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
12 import basic_plot_functions
as BasicPF
13 import plot_utils
as pu
14 import var_utils
as vu
15 import modelsp_utils
as mu
19 for metrics
in mu.allFileStats:
20 for varName
in mu.varNames3d:
21 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)
36 alldata = alldata.reshape(len(xlabeltime),len(data)).T
37 ylevels = list(np.arange(0,len(data),1))
38 varNamesListUse =
'expmgfs_fc_'+ latBand +
'_'+ varName +
'_' + metrics
42 arraylist= arraylist + [alldata]
43 dmin = np.amin(arraylist)
44 dmax = np.amax(arraylist)
50 FULL_SUBPLOT_LABELS =
True
52 fig = pu.setup_fig(nx, ny, subplot_size, aspect, FULL_SUBPLOT_LABELS)
53 title_tmp = varNamesListUse
54 region =
''.join(title_tmp.split(
"_")[2:][:-2])
55 var =
''.join(title_tmp.split(
"_")[3:][:-1])
56 stats =
''.join(title_tmp.split(
"_")[4:])
64 indepLabel =
'Vertical level'
66 invert_ind_axis =
False
72 title = mu.expNames[iplot] +
' var:'+vu.varDictModel[var][1]+
'('+ vu.varDictModel[var][0]+
')\
73 '+region+
' min=' +str(round(valuemin,3))+
' max='+str(round(valuemax,3))
75 BasicPF.plotTimeSeries2D( fig, \
76 xlabeltime,ylevels, k, \
77 title, statDiagLabel, \
78 sciTicks, signDefinite, \
79 indepLabel, invert_ind_axis, \
80 ny, nx, nsubplots, iplot, \
81 dmin = dmin, dmax = dmax, \
82 interiorLabels = interiorLabels )
84 filename = varNamesListUse+
'_TS_2d'
85 pu.finalize_fig(fig, filename,
'png', FULL_SUBPLOT_LABELS,
True)
88 if (mu.diff2exp ==
'True' and varNamesListUse[-3:] ==
'RMS'):
89 for iexp
in range(1,mu.nExp):
91 alldiffdata = arraylist[iexp]-arraylist[0]
92 BasicPF.plotTimeserial2D(alldiffdata,xlabeltime,ylevels,varNamesListUse+mu.expNames[iexp]+
'-RMS'+mu.expNames[0])
97 if __name__ ==
'__main__':
main()