From 352aa3ffc78517d1bd0670b56d4b765e7ddd37ad Mon Sep 17 00:00:00 2001 From: Wes Bonelli Date: Tue, 15 Aug 2023 00:54:11 -0400 Subject: [PATCH] support prt pathlines for map view --- autotest/test_plot_pathlines.py | 167 ++++++++++++++++---------------- flopy/plot/map.py | 13 ++- 2 files changed, 95 insertions(+), 85 deletions(-) diff --git a/autotest/test_plot_pathlines.py b/autotest/test_plot_pathlines.py index b258c3495..62fc616d7 100644 --- a/autotest/test_plot_pathlines.py +++ b/autotest/test_plot_pathlines.py @@ -30,7 +30,7 @@ from flopy.plot import PlotCrossSection, PlotMapView from flopy.utils import CellBudgetFile, EndpointFile, HeadFile, PathlineFile -# %% plotting MP6 models +# MP6 @pytest.fixture @@ -194,7 +194,7 @@ def test_plot_map_view_mp6_endpoint(mp6_sim): assert isinstance(ep, PathCollection) -# %% plotting MP7 models +# MP7 simname = "test_plot" @@ -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" @@ -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 diff --git a/flopy/plot/map.py b/flopy/plot/map.py index aa7354be8..d0f7df132 100644 --- a/flopy/plot/map.py +++ b/flopy/plot/map.py @@ -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"]) @@ -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(