4 from netCDF4
import Dataset
6 import matplotlib.pyplot
as plt
11 def avg(testdata, test, mpi, omp, suffix, testfig):
13 f = Dataset(testdata +
"/" + test +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
".nc",
"r", format=
"NETCDF4")
21 for group
in f.groups:
23 disth = f.groups[group][
"disth"][:]
29 nl0r = f.groups[group][
"cor_hist"][:,:,:,:].shape[1]
32 nbins = f.groups[group][
"cor_hist"][:,:,:,:].shape[3]
35 l0rl0_to_l0 = f.groups[group][
"l0rl0_to_l0"][:,:]
36 m11_hist = f.groups[group][
"m11_hist"][:,:,:,:]
37 m11_bins = f.groups[group][
"m11_bins"][:,:,:,:]
38 m11m11_hist = f.groups[group][
"m11m11_hist"][:,:,:,:]
39 m11m11_bins = f.groups[group][
"m11m11_bins"][:,:,:,:]
40 m2m2_hist = f.groups[group][
"m2m2_hist"][:,:,:,:]
41 m2m2_bins = f.groups[group][
"m2m2_bins"][:,:,:,:]
42 m22_hist = f.groups[group][
"m22_hist"][:,:,:,:]
43 m22_bins = f.groups[group][
"m22_bins"][:,:,:,:]
44 cor_hist = f.groups[group][
"cor_hist"][:,:,:,:]
45 cor_bins = f.groups[group][
"cor_bins"][:,:,:,:]
48 for il0
in range(0, nl0):
49 for jl0r
in range(0, nl0r):
50 for jc3
in range(0, nc3):
51 if np.any(cor_hist[il0,jl0r,jc3,:] > 0.0):
53 fig, ax = plt.subplots(ncols=5)
54 fig.subplots_adjust(hspace=2.0)
58 ax[i].set_title(
"Covariance")
59 x = 0.5*(m11_bins[il0,jl0r,jc3,0:nbins]+m11_bins[il0,jl0r,jc3,1:nbins+1])
60 ax[i].plot(x, m11_hist[il0,jl0r,jc3,:],
'r-')
64 ax[i].set_title(
"Covariance squared")
65 x = 0.5*(m11m11_bins[il0,jl0r,jc3,0:nbins]+m11m11_bins[il0,jl0r,jc3,1:nbins+1])
66 ax[i].plot(x, m11m11_hist[il0,jl0r,jc3,:],
'r-')
70 ax[i].set_title(
"Variance product")
71 x = 0.5*(m2m2_bins[il0,jl0r,jc3,0:nbins]+m2m2_bins[il0,jl0r,jc3,1:nbins+1])
72 ax[i].plot(x, m2m2_hist[il0,jl0r,jc3,:],
'r-')
76 ax[i].set_title(
"Fourth-order moment")
77 x = 0.5*(m22_bins[il0,jl0r,jc3,0:nbins]+m22_bins[il0,jl0r,jc3,1:nbins+1])
78 ax[i].plot(x, m22_hist[il0,jl0r,jc3,:],
'r-')
82 ax[i].set_title(
"Correlation")
83 x = 0.5*(cor_bins[il0,jl0r,jc3,0:nbins]+cor_bins[il0,jl0r,jc3,1:nbins+1])
84 ax[i].plot(x, cor_hist[il0,jl0r,jc3,:],
'r-')
87 fig.suptitle(
"Between levels " +
'%.2e'%vunit[il0] +
" and " +
'%.2e'%vunit[l0rl0_to_l0[il0,jl0r]-1] +
" for distance class " +
'%.2e'%disth[jc3])
90 plt.savefig(testfig +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + group +
"_" + str(il0+1) +
"-" + str(l0rl0_to_l0[il0,jl0r]) +
"-" + str(jc3+1) +
".jpg", format=
"jpg", dpi=300)