Skip to content

Commit

Permalink
Merge pull request #109 from matt-frey/add-plot-parcel-number
Browse files Browse the repository at this point in the history
add plot_parcel_number plot
  • Loading branch information
matt-frey authored May 21, 2021
2 parents 78606b2 + df8ba16 commit a39ad8d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python-scripts/plot-diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
plot_rms_volume_error, \
plot_max_volume_error, \
plot_aspect_ratio, \
plot_parcel_volume
plot_parcel_volume, \
plot_parcel_number
import os
import sys

Expand All @@ -19,7 +20,8 @@
'rms-volume-error',
'max-volume-error',
'aspect-ratio',
'parcel-volume'
'parcel-volume',
'parcel-number'
]


Expand Down Expand Up @@ -66,6 +68,9 @@
elif args.kind == kinds[3]:
for fname in args.filenames:
plot_parcel_volume(fname, show=args.show, fmt=args.fmt)
elif args.kind == kinds[4]:
for fname in args.filenames:
plot_parcel_number(fname, show=args.show, fmt=args.fmt)
else:
raise ValuError("Plot '" + args.kind + "' not supported!")

Expand Down
32 changes: 32 additions & 0 deletions python-scripts/tools/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,38 @@ def plot_aspect_ratio(fname, show=False, fmt="png"):
plt.close()


def plot_parcel_number(fname, show=False, fmt="png"):
"""
Plot the number of parcels in simulation.
"""
h5reader = H5Reader()
h5reader.open(fname)

nsteps = h5reader.get_num_steps()

nparcels = np.zeros(nsteps)

for step in range(nsteps):
nparcels[step] = h5reader.get_num_parcels(step)

h5reader.close()

plt.figure()
plt.plot(nparcels, color='blue')
plt.grid(linestyle='dashed', zorder=-1)

plt.xlabel(r'number of iterations')
plt.ylabel(r'parcel count')
plt.tight_layout()

if show:
plt.show()
else:
prefix = os.path.splitext(fname)[0]
plt.savefig(prefix + '_parcel_number_profile.' + fmt, bbox_inches='tight')
plt.close()


def plot_parcel_volume(fname, show=False, fmt="png"):
"""
Plot the mean and standard deviation of the parcel volume
Expand Down

0 comments on commit a39ad8d

Please sign in to comment.