Skip to content

Commit

Permalink
updates(zonbud, output_util, mfwel, OptionBlock): updates and bug fix…
Browse files Browse the repository at this point in the history
…es (#1209)

* autotest updates for deprecations and updates

* updates(zonbud, output_util, mfwel, OptionBlock): updates

* remove deprecated code from zonbud.py
* remove deprecated code form mfwel.py
* fix MF6Output.list(), update to use Mf6ListBudget
* fix Package.load() for mfnwt_options, well options not passed to well file when option block detected

* Remove references to deprecated code from notebooks
  • Loading branch information
jlarsen-usgs authored Aug 21, 2021
1 parent f0972e1 commit 86206ff
Show file tree
Hide file tree
Showing 10 changed files with 733 additions and 1,960 deletions.
102 changes: 0 additions & 102 deletions autotest/t039_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,107 +257,6 @@ def test_get_model_shape():
return


def test_zonebudget_output_to_netcdf():
from flopy.utils import HeadFile, ZoneBudgetOutput
from flopy.modflow import Modflow
from flopy.mf6 import MFSimulation
from flopy.export.utils import output_helper

model_ws = os.path.join(
"..", "examples", "data", "freyberg_multilayer_transient"
)
zb_ws = os.path.join("..", "examples", "data", "zonbud_examples")

hds = "freyberg.hds"
nam = "freyberg.nam"
zon = "zonef_mlt.zbr"

hds = HeadFile(os.path.join(model_ws, hds))
ml = Modflow.load(nam, model_ws=model_ws)
zone_array = ZoneBudget.read_zone_file(os.path.join(zb_ws, zon))

# test with standard zonebudget output
zbout = "freyberg_mlt.txt"
ncf_name = zbout + ".nc"

zb = ZoneBudgetOutput(os.path.join(zb_ws, zbout), ml.dis, zone_array)
vdf = zb.volumetric_flux()

netobj = zb.dataframe_to_netcdf_fmt(vdf, flux=False)

export_dict = {"hds": hds, "zonebud": netobj}

output_helper(os.path.join(outpth, ncf_name), ml, export_dict)

# test with zonebudget csv 1 output
zbout = "freyberg_mlt.1.csv"
ncf_name = zbout + ".nc"

zb = ZoneBudgetOutput(os.path.join(zb_ws, zbout), ml.dis, zone_array)

netobj = zb.dataframe_to_netcdf_fmt(zb.dataframe)

export_dict = {"hds": hds, "zonebud": netobj}

output_helper(os.path.join(outpth, ncf_name), ml, export_dict)

# test with zonebudget csv 2 output
zbout = "freyberg_mlt.2.csv"
ncf_name = zbout + ".nc"

zb = ZoneBudgetOutput(os.path.join(zb_ws, zbout), ml.dis, zone_array)
vdf = zb.volumetric_flux(extrapolate_kper=True)

netobj = zb.dataframe_to_netcdf_fmt(vdf, flux=False)

export_dict = {"hds": hds, "zonebud": netobj}

output_helper(os.path.join(outpth, ncf_name), ml, export_dict)

# test built in export function
zbout = "freyberg_mlt.2.csv"
ncf_name = zbout + ".bi1.nc"

zb = ZoneBudgetOutput(os.path.join(zb_ws, zbout), ml.dis, zone_array)
zb.export(os.path.join(outpth, ncf_name), ml)

# test built in export function with NetCdf output object
zbout = "freyberg_mlt.2.csv"
ncf_name = zbout + ".bi2.nc"

zb = ZoneBudgetOutput(os.path.join(zb_ws, zbout), ml.dis, zone_array)
export_dict = {"hds": hds}
ncfobj = output_helper(os.path.join(outpth, ncf_name), ml, export_dict)
zb.export(ncfobj, ml)

# test with modflow6/zonebudget6
sim_ws = os.path.join(
"..", "examples", "data", "mf6", "test005_advgw_tidal"
)
hds = "advgw_tidal.hds"
nam = "mfsim"
zon = "zonebudget6.csv"
ncf_name = zon + ".nc"

zone_array = np.ones((3, 15, 10), dtype=int)
zone_array = np.add.accumulate(zone_array, axis=0)
sim = MFSimulation.load(nam, sim_ws=sim_ws, exe_name="mf6")
sim.set_sim_path(outpth)
sim.write_simulation()
sim.run_simulation()
hds = HeadFile(os.path.join(outpth, hds))

ml = sim.get_model("gwf_1")

zb = ZoneBudgetOutput(os.path.join(zb_ws, zon), sim.tdis, zone_array)
vdf = zb.volumetric_flux()

netobj = zb.dataframe_to_netcdf_fmt(vdf, flux=False)
export_dict = {"hds": hds, "zbud": netobj}

output_helper(os.path.join(outpth, ncf_name), ml, export_dict)


def test_zonbud_active_areas_zone_zero(rtol=1e-2):
try:
import pandas as pd
Expand Down Expand Up @@ -472,6 +371,5 @@ def test_zonebudget_6():
test_dataframes()
test_get_budget()
test_get_model_shape()
test_zonebudget_output_to_netcdf()
test_zonbud_active_areas_zone_zero()
test_zonebudget_6()
2 changes: 1 addition & 1 deletion autotest/t054_test_mfnwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def mfnwt_model(namfile, model_ws):
wel = m.get_package("WEL")
wel.specify = True
wel.phiramp = 1.0e-5
wel.phiramp_unit = 2
wel.iunitramp = 2

# change workspace and write MODFLOW-NWT model
tdir = os.path.splitext(namfile)[0]
Expand Down
4 changes: 2 additions & 2 deletions autotest/t504_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ def test_mf6_output():
if not isinstance(zonbud, flopy.utils.ZoneBudget6):
raise AssertionError()

if not isinstance(lst, flopy.utils.MfListBudget):
if not isinstance(lst, flopy.utils.Mf6ListBudget):
raise AssertionError()

bud = ml.output.budget()
Expand All @@ -1202,7 +1202,7 @@ def test_mf6_output():
if not isinstance(zonbud, flopy.utils.ZoneBudget6):
raise TypeError()

if not isinstance(lst, flopy.utils.MfListBudget):
if not isinstance(lst, flopy.utils.Mf6ListBudget):
raise TypeError()

uzf = ml.uzf
Expand Down
57 changes: 21 additions & 36 deletions examples/Notebooks/flopy3_ZoneBudget_example.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 86206ff

Please sign in to comment.