4 from netCDF4
import Dataset
6 import matplotlib.pyplot
as plt
11 def normality(testdata, test, mpi, omp, suffix, testfig):
14 for impi
in range(0, int(mpi)):
16 f = Dataset(testdata +
"/" + test +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + mpi.zfill(6) +
"-" + format(impi+1,
'06d') +
".nc",
"r", format=
"NETCDF4")
19 if "ens_norm" in f.variables:
20 nloc = f[
"ens_norm"][:].shape[0]
22 ne = f[
"ens_norm"][:].shape[1]
23 ens_norm = np.zeros((0, ne))
24 ens_step = np.zeros((0, ne-1))
26 for iloc
in range(0, nloc):
27 ens_norm = np.append(ens_norm, [f[
"ens_norm"][iloc,:].data], axis=0)
28 ens_step = np.append(ens_step, [f[
"ens_step"][iloc,:].data], axis=0)
31 x_norm = np.linspace(1, ne, ne)
32 x_step = np.linspace(1, ne-1, ne-1)
35 fig, ax = plt.subplots(nrows=2)
36 fig.subplots_adjust(hspace=0.5)
37 ax[0].set_title(
"Normalized perturbation amplitude")
38 ax[0].set_xlim([1.0,float(ne)])
39 ax[0].set_ylim([-0.1,1.1])
40 ax[0].set_xlabel(
"Ordered member")
41 ax[0].plot(x_norm, ens_norm[0,:])
42 ax[1].set_title(
"Normalized perturbation amplitude step")
43 ax[1].set_xlim([1.0,float(ne-1)])
44 ax[1].set_ylim([-0.1,1.1])
45 ax[1].set_xlabel(
"Ordered member")
46 ax[1].plot(x_step, ens_step[0,:])
49 plt.savefig(testfig +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
".jpg", format=
"jpg", dpi=300)