Skip to content

Commit

Permalink
fix(plot_pathline): split recarray into particle list when it contain…
Browse files Browse the repository at this point in the history
…s multiple particle ids (#1400)

* fix(plot_pathline): split recarray into particle list when it contains multiple particle ids

* update MfListBudget docstrings

* remove todo statements
  • Loading branch information
jlarsen-usgs committed Apr 30, 2022
1 parent cb8c219 commit 85d4558
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
30 changes: 29 additions & 1 deletion autotest/t057_test_mp7.py
@@ -1,6 +1,7 @@
import os

import numpy as np
import matplotlib.pyplot as plt
from ci_framework import FlopyTestSetup, base_test_dir

import flopy
Expand Down Expand Up @@ -365,9 +366,36 @@ def build_mf6(model_ws):
success, buff = mp.run_model()
assert success, f"mp7 model ({mp.name}) did not run"

return
return gwf


def test_pathline_plotting():
model_ws = f"{base_dir}_test_pathline_output"
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

gwf = build_mf6(model_ws)

modelgrid = gwf.modelgrid
nodes = list(range(modelgrid.nnodes))

if run:
fpth1 = os.path.join(model_ws, "mf6", "ex01_mf6_mp.mppth")
p = flopy.utils.PathlineFile(fpth1)
p1 = p.get_alldata()
pls = p.get_destination_data(nodes)

pmv = flopy.plot.PlotMapView(modelgrid=modelgrid, layer=0)
pmv.plot_grid()
linecol = pmv.plot_pathline(pls, layer="all")
linecol2 = pmv.plot_pathline(p1, layer="all")
if not len(linecol._paths) == len(linecol2._paths):
raise AssertionError(
"plot_pathline not properly splitting particles from recarray"
)
plt.close()


if __name__ == "__main__":
test_pathline_output()
test_endpoint_output()
test_pathline_plotting()
6 changes: 5 additions & 1 deletion flopy/plot/map.py
Expand Up @@ -735,7 +735,11 @@ def plot_pathline(self, pl, travel_time=None, **kwargs):

# make sure pathlines is a list
if not isinstance(pl, list):
pl = [pl]
pids = np.unique(pl["particleid"])
if len(pids) > 1:
pl = [pl[pl["particleid"] == pid] for pid in pids]
else:
pl = [pl]

if "layer" in kwargs:
kon = kwargs.pop("layer")
Expand Down
2 changes: 1 addition & 1 deletion flopy/utils/mflistfile.py
Expand Up @@ -39,7 +39,7 @@ class ListBudget:
--------
>>> mf_list = MfListBudget("my_model.list")
>>> incremental, cumulative = mf_list.get_budget()
>>> df_in, df_out = mf_list.get_dataframes(start_datetime="10-21-2015")
>>> df_inc, df_cumul = mf_list.get_dataframes(start_datetime="10-21-2015")
"""

Expand Down

0 comments on commit 85d4558

Please sign in to comment.