Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates(zonbud, output_util, mfwel, OptionBlock): updates and bug fixes #1209

Merged
merged 3 commits into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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