# varname = 'fogpresent' varname = 'SMOIS' # varname = 'fogbase' # varname = 'fogpct' # varname = 'QCLOUD' # varname = 'uvmet' # varname = 'wa' # varname = 'LU_INDEX' read_data = True if read_data: # wildcard_pat = "*d{:02d}02_2009-06-\{0[0-9],1[01]\}".format(DOMAIN) wildcard_pat = "*d{:02d}_2005-*".format(DOMAIN) vd = var_diff(os.path.join(ctl_dir, wildcard_pat), os.path.join(dry_dir, wildcard_pat), label_A='ctl', label_B='drysoil_CLM', varname=varname) vd.read_files() vd.to_netcdf( os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', '{}_d{:02d}_CLM_drysoil.nc'.format(varname, DOMAIN))) print('done reading files ({})'.format(datetime.datetime.now() - t0)) # vd.mask_land_or_water(mask_water=False) else: vd = var_diff(ncfile=os.path.join( '/', 'global', 'cscratch1', 'sd', 'twhilton', '{varname}_d{DOMAIN:02d}_CLM_drysoil.nc'.format(varname=varname, DOMAIN=DOMAIN))) # vd = is_foggy_obrien_2013(vd) # vd.get_significance_mask(significance=0.99, adj_autocorr=False)
import os from plot_diff import var_diff, graphics if __name__ == "__main__": rootdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'WRFv3.9_Sensitivity', 'FromScratch') ctl_dir = os.path.join(rootdir, 'WRFV3_Ctl', 'run') ctl2_dir = os.path.join(rootdir, 'WRFV3_Ctl2', 'run') vd = var_diff(os.path.join(ctl_dir, 'summen_sensitivity_ctl', '*d01_2009-06*'), os.path.join(ctl2_dir, 'summen_sensitivity_ctl2', '*d01_2009-06*'), label_A='ctl', label_B='ctl2', varname='QCLOUD') read_data = True if read_data: vd.read_files() # vd.mask_land_or_water(mask_water=True) for this_t in range(0, 120): # 255 fig = graphics(vd, t_idx=this_t, layer=0, domain=1, pfx='ctl2')
if __name__ == "__main__": rootdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'WRFv3.9_Sensitivity') ctl_dir = os.path.join(rootdir, 'WRFv3.9_Sensitivity_Ctl', 'WRFV3', 'run') ctl_dir_new = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'WRFv3.9_Sensitivity', 'FromScratch', 'WRFV3_Ctl', 'run') urb_dir = os.path.join(rootdir, 'FromScratch', 'WRFV3_urban', 'run') vd = var_diff( os.path.join(ctl_dir_new, 'summen_sensitivity_ctl', '*d{:02d}_2009-06-02*.nc'.format(DOMAIN)), os.path.join(urb_dir, 'summen_sensitivity_urban', '*d{:02d}_2009-06-02*.nc'.format(DOMAIN)), label_A='ctl', label_B='urban', # varname='LCL') varname='QCLOUD') # varname='uvmet') # varname='wa') # varname='LU_INDEX') read_data = True if read_data: vd.read_files() # vd.mask_land_or_water(mask_water=False) for this_t in range(0, 47): # plotter = VarDiffPlotter(vd, t_idx=this_t, layer=0,
import os from plot_diff import var_diff, graphics if __name__ == "__main__": rootdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'WRFv3.9_Sensitivity', 'FromScratch') ctl_dir = os.path.join(rootdir, 'WRFV3_Ctl', 'run') dry_dir = os.path.join(rootdir, 'WRFV3_Dry', 'run') # vd = var_diff(os.path.join(ctl_dir, 'met_em.d01.2009-06-02_00:00:00.nc'), # os.path.join(dry_dir, 'met_em.d01.2009-06-02_00:00:00.nc'), # label_A='ctl met_em', # label_B='dry met_em', # varname='SM000010') vd = var_diff(os.path.join(ctl_dir, 'summen_sensitivity_ctl', 'wrfsees_ccs3pb1_ls2_d02_2009-06-02_00:00:00'), os.path.join(dry_dir, 'summen_sensitivity_dry', 'wrfsees_ccs3pb1_ls2_d02_2009-06-02_00:00:00'), label_A='ctl out', label_B='dry out', varname='SMOIS') read_data = True if read_data: vd.read_files() # vd.mask_land_or_water(mask_water=True) for this_t in range(0, 6): # 255 fig = graphics(vd, t_idx=this_t, layer=0, domain=2)
import os from plot_diff import var_diff, graphics if __name__ == "__main__": cscratch = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton') ctl_dir = os.path.join(cscratch, 'WRFv3.9_Sensitivity', 'WRFv3.9_Sensitivity_Ctl_short', 'WRFV3', 'run') dry_dir = os.path.join(cscratch, 'WRFv3.9_Sensitivity', 'WRFv3.9_Sensitivity_DrySoil_newrst', 'WRFV3', 'run', 'summen_sensitivity_drysoil') vd = var_diff(os.path.join(ctl_dir, 'wrfrst_d01_2009-06-02*'), os.path.join(dry_dir, 'wrfsees_ccs3pb1_ls2_d01_2009-06-02*'), label_A='short_ctl rst', label_B='short_dry out', varname='QCLOUD') read_data = True if read_data: vd.read_files() # vd.mask_land_or_water(mask_water=True) for this_t in range(0, 1): # 255 fig = graphics(vd, t_idx=this_t, layer=0, domain=1)
out_dir = os.path.join(cscratchdir, 'plots_temporary') # insignificant_pixels = ma.masked_invalid(means_diff_test.main(0.95)).mask varname = 'HFX' runkey = 'CLM_nourban' runkey = 'CLM_drysoil' runkey = 'RWurban' read_data = True if read_data: # wildcard_pat = "*d{:02d}02_2009-06-\{0[0-9],1[01]\}".format(DOMAIN) wildcard_pat = "*d{:02d}_2009-06-*".format(DOMAIN) vd = var_diff(os.path.join(ctl_dir, wildcard_pat), os.path.join(urb_dir, wildcard_pat), label_A='ctl', label_B='urbanRW', varname=varname) vd.read_files() vd.get_significance_mask(significance=0.95, adj_autocorr=True) vd.to_netcdf( os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', '{}_d{:02d}_RWurban.nc'.format(varname, DOMAIN))) print('done reading files ({})'.format(datetime.datetime.now() - t0)) # vd.mask_land_or_water(mask_water=False) else: vd = var_diff(ncfile=os.path.join( cscratchdir, # '/Users/tim/work/Data/SummenWRF/', # '{varname}_d{DOMAIN:02d}_RWurban.nc'.format( '{varname}_d{DOMAIN:02d}_{runkey}.nc'.format(
"""compare wrf.ll_points() to XLONG, XLAT variables """ nc = netCDF4.Dataset(wrffile, 'r') xlat = nc.variables['XLAT_U'][...].squeeze() xlong = nc.variables['XLONG_U'][...].squeeze() ll_points_list = ll_points(xlat, xlong) return (ll_points_list, xlat, xlong) if __name__ == "__main__": varname = 'fogpresent' read_data = False vd = var_diff(ncfile=os.path.join( '/Users/tim/work/Data/SummenWRF/', '{varname}_d{DOMAIN:02d}_CLM_nourban.nc'.format(varname=varname, DOMAIN=DOMAIN))) # for k in vd.data.keys(): # vd.data[k] = vd.data[k] * 100.0 if vd.p is None: vd.get_significance_mask(significance=0.95, adj_autocorr=True) pfx = 'gridtest' # for this_series in ['all_tstamps', 'time_avg']: t_end = 1 pfx = pfx + '_timeavg' vd.aggregate_time(time_avg=True) time_title_str = 'June 2005' for k in vd.data.keys(): vd.data[k][...] = np.ones(vd.data[k].shape)
cscratchdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton') rootdir = os.path.join(cscratchdir, 'WRFv4.0_Sensitivity') ctl_dir = os.path.join(rootdir, 'WRFCLMv4.0_NCEPDOEp2', 'WRFV4', 'run', 'summen_2005_ctl_NCEPDOE') nourb_dir = os.path.join(rootdir, 'WRFCLMv4.0_NCEPDOEp2_deurbanized', 'WRFV4', 'run', 'summen_2005_deurbanized_NCEPDOE') out_dir = os.path.join(cscratchdir, 'plots_temporary') if READ_DATA: # wildcard_pat = "*d{:02d}02_2009-06-\{0[0-9],1[01]\}".format(DOMAIN) wildcard_pat = "*d{:02d}_2005-*".format(DOMAIN) re_pat = "d{:02d}_all\\.nc".format(DOMAIN) vd = var_diff(os.path.join(ctl_dir, re_pat), os.path.join(nourb_dir, re_pat), label_A='ctl', label_B='no_urban_CLM', varname=varname) vd.read_files() # for k in vd.data.keys(): # z_ax = vd.var_axes.index('Lay') # idx = [slice(None), ] * vd.data[k].ndim # idx[z_ax] = slice(0, 10) # vd.data[k] = np.mean(vd.data[k][idx], axis=z_ax) # vd.var_axes.pop(vd.var_axes.index('Lay')) vd.get_significance_mask(significance=0.95, adj_autocorr=False) vd.to_netcdf( os.path.join( '/', 'global', 'cscratch1', 'sd', 'twhilton', '{}_d{:02d}_CLM_nourban_noautocorr.nc'.format(varname, DOMAIN)))
def main(significance=None): if significance is None: significance = significance_default cscratchdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton') rootdir = os.path.join(cscratchdir, 'WRFv3.9_Sensitivity') ctl_dir = os.path.join(rootdir, 'WRFV3_Ctl', 'run', 'summen_sensitivity_ctl') urb_dir = os.path.join(rootdir, 'WRFV3_redwoodsurban', 'run', 'summen_redwoodsurban') # urb_dir = os.path.join('/', 'global', 'cscratch1', 'sd', # 'twhilton', 'WRFv3.9_Sensitivity', # 'FromScratch', 'WRFV3_urban', 'run', # 'summen_sensitivity_urban') out_dir = os.path.join(cscratchdir, 'plots_temporary') if read_vardiff_from_netcdf: vd = var_diff( ncfile=os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'fog_pct_d02_RWurban.nc')) else: # wildcard_pat = "*d{:02d}02_2009-06-\{0[0-9],1[01]\}".format(DOMAIN) wildcard_pat = "*d{:02d}_2009-06-*".format(DOMAIN) vd = var_diff( os.path.join(ctl_dir, wildcard_pat), os.path.join(urb_dir, wildcard_pat), label_A='ctl', label_B='urbanRW', # varname='HFX') varname='fogpresent') # varname='fogbase') # varname='fogpct') vd.read_files() vd.to_netcdf( os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'fog_pct_d02_RWurban.nc')) print('calculating probabilities') z = vd.diff_means_test(adj_autocorr=adj_autocorr) vectorized_cdf = np.vectorize(lambda x: norm.cdf(x, 0.0, 1.0)) p = vectorized_cdf(z) p = np.ma.masked_less(p, significance) # draw map print('drawing map') fig = MyFig(figsize=(8, 8)) ax = fig.add_subplot(111, projection=CoastalSEES_WRF_prj()) this_cmap = matplotlib.cm.get_cmap('Dark2_r') this_map = CoastalSEES_WRF_Mapper(ax=ax, domain=DOMAIN) this_map.pcolormesh(vd.lon, vd.lat, p, vmin=0, vmax=1.0, cmap=this_cmap) ax.set_title(('urbanized redwood experiment\n' 'fog differences significant ' 'at {:0.0f}%'.format(significance * 100.0))) significant_patch = mpatches.Patch(color=this_cmap.colors[-1], label='signficant') ax.legend(handles=(significant_patch, )) fname = ('fogpct_RWurban_d{domain:02d}_means_diff_' 'map_2tail_adj{adj}_p{sig:0.2f}.png'.format(domain=DOMAIN, adj=adj_autocorr, sig=significance)) fig.savefig(fname=fname) print('saved {}'.format(fname)) return (p)
from plot_diff import var_diff, graphics if __name__ == "__main__": rootdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'WRFv3.9_Sensitivity', 'FromScratch') ctl_dir = os.path.join(rootdir, 'WRFV3_Ctl', 'run') dry_dir = os.path.join(rootdir, 'WRFV3_Dry', 'run') # vd = var_diff(os.path.join(ctl_dir, 'met_em.d01.2009-06-02_00:00:00.nc'), # os.path.join(dry_dir, 'met_em.d01.2009-06-02_00:00:00.nc'), # label_A='ctl met_em', # label_B='dry met_em', # varname='SM000010') vd = var_diff(os.path.join(ctl_dir, 'summen_sensitivity_ctl_d01_3hr', 'wrfinput_ctl_3hr_d01_2009-06*'), os.path.join(dry_dir, 'summen_sensitivity_dry_d01_3hr', 'wrfinput_dry_3hr_d01_2009-06*'), label_A='ctl out', label_B='dry out', varname='QCLOUD') read_data = True if read_data: vd.read_files() # vd.mask_land_or_water(mask_water=True) for this_t in range(0, 20): # 255 fig = graphics(vd, t_idx=this_t, layer=0, domain=1, pfx='fromscratch_nomatch_t')
import os from plot_diff import var_diff, graphics if __name__ == "__main__": rootdir = os.path.join('/', 'global', 'cscratch1', 'sd', 'twhilton', 'WRFv3.9_Sensitivity', 'FromScratch') dry0p05_dir = os.path.join(rootdir, 'WRFV3_Dry', 'run') dry0p70_dir = os.path.join(rootdir, 'WRFV3_0.7Dry', 'run') ctl_dir = os.path.join(rootdir, 'WRFV3_Ctl', 'run') vd_0p05_0p70 = var_diff(os.path.join(dry0p05_dir, 'summen_sensitivity_dry', '*d01_2009-06-0[12]*'), os.path.join(dry0p70_dir, 'summen_sensitivity_0.7dry', '*d01_2009-06-0[12]*'), label_A='dry 0.05', label_B='dry 0.70', varname='QCLOUD') vd_d0p7_ctl = var_diff(os.path.join(dry0p70_dir, 'summen_sensitivity_0.7dry', '*d02_2009-06-0[12]*'), os.path.join(ctl_dir, 'summen_sensitivity_ctl', '*d02_2009-06-0[12]*'), label_A='dry 0.70', label_B='control', varname='QCLOUD') read_data = True if read_data: vd_0p05_0p70.read_files() vd_d0p7_ctl.read_files()