Skip to content

Commit

Permalink
support prt pathlines for map view
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Aug 15, 2023
1 parent 1f9ee55 commit 352aa3f
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 85 deletions.
167 changes: 84 additions & 83 deletions autotest/test_plot_pathlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from flopy.plot import PlotCrossSection, PlotMapView
from flopy.utils import CellBudgetFile, EndpointFile, HeadFile, PathlineFile

# %% plotting MP6 models
# MP6


@pytest.fixture
Expand Down Expand Up @@ -194,7 +194,7 @@ def test_plot_map_view_mp6_endpoint(mp6_sim):
assert isinstance(ep, PathCollection)


# %% plotting MP7 models
# MP7


simname = "test_plot"
Expand All @@ -210,6 +210,7 @@ def test_plot_map_view_mp6_endpoint(mp6_sim):
porosity = 0.1


@pytest.fixture
def mf6_gwf_sim(module_tmpdir):
gwfname = f"{simname}_gwf"

Expand Down Expand Up @@ -282,95 +283,95 @@ def mf6_gwf_sim(module_tmpdir):


@pytest.fixture
def mp7_model(function_tmpdir, gwf_model):
def mp7_sim(function_tmpdir, mf6_gwf_sim):
pass


@requires_exe("mf6", "mp7")
def test_plot_map_view_mp7_pathline(mp7_model):
def test_plot_map_view_mp7_pathline(mp7_sim):
pass


@requires_exe("mf6", "mp7")
def test_plot_cross_section_mp7_pathline(mp7_model):
pass


# %% plotting PRT models


@pytest.fixture
def mf6_prt_sim(function_tmpdir, mf6_gwf_sim):
prtname = f"{simname}_prt"

# create prt model
prt = flopy.mf6.ModflowPrt(mf6_gwf_sim, modelname=prtname)

# create prt discretization
flopy.mf6.modflow.mfgwfdis.ModflowGwfdis(
prt,
pname="dis",
nlay=nlay,
nrow=nrow,
ncol=ncol,
)

# create mip package
flopy.mf6.ModflowPrtmip(prt, pname="mip", porosity=porosity)

# create prp package
flopy.mf6.ModflowPrtprp(
prt,
pname="prp1",
filename=f"{prtname}_1.prp",
nreleasepts=len(releasepts),
packagedata=releasepts,
perioddata={0: ["FIRST"]},
)

# create output control package
flopy.mf6.ModflowPrtoc(
prt,
pname="oc",
track_filerecord=[prt_track_file],
trackcsv_filerecord=[prt_track_csv_file],
)

# create a flow model interface
# todo Fienen's report (crash when FMI created but not needed)
# flopy.mf6.ModflowPrtfmi(
# prt,
# packagedata=[
# ("GWFHEAD", gwf_head_file),
# ("GWFBUDGET", gwf_budget_file),
# ],
# )

# create exchange
flopy.mf6.ModflowGwfprt(
sim,
exgtype="GWF6-PRT6",
exgmnamea=gwfname,
exgmnameb=prtname,
filename=f"{gwfname}.gwfprt",
)

# add explicit model solution
ems = flopy.mf6.ModflowEms(
sim,
pname="ems",
filename=f"{prtname}.ems",
)
sim.register_solution_package(ems, [prt.name])

return sim


@requires_exe("mf6")
def test_plot_map_view_prt_pathline(prt_model):
def test_plot_cross_section_mp7_pathline(mp7_sim):
pass


@requires_exe("mf6")
def test_plot_cross_section_prt_pathline(prt_model):
pass
# MF6 PRT


# @pytest.fixture
# def mf6_prt_sim(function_tmpdir, mf6_gwf_sim):
# prtname = f"{simname}_prt"
#
# # create prt model
# prt = flopy.mf6.ModflowPrt(mf6_gwf_sim, modelname=prtname)
#
# # create prt discretization
# flopy.mf6.modflow.mfgwfdis.ModflowGwfdis(
# prt,
# pname="dis",
# nlay=nlay,
# nrow=nrow,
# ncol=ncol,
# )
#
# # create mip package
# flopy.mf6.ModflowPrtmip(prt, pname="mip", porosity=porosity)
#
# # create prp package
# flopy.mf6.ModflowPrtprp(
# prt,
# pname="prp1",
# filename=f"{prtname}_1.prp",
# nreleasepts=len(releasepts),
# packagedata=releasepts,
# perioddata={0: ["FIRST"]},
# )
#
# # create output control package
# flopy.mf6.ModflowPrtoc(
# prt,
# pname="oc",
# track_filerecord=[prt_track_file],
# trackcsv_filerecord=[prt_track_csv_file],
# )
#
# # create a flow model interface
# # todo Fienen's report (crash when FMI created but not needed)
# # flopy.mf6.ModflowPrtfmi(
# # prt,
# # packagedata=[
# # ("GWFHEAD", gwf_head_file),
# # ("GWFBUDGET", gwf_budget_file),
# # ],
# # )
#
# # create exchange
# flopy.mf6.ModflowGwfprt(
# sim,
# exgtype="GWF6-PRT6",
# exgmnamea=gwfname,
# exgmnameb=prtname,
# filename=f"{gwfname}.gwfprt",
# )
#
# # add explicit model solution
# ems = flopy.mf6.ModflowEms(
# sim,
# pname="ems",
# filename=f"{prtname}.ems",
# )
# sim.register_solution_package(ems, [prt.name])
#
# return sim
#
#
# @requires_exe("mf6")
# def test_plot_map_view_prt_pathline(mf6_prt_sim):
# pass
#
#
# @requires_exe("mf6")
# def test_plot_cross_section_prt_pathline(mf6_prt_sim):
# pass
13 changes: 11 additions & 2 deletions flopy/plot/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,12 @@ def plot_pathline(self, pl, travel_time=None, **kwargs):
from matplotlib.collections import LineCollection

# todo check provided data format
# todo convert prt to mp7 format

# convert prt to mp7 format
if "t" in pl.dtype.names:
from .plotutil import to_mp7_pathlines
pl = to_mp7_pathlines(pl)

# make sure pathlines is a list
if not isinstance(pl, list):
pids = np.unique(pl["particleid"])
Expand Down Expand Up @@ -916,7 +921,11 @@ def plot_endpoint(
"""

# todo check provided data format
# todo convert prt to mp7 format

# convert prt to mp7 format if needed
if "t" in ep.dtype.names:
from .plotutil import to_mp7_endpoints
ep = to_mp7_endpoints(ep)

ax = kwargs.pop("ax", self.ax)
tep, _, xp, yp = plotutil.parse_modpath_selection_options(
Expand Down

0 comments on commit 352aa3f

Please sign in to comment.