5 from netCDF4
import Dataset
7 from datetime
import datetime, timedelta
8 import basic_plot_functions
as BasicPF
9 import plot_utils
as pu
10 import var_utils
as vu
11 import modelsp_utils
as mu
14 for fcTDelta
in np.arange(0,mu.fcRange+mu.interval,mu.interval):
16 for metrics
in mu.allFileStats:
17 for varName
in mu.varNames3d:
18 for latBand
in mu.latBands:
19 varNamesList = [
'expmgfs_day'+str(fcTDelta)+
'_'+ latBand +
'_'+ varName +
'_' + metrics]
20 varNamesListAll.append(varNamesList)
21 for i
in range(0,len(varNamesListAll)):
23 for iexp, expName
in enumerate(mu.expNames):
28 alldiffdata_rmsdiv = []
32 while TDATE <= mu.EDATE:
37 date = TDATE.strftime(
'%Y%m%d%H')
38 xlabeltime = np.append(xlabeltime,date[4:][:-2])
40 nc_file = mu.expDirectory+
'/'+mu.expLongNames[iexp]+
'/FC1DIAG/'+date+
'/diagnostic_stats/expmgfs.nc'
41 nc_fid = Dataset(nc_file,
"r", format=
"NETCDF4")
43 data = np.array( nc_fid.variables[
''.join(varNamesListAll[i])][:] )
44 alldata = np.append(alldata, data)
48 ylevels = list(np.arange(0,len(data),1))
49 alldata = alldata.reshape(len(xlabeltime),len(data)).T
53 arraylist= arraylist + [alldata]
55 dmin = np.amin(arraylist)
56 dmax = np.amax(arraylist)
62 FULL_SUBPLOT_LABELS =
True
64 fig = pu.setup_fig(nx, ny, subplot_size, aspect, FULL_SUBPLOT_LABELS)
65 title_tmp =
''.join(varNamesListAll[i])
66 region =
''.join(title_tmp.split(
"_")[2:][:-2])
67 var =
''.join(title_tmp.split(
"_")[3:][:-1])
68 stats =
''.join(title_tmp.split(
"_")[4:])
69 FCDay =
''.join(title_tmp.split(
"_")[1:][:-3])
76 indepLabel =
'Vertical level'
78 invert_ind_axis =
False
84 title = mu.expNames[iplot] +
' var:'+vu.varDictModel[var][1]+
'('+ vu.varDictModel[var][0]+
')\
85 '+region+
' min=' +str(round(valuemin,3))+
' max='+str(round(valuemax,3))
87 BasicPF.plotTimeSeries2D( fig, \
88 xlabeltime,ylevels, k, \
89 title, statDiagLabel, \
90 sciTicks, signDefinite, \
91 indepLabel, invert_ind_axis, \
92 ny, nx, nsubplots, iplot, \
93 dmin = dmin, dmax = dmax, \
94 interiorLabels = interiorLabels )
96 filename =
''.join(varNamesListAll[i])+
'_TS_2d'
97 pu.finalize_fig(fig, filename,
'png', FULL_SUBPLOT_LABELS,
True)
100 if (mu.diff2exp ==
'True' and ''.join(varNamesListAll[i])[-3:] ==
'RMS'):
101 for iexp
in range(1,mu.nExp):
103 alldiffdata = arraylist[iexp]-arraylist[0]
104 BasicPF.plotTimeserial2D(alldiffdata,xlabeltime,ylevels,
''.join(varNamesListAll[i])+mu.expNames[iexp]+
'-RMS'+mu.expNames[0])
108 if __name__ ==
'__main__':
main()