def make_spatial_bias_plot(df, out_name, vmin, vmax, col1='OZONE', col2='O3', date=None, region='domain', **kwargs): 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 = 25.0 lonmin = -130.0 latmax = 55.0 lonmax = -55.0 else: from monet.util.tools import get_epa_region_bounds as get_epa_bounds latmin, lonmin, latmax, lonmax, acro = get_epa_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()
def make_spatial_plot(da, lev, alt_label, outname, proj, startdate, enddate, count, vmin, vmax, region='domain'): cbar_kwargs = dict(aspect=30, shrink=.8) #dict(aspect=30) if region == 'domain': latmin = 25.0 lonmin = -130.0 latmax = 48.0 lonmax = -70.0 else: from monet.util.tools import get_epa_region_bounds as get_epa_bounds latmin, lonmin, latmax, lonmax, acro = get_epa_bounds(index=None, acronym=region) # import stratify # lev3d=(daz*0.0)+(lev) #convert target level to 3d # new_da = stratify.interpolate(lev3d, daz, da, # axis=0) da.values = da extent = [lonmin, lonmax, latmin, latmax] ax = da[lev, :, :].monet.quick_map(cbar_kwargs=cbar_kwargs, figsize=(15, 8), map_kwarg={ 'states': True, 'crs': proj, 'extent': extent }, robust=True, vmin=vmin, vmax=vmax, cmap=plt.cm.get_cmap('Spectral_r')) plt.gcf().canvas.draw() plt.tight_layout(pad=0) if startdate == None and enddate == None: date = pd.Timestamp(da.time.values) initial_datetime = date # dt = date - initial_datetime # dtstr = str(dt.days * 24 + dt.seconds // 3600).zfill(3) dt = count dtstr = str(dt).zfill(3) plt.title( date.strftime( 'time=%Y/%m/%d %H:00 | CMAQ | Meters AGL ~ {}'.format( alt_label))) else: plt.title( 'average time period | CMAQ | Meters AGL ~ {}'.format(alt_label)) cbar = ax.figure.get_axes()[1] if vmin == None and vmax == None: vmin, vmax = cbar.get_ybound() # vars = df.keys() # varname = [x for x in vars if x not in ['latitude','longitude']][0] # ax.scatter(df.longitude.values,df.latitude.values,s=25,c=df[varname],transform=ccrs.PlateCarree(),edgecolor='b',linewidth=.50,vmin=vmin,vmax=vmax,cmap=plt.cm.get_cmap('Spectral_r')) ax.set_extent(extent, crs=ccrs.PlateCarree()) if startdate == None and enddate == None: savename = "{}.{}.{}.jpg".format(outname, initial_datetime.strftime('sp'), dtstr) else: savename = "{}.{}.jpg".format(outname, 'sp') print(savename) monet.plots.savefig(savename, bbox_inches='tight', dpi=100, decorate=True) plt.close()