4 from netCDF4
import Dataset
6 import matplotlib.cm
as cm
7 import matplotlib.pyplot
as plt
8 import matplotlib.tri
as tri
22 for impi
in range(0, int(mpi)):
24 f = Dataset(testdata +
"/" + test +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + mpi.zfill(6) +
"-" + format(impi+1,
'06d') +
".nc",
"r", format=
"NETCDF4")
27 _FillValue = f.__dict__[
"_FillValue"]
29 for group
in f.groups:
32 sc3 = (
"lon" in f.groups[group].variables)
33 local = (group ==
"hdiag")
34 vbal = (group ==
"vbal")
37 nc0a = f[
"lon_c0a"].shape[0]
39 nc1a = f.groups[group][
"lon"].shape[2]
41 nc2a = f.groups[group][
"lon_local"].shape[1]
43 nc2b = f.groups[group][
"lon_vbal"].shape[1]
45 nl0 = f[
"gmask_c0a"].shape[0]
46 lon_c0 = np.zeros((0))
47 lat_c0 = np.zeros((0))
48 gmask_c0 = np.zeros((0,nl0))
50 nc3 = f.groups[group][
"lon"].shape[1]
51 lon = np.zeros((0, nl0, nc3))
52 lat = np.zeros((0, nl0, nc3))
54 nc1max = f.groups[group][
"lon_local"].shape[2]
55 lon_local = np.zeros((0, nl0, nc1max))
56 lat_local = np.zeros((0, nl0, nc1max))
58 nc1max = f.groups[group][
"lon_vbal"].shape[2]
59 lon_vbal = np.zeros((0, nl0, nc1max))
60 lat_vbal = np.zeros((0, nl0, nc1max))
62 for ic0a
in range(0, nc0a):
63 lon_c0 = np.append(lon_c0, f[
"lon_c0a"][ic0a].data)
64 lat_c0 = np.append(lat_c0, f[
"lat_c0a"][ic0a].data)
65 gmask_c0 = np.append(gmask_c0, [f[
"gmask_c0a"][:,ic0a].data], axis=0)
67 for ic1a
in range(0, nc1a):
68 lon = np.append(lon, [f.groups[group][
"lon"][:,:,ic1a].data], axis=0)
69 lat = np.append(lat, [f.groups[group][
"lat"][:,:,ic1a].data], axis=0)
71 for ic2a
in range(0, nc2a):
72 lon_local = np.append(lon_local, [f.groups[group][
"lon_local"][:,ic2a,:].data], axis=0)
73 lat_local = np.append(lat_local, [f.groups[group][
"lat_local"][:,ic2a,:].data], axis=0)
75 for ic2b
in range(0, nc2b):
76 lon_vbal = np.append(lon_vbal, [f.groups[group][
"lon_vbal"][:,ic2b,:].data], axis=0)
77 lat_vbal = np.append(lat_vbal, [f.groups[group][
"lat_vbal"][:,ic2b,:].data], axis=0)
81 lon = ma.masked_where(lon==_FillValue, lon,
False)
82 lat = ma.masked_where(lat==_FillValue, lat,
False)
84 lon_local = ma.masked_where(lon_local==_FillValue, lon_local,
False)
85 lat_local = ma.masked_where(lat_local==_FillValue, lat_local,
False)
87 lon_vbal = ma.masked_where(lon_vbal==_FillValue, lon_vbal,
False)
88 lat_vbal = ma.masked_where(lat_vbal==_FillValue, lat_vbal,
False)
95 nc2 = lon_local.shape[0]
97 nc2btot = lon_vbal.shape[0]
100 for ic0
in range(0, nc0):
101 gmask_c0[ic0,:] = gmask_c0[ic0,:]*(ic0%2+1)
102 gmask_c0 = ma.masked_where(gmask_c0<0.5, gmask_c0,
False)
105 levs = f.__dict__[
"nam_levs"].split(
":")
108 gmask_c0 = ma.masked_invalid(gmask_c0)
109 vmax = np.max(gmask_c0)
110 gmask_c0 = gmask_c0.filled(fill_value=-1.0e38)
111 levels = [-1.0, 0.0, 1.0, 2.0]
116 fig, ax = plt.subplots(nrows=nl0)
117 fig.subplots_adjust(hspace=0.4)
118 for il0
in range(0, nl0):
119 ax[il0].set_title(
"@ " + str(il0))
120 ax[il0].tricontourf(lon_c0, lat_c0, gmask_c0[:,il0], levels=levels, cmap=
"gray")
121 for ic1
in range(0, nc1):
122 if (
not lon.mask[ic1,il0,ic3])
and (
not lat.mask[ic1,il0,ic3]):
123 if (np.abs(lon[ic1,il0,0]-lon[ic1,il0,ic3]) < 180.0):
124 ax[il0].plot([lon[ic1,il0,0], lon[ic1,il0,ic3]], [lat[ic1,il0,0], lat[ic1,il0,ic3]],
"k-")
125 ax[il0].plot([lon[ic1,il0,0], lon[ic1,il0,ic3]], [lat[ic1,il0,0], lat[ic1,il0,ic3]], marker=
"o", color=
"black", ms=0.2)
128 plt.savefig(testfig +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + group +
"_c3_" + str(ic3) +
".jpg", format=
"jpg", dpi=300)
131 if sc3
and (local
or vbal):
135 fig, ax = plt.subplots(nrows=nl0)
136 fig.subplots_adjust(hspace=0.4)
137 for il0
in range(0, nl0):
138 ax[il0].set_title(
"@ " + str(il0))
139 ax[il0].tricontourf(lon_c0, lat_c0, gmask_c0[:,il0], levels=levels, cmap=
"gray")
140 for ic1
in range(0, nc1):
141 if (
not lon.mask[ic1,il0,0])
and (
not lat.mask[ic1,il0,0]):
142 ax[il0].plot(lon[ic1,il0,0], lat[ic1,il0,0], marker=
"o", color=
"black", ms=0.2)
145 for ic2
in range(0, nc2):
146 if (
not lon_local.mask[ic2,il0,0])
and (
not lat_local.mask[ic2,il0,0]):
147 ax[il0].plot(lon_local[ic2,il0,0], lat_local[ic2,il0,0], marker=
"o", color=
"red", ms=0.2)
149 for ic2
in range(0, nc2btot):
150 if (
not lon_vbal.mask[ic2,il0,0])
and (
not lat_vbal.mask[ic2,il0,0]):
151 ax[il0].plot(lon_vbal[ic2,il0,0], lat_vbal[ic2,il0,0], marker=
"o", color=
"red", ms=0.2)
154 plt.savefig(testfig +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + group +
"_c2_in_c1.jpg", format=
"jpg", dpi=300)
161 fig, ax = plt.subplots(nrows=nl0)
162 fig.subplots_adjust(hspace=0.4)
163 for il0
in range(0, nl0):
164 ax[il0].set_title(
"@ " + str(il0))
165 ax[il0].tricontourf(lon_c0, lat_c0, gmask_c0[:,il0], levels=levels, cmap=
"gray")
166 for ic1
in range(0, nc1max):
167 if (
not lon_local.mask[ic2,il0,ic1])
and (
not lat_local.mask[ic2,il0,ic1]):
168 if (np.abs(lon_local[ic2,il0,0]-lon_local[ic2,il0,ic1]) < 180.0):
169 ax[il0].plot([lon_local[ic2,il0,0], lon_local[ic2,il0,ic1]], [lat_local[ic2,il0,0], lat_local[ic2,il0,ic1]],
"k-")
170 ax[il0].plot([lon_local[ic2,il0,0], lon_local[ic2,il0,ic1]], [lat_local[ic2,il0,0], lat_local[ic2,il0,ic1]], marker=
"o", color=
"black", ms=0.2)
173 plt.savefig(testfig +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + group +
"_c2_" + str(ic2) +
".jpg", format=
"jpg", dpi=300)
180 fig, ax = plt.subplots(nrows=nl0)
181 fig.subplots_adjust(hspace=0.4)
182 for il0
in range(0, nl0):
183 ax[il0].set_title(
"@ " + str(il0))
184 ax[il0].tricontourf(lon_c0, lat_c0, gmask_c0[:,il0], levels=levels, cmap=
"gray")
185 for ic1
in range(0, nc1max):
186 if (
not lon_vbal.mask[ic2,il0,ic1])
and (
not lat_vbal.mask[ic2,il0,ic1]):
187 if (np.abs(lon_vbal[ic2,il0,0]-lon_vbal[ic2,il0,ic1]) < 180.0):
188 ax[il0].plot([lon_vbal[ic2,il0,0], lon_vbal[ic2,il0,ic1]], [lat_vbal[ic2,il0,0], lat_vbal[ic2,il0,ic1]],
"k-")
189 ax[il0].plot([lon_vbal[ic2,il0,0], lon_vbal[ic2,il0,ic1]], [lat_vbal[ic2,il0,0], lat_vbal[ic2,il0,ic1]], marker=
"o", color=
"black", ms=0.2)
192 plt.savefig(testfig +
"/test_" + mpi +
"-" + omp +
"_" + suffix +
"_" + group +
"_c2_" + str(ic2) +
".jpg", format=
"jpg", dpi=300)