Skip to content

Commit

Permalink
fix(plotutil): number of plottable layers should be from util3d.shape…
Browse files Browse the repository at this point in the history
…[0] (#1077)
  • Loading branch information
mwtoews authored Mar 15, 2021
1 parent aca1446 commit 605366b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
22 changes: 18 additions & 4 deletions autotest/t007_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,8 @@ def test_get_lrc_get_node():

def test_vertex_model_dot_plot():
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams["figure.max_open_warning"] = 36
# load up the vertex example problem
sim_name = "mfsim.nam"
sim_path = "../examples/data/mf6/test003_gwftri_disv"
Expand All @@ -1431,16 +1433,28 @@ def test_vertex_model_dot_plot():
sim_ws=sim_path)
disv_ml = disv_sim.get_model('gwf_1')
ax = disv_ml.plot()
assert ax
assert isinstance(ax, list)
assert len(ax) == 36
plt.close('all')


def test_model_dot_plot():
import matplotlib.pyplot as plt
loadpth = os.path.join('..', 'examples', 'data', 'secp')
ml = flopy.modflow.Modflow.load('secp.nam', model_ws=loadpth)
loadpth = os.path.join('..', 'examples', 'data', 'mf2005_test')
ml = flopy.modflow.Modflow.load('ibs2k.nam', 'mf2k', model_ws=loadpth)
ax = ml.plot()
assert ax
assert isinstance(ax, list)
assert len(ax) == 20
plt.close('all')

# plot specific dataset
ax = ml.bcf6.hy.plot()
assert isinstance(ax, list)
assert len(ax) == 2

# special case where nlay != plottable
ax = ml.bcf6.vcont.plot()
assert isinstance(ax, plt.Axes)
plt.close('all')


Expand Down
8 changes: 5 additions & 3 deletions flopy/plot/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,12 @@ def _plot_util3d_helper(
else:
fext = "png"

# flopy6 adaption
model = util3d.model
modelgrid = model.modelgrid
nplottable_layers = modelgrid.nlay
if isinstance(util3d, Util3d):
nplottable_layers = util3d.shape[0]
else:
# flopy6 adaption
nplottable_layers = model.modelgrid.nlay
array = util3d.array
name = util3d.name
if isinstance(name, str):
Expand Down

0 comments on commit 605366b

Please sign in to comment.