diff --git a/jobs/JLANDDA_PREP_OBS b/jobs/JLANDDA_PREP_OBS index 3e6bb7ec..b456670c 100755 --- a/jobs/JLANDDA_PREP_OBS +++ b/jobs/JLANDDA_PREP_OBS @@ -73,6 +73,8 @@ fi mkdir -p ${COMOUT} export COMOUTobs=${COMOUTobs:-${COMOUT}/obs} mkdir -p ${COMOUTobs} +export COMOUTplot="${COMOUTplot:-${COMOUT}/plot}" +mkdir -p ${COMOUTplot} # Create a teomporary share directory export DATA_SHARE="${DATA_SHARE:-${DATAROOT}/DATA_SHARE/${PDY}}" diff --git a/modulefiles/tasks/hera/task.prep_obs.lua b/modulefiles/tasks/hera/task.prep_obs.lua index e7bcb54c..d57971da 100644 --- a/modulefiles/tasks/hera/task.prep_obs.lua +++ b/modulefiles/tasks/hera/task.prep_obs.lua @@ -10,7 +10,5 @@ load(pathJoin("py-cartopy", py_cartopy_ver)) load(pathJoin("py-matplotlib", py_matplotlib_ver)) load(pathJoin("py-netcdf4", py_netcdf4_ver)) load(pathJoin("py-numpy", py_numpy_ver)) -load(pathJoin("py-pandas", py_pandas_ver)) load(pathJoin("py-pyyaml", py_pyyaml_ver)) -load(pathJoin("py-xarray", py_xarray_ver)) diff --git a/scripts/exlandda_plot_stats.sh b/scripts/exlandda_plot_stats.sh index 93ac7c14..69179a72 100755 --- a/scripts/exlandda_plot_stats.sh +++ b/scripts/exlandda_plot_stats.sh @@ -19,30 +19,28 @@ nHH=${NTIME:8:2} # Stats Plot ############################################################ -# Path to the directory containing the input file -INPUTFP="${DATA_HOFX}" # Field variable -FIELDVAR="OMA" +field_var="OMA" # Field Range for scatter plot: [Low,High] -FRLOW=-300 -FRHIGH=300 +field_range_low=-300 +field_range_high=300 # Number of bins in histogram plot -NBINS=100 +nbins=100 # Plot type (scatter/histogram/both) -PLOTTYPE="both" +plottype="both" # Figure title -FIGTITLE="GHCN Snow Depth (mm)::Obs-Ana::${PDY}" +title_fig="GHCN Snow Depth (mm)::Obs-Ana::${PDY}" # Prefix of output file name -PREOUTFN="hofx_oma_${PDY}" +output_prefix="hofx_oma_${PDY}" cat > plot_hofx.yaml < plot_timehistory.yaml < plot_restart.yaml < plot_obs_ghcn.yaml < -180:180 +# lon_max=np.max(lon) +# if lon_max>180: +# lon=(lon+180)%360-180 + + lon=longitude + lat=latitude + + # Highest and lowest longitudes and latitudes for plot extent + lon_min=np.min(lon) + lon_max=np.max(lon) + lat_min=np.min(lat) + lat_max=np.max(lat) +# extent=[lon_min,lon_max,lat_min,lat_max] + # for CONUS +# extent=[-125,-66,23,53] + # for Northern Hemisphere + extent=[-179,179,0,82.5] + print(extent) + +# c_lon=np.mean(extent[:2]) + c_lon=-77.0369 # D.C. + print(' c_lon=',c_lon) + + # Variables +# vars_out=["ObsValue","ObsError","PreQC"] + vars_out=["ObsValue"] + for svar in vars_out: + svar_plot(svar,mdat,lon,lat,extent,c_lon,out_title_base,out_fn_base,work_dir) + + +# Variable plot =============================================== CHJ ===== +def svar_plot(svar,mdat,lon,lat,extent,c_lon,out_title_base,out_fn_base,work_dir): +# ============================================================= CHJ ===== + + print(' ===== '+svar+' === Total Snow Depth =====================') + # Extract data array + sfld=mdat.groups[svar].variables['totalSnowDepth'][:] + + svar="SnowDepth" + out_title_fld=out_title_base+svar + out_fn=out_fn_base+svar + + cs_cmap='gist_ncar_r' + lb_ext='neither' + tick_ln=1.5 + tick_wd=0.45 + tlb_sz=3 + scat_sz=1.0 + n_rnd=2 + cmap_range='fixed' + + print(' svar name=',svar) + + # Max and Min of the field + fmax=np.max(sfld) + fmin=np.min(sfld) + print(' fld_max=',fmax) + print(' flx_min=',fmin) + + # Make the colormap range symmetry + print(' cmap range=',cmap_range) + if cmap_range=='symmetry': + tmp_cmp=max(abs(fmax),abs(fmin)) + cs_min=round(-tmp_cmp,n_rnd) + cs_max=round(tmp_cmp,n_rnd) + elif cmap_range=='round': + cs_min=round(fmin,n_rnd) + cs_max=round(fmax,n_rnd) + elif cmap_range=='real': + cs_min=fmin + cs_max=fmax + elif cmap_range=='fixed': + cs_min=0 + cs_max=1000.0 + else: + sys.exit('ERROR: wrong colormap-range flag !!!') + + print(' cs_max=',cs_max) + print(' cs_min=',cs_min) + print(' extent=',extent) + + # Plot field + fig,ax=plt.subplots(1,1,subplot_kw=dict(projection=ccrs.Robinson(c_lon))) + ax.set_extent(extent, ccrs.PlateCarree()) + # Call background plot + back_plot(ax) + ax.set_title(out_title_fld,fontsize=9) + cs=ax.scatter(lon,lat,transform=ccrs.PlateCarree(),c=sfld,cmap=cs_cmap, + vmin=cs_min,vmax=cs_max,s=scat_sz) + divider=make_axes_locatable(ax) + ax_cb=divider.new_horizontal(size="3%",pad=0.1,axes_class=plt.Axes) + fig.add_axes(ax_cb) + cbar=plt.colorbar(cs,cax=ax_cb,extend=lb_ext) + cbar.ax.tick_params(labelsize=8) + cbar.set_label(svar,fontsize=8) + + # Output figure + ndpi=300 + out_file(work_dir,out_fn,ndpi) + + +# Background plot ==================================================== CHJ ===== +def back_plot(ax): +# ==================================================================== CHJ ===== + + # Resolution of background natural earth data ('50m' or '110m') + back_res='50m' + + fline_wd=0.5 # line width + falpha=0.7 # transparency + + # natural_earth + land=cfeature.NaturalEarthFeature('physical','land',back_res, + edgecolor='face',facecolor=cfeature.COLORS['land'], + alpha=falpha) + lakes=cfeature.NaturalEarthFeature('physical','lakes',back_res, + edgecolor='blue',facecolor='none', + linewidth=fline_wd,alpha=falpha) + coastline=cfeature.NaturalEarthFeature('physical','coastline', + back_res,edgecolor='black',facecolor='none', + linewidth=fline_wd,alpha=falpha) + states=cfeature.NaturalEarthFeature('cultural','admin_1_states_provinces', + back_res,edgecolor='green',facecolor='none', + linewidth=fline_wd,linestyle=':',alpha=falpha) + borders=cfeature.NaturalEarthFeature('cultural','admin_0_countries', + back_res,edgecolor='red',facecolor='none', + linewidth=fline_wd,alpha=falpha) + +# ax.add_feature(land) +# ax.add_feature(lakes) +# ax.add_feature(states) +# ax.add_feature(borders) + ax.add_feature(coastline) + + +# Output file ======================================================= CHJ ===== +def out_file(work_dir,out_file,ndpi): +# =================================================================== CHJ ===== + # Output figure + fp_out=os.path.join(work_dir,out_file) + plt.savefig(fp_out+'.png',dpi=ndpi,bbox_inches='tight') + plt.close('all') + + +# Main call ========================================================= CHJ ===== +if __name__=='__main__': + main() +