def make_spatial_bias_plot(df,
                           out_name,
                           vmin,
                           vmax,
                           col1='pm25_ug3',
                           col2='sfc_pm25',
                           date=None,
                           region='domain',
                           **kwargs):
    if region == 'domain':
        ax = monet.plots.sp_scatter_bias(df,
                                         col1=col1,
                                         col2=col2,
                                         map_kwargs=dict(states=False),
                                         val_max=vmax,
                                         val_min=vmin,
                                         **kwargs)
    else:
        ax = monet.plots.sp_scatter_bias(df,
                                         col1=col1,
                                         col2=col2,
                                         map_kwargs=dict(states=True),
                                         val_max=vmax,
                                         val_min=vmin,
                                         **kwargs)

    date = pd.Timestamp(date)
    dt = date - initial_datetime
    dtstr = str(dt.days * 24 + dt.seconds // 3600).zfill(3)
    plt.title(date.strftime('time=%Y/%m/%d %H:00 | CMAQ - AIRNOW '))

    if region == 'domain':
        latmin = -90.0
        lonmin = -180.0
        latmax = 90.0
        lonmax = 180.0
    else:
        from monet.util.tools import get_giorgi_region_bounds as get_giorgi_bounds
        latmin, lonmin, latmax, lonmax, acro = get_giorgi_bounds(
            index=None, acronym=region)

    plt.xlim([lonmin, lonmax])
    plt.ylim([latmin, latmax])

    plt.tight_layout(pad=0)
    savename = "{}.{}.{}.jpg".format(out_name,
                                     initial_datetime.strftime('spbias'),
                                     dtstr)
    print(savename)
    monet.plots.savefig(savename, bbox_inches='tight', dpi=100, decorate=True)
    plt.close()
示例#2
0
            startdatename_obj = datetime.datetime.strptime(
                startdate, '%Y-%m-%d %H:%M:%S')
            enddatename_obj = datetime.datetime.strptime(
                enddate, '%Y-%m-%d %H:%M:%S')
            startdatename = str(
                datetime.datetime.strftime(startdatename_obj, '%Y-%m-%d_%H'))
            enddatename = str(
                datetime.datetime.strftime(enddatename_obj, '%Y-%m-%d_%H'))
        else:
            startdatename = 'Entire'
            enddatename = 'Period'

        if subset_giorgi is True:
            #df.query('giorgi_region == '+'"'+ee+'"',inplace=True)
            from monet.util.tools import get_giorgi_region_bounds as get_giorgi_bounds
            latmin, lonmin, latmax, lonmax, acro = get_giorgi_bounds(
                index=None, acronym=ee)
            df = df[(df['latitude'] >= latmin) & (df['latitude'] <= latmax)]
            df = df[(df['longitude'] >= lonmin) & (df['longitude'] <= lonmax)]

        if reg is True and subset_giorgi is False:
            stats = open(
                finput[0].replace('.hdf', '_') + startdatename + '_' +
                enddatename + '_reg_stats_domain.txt', 'w')
        elif reg is True and subset_giorgi is True:
            stats = open(
                finput[0].replace('.hdf', '_') + startdatename + '_' +
                enddatename + '_reg_stats_' + ee + '.txt', 'w')
        elif reg is False and subset_giorgi is True:
            stats = open(
                finput[0].replace('.hdf', '_') + startdatename + '_' +
                enddatename + '_stats_' + ee + '.txt', 'w')