5 from netCDF4
import Dataset
8 import matplotlib.cm
as cm
9 import matplotlib.pyplot
as plt
10 from mpl_toolkits.basemap
import Basemap
11 from copy
import deepcopy
13 from datetime
import datetime, timedelta
14 import plot_utils
as pu
15 import var_utils
as vu
16 import modelsp_utils
as mu
23 for metrics
in mu.allFileStats:
24 for varName
in mu.varNames2d:
25 for latBand
in mu.latBands:
26 for fcTDelta
in np.arange(0, mu.fcRange+mu.interval,mu.interval):
27 varNamesList = [
'expmgfs_day'+str(fcTDelta)+
'_'+ latBand +
'_'+ varName +
'_' + metrics]
28 varNamesListAll.append(varNamesList)
31 for i
in range(0,len(varNamesListAll)):
33 alldiffdata_rmsdiv = []
36 for iexp, expName
in enumerate(mu.expNames):
40 while TDATE <= mu.EDATE:
43 date = TDATE.strftime(
'%Y%m%d%H')
44 xlabeltime = np.append(xlabeltime,date[4:][:-2])
45 nc_file = mu.expDirectory+
'/'+mu.expLongNames[iexp]+
'/FC1DIAG/'+date+
'/diagnostic_stats/expmgfs.nc'
46 nc_fid = Dataset(nc_file,
"r", format=
"NETCDF4")
48 data = np.array( nc_fid.variables[
''.join(varNamesListAll[i])][:] )
49 alldata = np.append(alldata, data)
54 arraylist= arraylist + [alldata]
60 fig,ax1 = plt.subplots(1,sharex=
True)
62 xarray = range(len(xlabeltime))
63 major_ticks = np.arange(0, len(xlabeltime), 1)
65 if (VarName ==
'qv' or VarName ==
'rho' or VarName ==
'q2'):
66 ax1.ticklabel_format(style=
'sci', axis=
'y', scilimits=(0,0))
68 for iexp
in range(0,mu.nExp):
69 ax1.plot(xarray,linesVals[iexp],pu.plotSpecs[iexp],markersize=5)
71 ax1.set_xticks(major_ticks[::4])
73 ax1.legend(mu.expNames, loc=
'upper left',fontsize=12,frameon=
False)
75 FCDay = VarName.split(
"_")[1]
76 if (FCDay ==
'day0.0'):
77 ax1.set_xlabel(
'Analysis Time',fontsize=15)
78 ax1.set_xticks(xarray[::4])
79 ax1.set_xticklabels(xlabeltime[::4],rotation=90)
80 elif (FCDay ==
'day0.25'):
81 ax1.set_xlabel(
'6h Forecast',fontsize=15)
82 ax1.set_xticks(xarray[::4])
83 ax1.set_xticklabels(xlabeltime[::4],rotation=90)
85 ax1.set_xlabel(
'Lead Time (day)',fontsize=15)
88 ax1.set_xticklabels(xlabeltime[::4])
89 plt.xticks(rotation=90)
91 region = VarName.split(
"_")[2]
92 var =
'_'.join(VarName.split(
"_")[3:][:-1])
93 stats =
''.join(VarName.split(
"_")[-1:])
94 ax1.set_ylabel(stats,fontsize=15)
95 plt.title(stats+
' variable:'+vu.varDictModel[var][1]+
'('+ vu.varDictModel[var][0]+
') '+region, fontsize = 12)
96 plt.savefig(VarName+
'.png',dpi=300,bbox_inches=
'tight')
101 if __name__ ==
'__main__':
main()
def plotTimeSerial(linesVals, xlabeltime, VarName)
TODO: move this part to basic_plot_functions.py.