Skip to content

Commit

Permalink
add plot_bc tests to t506_test.py for unstructured mf6 and mfusg models
Browse files Browse the repository at this point in the history
  • Loading branch information
cnicol-gwlogic committed Aug 15, 2021
1 parent 548610c commit 991356d
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions autotest/t506_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
try:
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.collections import QuadMesh, PathCollection, LineCollection
except:
print("Matplotlib not installed, tests cannot be run.")
matplotlib = None
Expand Down Expand Up @@ -304,6 +305,36 @@ def test_mf6disu():
plt.savefig(fname)
plt.close("all")

# check plot_bc works for unstructured mf6 grids
# (for each layer, and then for all layers in one plot)
plot_ranges = [range(gwf.modelgrid.nlay), range(1)]
plot_alls = [False, True]
for plot_range, plot_all in zip(plot_ranges, plot_alls):
f_bc = plt.figure(figsize=(10, 10))
for ilay in plot_range:
ax = plt.subplot(1, plot_range[-1] + 1, ilay + 1)
pmv = flopy.plot.PlotMapView(gwf, layer=ilay, ax=ax)
ax.set_aspect("equal")

pmv.plot_bc(
"CHD", plotAll=plot_all, edgecolor="None", zorder=2
)
pmv.plot_grid(
colors="k", linewidth=0.3, alpha=0.1, zorder=1
)

if len(ax.collections) == 0:
raise AssertionError(
"Boundary condition was not drawn"
)

for col in ax.collections:
if not isinstance(
col, (QuadMesh, PathCollection, LineCollection)
):
raise AssertionError("Unexpected collection type")
plt.close()

return


Expand Down Expand Up @@ -399,6 +430,36 @@ def test_mfusg():
plt.savefig(fname)
plt.close("all")

# check plot_bc works for unstructured mfusg grids
# (for each layer, and then for all layers in one plot)
plot_ranges = [range(disu.nlay), range(1)]
plot_alls = [False, True]
for plot_range, plot_all in zip(plot_ranges, plot_alls):
f_bc = plt.figure(figsize=(10, 10))
for ilay in plot_range:
ax = plt.subplot(1, plot_range[-1] + 1, ilay + 1)
pmv = flopy.plot.PlotMapView(m, layer=ilay, ax=ax)
ax.set_aspect("equal")

pmv.plot_bc(
"CHD", plotAll=plot_all, edgecolor="None", zorder=2
)
pmv.plot_grid(
colors="k", linewidth=0.3, alpha=0.1, zorder=1
)

if len(ax.collections) == 0:
raise AssertionError(
"Boundary condition was not drawn"
)

for col in ax.collections:
if not isinstance(
col, (QuadMesh, PathCollection, LineCollection)
):
raise AssertionError("Unexpected collection type")
plt.close()

# re-run with an LPF keyword specified. This would have thrown an error
# before the addition of ikcflag to mflpf.py (flopy 3.3.3 and earlier).
lpf = flopy.modflow.ModflowLpf(m, novfc=True, nocvcorrection=True)
Expand Down

0 comments on commit 991356d

Please sign in to comment.