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 import plot_utils
as pu
14 import var_utils
as vu
15 import modelsp_utils
as mu
18 for metrics
in mu.allFileStats:
19 for varName
in mu.varNames2d:
20 for latBand
in mu.latBands:
22 for iexp, expName
in enumerate(mu.expNames):
26 alldiffdata_rmsdiv = []
27 nc_file = mu.expDirectory+
'/'+mu.expLongNames[iexp]+
'/FC2DIAG/expmgfs.nc'
28 nc_fid = Dataset(nc_file,
"r", format=
"NETCDF4")
29 for fcTDelta
in np.arange(0,mu.fcRange+mu.interval,mu.interval):
30 varNamesList = [
'expmgfs_day'+str(fcTDelta)+
'_'+ latBand +
'_'+ varName +
'_' + metrics]
32 data = np.array( nc_fid.variables[
''.join(varNamesList)][:])
33 alldata = np.append(alldata, data)
34 xlabeltime = np.append(xlabeltime,fcTDelta)
35 varNamesListUse =
'expmgfs_fc_'+ latBand +
'_'+ varName +
'_' + metrics
39 arraylist= arraylist + [alldata]
44 fig,ax1 = plt.subplots(1,sharex=
True)
46 xarray = range(len(xlabeltime))
47 major_ticks = np.arange(0, len(xlabeltime), 1)
49 if (VarName ==
'qv' or VarName ==
'rho' or VarName ==
'q2'):
50 ax1.ticklabel_format(style=
'sci', axis=
'y', scilimits=(0,0))
52 for iexp
in range(0,mu.nExp):
53 ax1.plot(xarray,linesVals[iexp],pu.plotSpecs[iexp],markersize=5)
55 ax1.set_xticks(major_ticks[::4])
57 ax1.legend(mu.expNames, loc=
'upper left',fontsize=12,frameon=
False)
59 FCDay = VarName.split(
"_")[1]
60 if (FCDay ==
'day0.0'):
61 ax1.set_xlabel(
'Analysis Time',fontsize=15)
62 ax1.set_xticks(xarray[::4])
63 ax1.set_xticklabels(xlabeltime[::4],rotation=90)
64 elif (FCDay ==
'day0.25'):
65 ax1.set_xlabel(
'6h Forecast',fontsize=15)
66 ax1.set_xticks(xarray[::4])
67 ax1.set_xticklabels(xlabeltime[::4],rotation=90)
69 ax1.set_xlabel(
'Lead Time (day)',fontsize=15)
70 ax1.set_xticks(major_ticks[::1])
71 ax1.set_xticks(xarray[::1])
72 ax1.set_xticklabels(xlabeltime[::1],rotation=0)
76 plt.xticks(rotation=90)
78 region = VarName.split(
"_")[2]
79 var =
'_'.join(VarName.split(
"_")[3:][:-1])
80 stats =
''.join(VarName.split(
"_")[-1:])
81 ax1.set_ylabel(stats,fontsize=15)
82 plt.title(stats+
' variable:'+vu.varDictModel[var][1]+
'('+ vu.varDictModel[var][0]+
') '+region, fontsize = 12)
83 plt.savefig(VarName+
'.png',dpi=300,bbox_inches=
'tight')
88 if __name__ ==
'__main__':
main()
def plotTimeSerial(linesVals, xlabeltime, VarName)