

from datetime import datetime
import os
import matplotlib.pyplot as plt

import smartcarb as sc

# Extract values and make plots to analyze undershooting near strong point sources.
#
# - 
#

XLIM = (2.34, 3.48)
YLIM = (4.25, 5.16)

PATH = '/users/gkuhl/projects/smartcarb/figures/power-plants/'

def powerplants_xco2():

    start = datetime(2015,1,1)
    stop = datetime(2015,1,3)

    for time in sc.misc.iter_times(start, stop):
        print(time)
        rlon, rlat, xco2 = sc.io.read_field(
                time, datetime(2015,1,1), ['rlon', 'rlat', 'XCO2_TOT'],
                input_files='2D'
        )
        fig = sc.map.make_cosmo_map(rlon, rlat, xco2[0], vmin=0, vmax=2, border=0.1, label='XCO$_2$ (ppm)')
        ax, cax = fig.get_axes()
        ax.set_title(time)

        ax.set_xlim(*XLIM)
        ax.set_ylim(*YLIM)

        filename = os.path.join(PATH, time.strftime('cosmo_2d_pp_%Y%m%d%H.png'))
        fig.savefig(filename)
        plt.close()


if __name__ == '__main__':
    powerplants_xco2()
