Skip to content

Commit

Permalink
refactor(pakbase): standardize ipakcb docstrings/defaults (#2001)
Browse files Browse the repository at this point in the history
* make ipakcb docstrings consistent for all modflow (non-mf6) packages
* make default ipakcb consistent (None for ipakcb=0 and no output file)
* add default_cbc_unit method to Package, support ipakcb=default for 53
  • Loading branch information
wpbonelli authored Nov 22, 2023
1 parent 0ffe85c commit 09b59ce
Show file tree
Hide file tree
Showing 27 changed files with 154 additions and 326 deletions.
6 changes: 3 additions & 3 deletions .docs/Notebooks/modpath7_structured_transient_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def no_flow(w):
[drain[0], drain[1], i + drain[2][0], 322.5, 100000.0, 6]
for i in range(drain[2][1] - drain[2][0])
]
drn = flopy.mf6.modflow.mfgwfdrn.ModflowGwfdrn(gwf, auxiliary=["IFACE"], stress_period_data={0: dd})
drn = flopy.mf6.modflow.mfgwfdrn.ModflowGwfdrn(
gwf, auxiliary=["IFACE"], stress_period_data={0: dd}
)

# output control
headfile = f"{sim_name}.hds"
Expand Down Expand Up @@ -410,5 +412,3 @@ def add_legend(ax):
temp_dir.cleanup()
except:
pass


1 change: 0 additions & 1 deletion autotest/regression/test_mf6_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
)
from flopy.mf6.data.mfdataplist import MFPandasList


pytestmark = pytest.mark.mf6


Expand Down
1 change: 0 additions & 1 deletion autotest/test_mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from flopy.mbase import resolve_exe
from flopy.utils.flopy_io import relpath_safe


_system = system()


Expand Down
11 changes: 5 additions & 6 deletions flopy/mfusg/mfusgbcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ class MfUsgBcf(ModflowBcf):
model : model object
The model object (of type :class:`flopy.modflow.Modflow`) to which
this package will be added.
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is 53)
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
intercellt : int
Intercell transmissivities, harmonic mean (0), arithmetic mean (1),
logarithmic mean (2), combination (3). (default is 0)
Expand Down Expand Up @@ -96,9 +95,9 @@ class MfUsgBcf(ModflowBcf):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output name will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down
11 changes: 5 additions & 6 deletions flopy/mfusg/mfusglpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ class MfUsgLpf(ModflowLpf):
model : model object
The model object (of type :class:`flopy.modflowusg.mfusg.MfUsg`) to which
this package will be added.
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is 0)
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
hdry : float
Is the head that is assigned to cells that are converted to dry during
a simulation. Although this value plays no role in the model
Expand Down Expand Up @@ -169,9 +168,9 @@ class MfUsgLpf(ModflowLpf):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output name will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down
17 changes: 5 additions & 12 deletions flopy/mfusg/mfusgwel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
MODFLOW Guide
<https://water.usgs.gov/ogw/modflow/MODFLOW-2005-Guide/wel.html>`_.
"""
from copy import deepcopy

import numpy as np
from numpy.lib.recfunctions import stack_arrays

from ..modflow.mfparbc import ModflowParBc as mfparbc
from ..modflow.mfwel import ModflowWel
from ..utils import MfList
from ..utils.flopy_io import ulstrd
from ..utils.utils_def import get_open_file_object
from .mfusg import MfUsg


Expand All @@ -29,10 +23,9 @@ class MfUsgWel(ModflowWel):
model : model object
The model object (of type :class:`flopy.modflow.mf.Modflow`) to which
this package will be added.
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is 0).
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
stress_period_data : list of boundaries, or recarray of boundaries, or
dictionary of boundaries
For structured grid, each well is defined through definition of
Expand Down Expand Up @@ -127,9 +120,9 @@ class MfUsgWel(ModflowWel):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output names will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down
21 changes: 7 additions & 14 deletions flopy/modflow/mfbcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ class ModflowBcf(Package):
model : model object
The model object (of type :class:`flopy.modflow.Modflow`) to which
this package will be added.
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is 53)
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
intercellt : int
Intercell transmissivities, harmonic mean (0), arithmetic mean (1),
logarithmic mean (2), combination (3). (default is 0)
Expand Down Expand Up @@ -64,9 +63,9 @@ class ModflowBcf(Package):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output name will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down Expand Up @@ -121,13 +120,8 @@ def __init__(
# set filenames
filenames = self._prepare_filenames(filenames, 2)

# update external file information with cbc output, if necessary
if ipakcb is not None:
model.add_output_file(
ipakcb, fname=filenames[1], package=self._ftype()
)
else:
ipakcb = 0
# cbc output file
self.set_cbc_output_file(ipakcb, model, filenames[1])

# call base package constructor
super().__init__(
Expand Down Expand Up @@ -168,7 +162,6 @@ def __init__(
)

# item 1
self.ipakcb = ipakcb
self.hdry = hdry
self.iwdflg = iwdflg
self.wetfct = wetfct
Expand Down
22 changes: 7 additions & 15 deletions flopy/modflow/mfdrn.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ class ModflowDrn(Package):
model : model object
The model object (of type :class:`flopy.modflow.mf.Modflow`) to which
this package will be added.
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is None).
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
stress_period_data : list, recarray, dataframe or dictionary of boundaries.
Each drain cell is defined through definition of
layer(int), row(int), column(int), elevation(float),
Expand Down Expand Up @@ -73,9 +72,9 @@ class ModflowDrn(Package):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output names will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down Expand Up @@ -125,13 +124,8 @@ def __init__(
# set filenames
filenames = self._prepare_filenames(filenames, 2)

# update external file information with cbc output, if necessary
if ipakcb is not None:
model.add_output_file(
ipakcb, fname=filenames[1], package=self._ftype()
)
else:
ipakcb = 0
# cbc output file
self.set_cbc_output_file(ipakcb, model, filenames[1])

if options is None:
options = []
Expand All @@ -157,8 +151,6 @@ def __init__(
self._generate_heading()
self.url = "drn.html"

self.ipakcb = ipakcb

self.np = 0

self.options = options
Expand Down
23 changes: 7 additions & 16 deletions flopy/modflow/mfdrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ class ModflowDrt(Package):
model : model object
The model object (of type :class:`flopy.modflow.mf.Modflow`) to which
this package will be added.
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is None).
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
stress_period_data : list, recarray, dataframe or dictionary of boundaries.
Each drain return cell is defined through definition of
layer(int), row(int), column(int), elevation(float),
Expand Down Expand Up @@ -73,9 +72,9 @@ class ModflowDrt(Package):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output names will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down Expand Up @@ -123,13 +122,8 @@ def __init__(
# set filenames
filenames = self._prepare_filenames(filenames, 2)

# update external file information with cbc output, if necessary
if ipakcb is not None:
model.add_output_file(
ipakcb, fname=filenames[1], package=self._ftype()
)
else:
ipakcb = 0
# cbc output file
self.set_cbc_output_file(ipakcb, model, filenames[1])

if options is None:
options = []
Expand All @@ -152,9 +146,6 @@ def __init__(

self._generate_heading()
self.url = "drt.html"

self.ipakcb = ipakcb

self.np = 0

self.options = options
Expand Down
10 changes: 2 additions & 8 deletions flopy/modflow/mfevt.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,8 @@ def __init__(
# set filenames
filenames = self._prepare_filenames(filenames, 2)

# update external file information with cbc output, if necessary
if ipakcb is not None:
model.add_output_file(
ipakcb, fname=filenames[1], package=self._ftype()
)
else:
ipakcb = 0
# cbc output file
self.set_cbc_output_file(ipakcb, model, filenames[1])

# call base package constructor
super().__init__(
Expand All @@ -125,7 +120,6 @@ def __init__(
self._generate_heading()
self.url = "evt.html"
self.nevtop = nevtop
self.ipakcb = ipakcb
self.external = external
if self.external is False:
load = True
Expand Down
21 changes: 7 additions & 14 deletions flopy/modflow/mffhb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ class ModflowFhb(Package):
If the simulation includes only steady-state stress periods, the flag
controls how flow, head, and auxiliary-variable values will be
computed for each steady-state solution. (default is 0)
ipakcb : int
A flag that is used to determine if cell-by-cell budget data should be
saved. If ipakcb is non-zero cell-by-cell budget data will be saved.
(default is None).
ipakcb : int, optional
Toggles whether cell-by-cell budget data should be saved. If None or zero,
budget data will not be saved (default is None).
nfhbx1 : int
Number of auxiliary variables whose values will be computed for each
time step for each specified-flow cell. Auxiliary variables are
Expand Down Expand Up @@ -106,9 +105,9 @@ class ModflowFhb(Package):
filenames=None the package name will be created using the model name
and package extension and the cbc output name will be created using
the model name and .cbc extension (for example, modflowtest.cbc),
if ipakcbc is a number greater than zero. If a single string is passed
if ipakcb is a number greater than zero. If a single string is passed
the package will be set to the string and cbc output names will be
created using the model name and .cbc extension, if ipakcbc is a
created using the model name and .cbc extension, if ipakcb is a
number greater than zero. To define the names for all package files
(input and output) the length of the list of strings should be 2.
Default is None.
Expand Down Expand Up @@ -163,13 +162,8 @@ def __init__(
# set filenames
filenames = self._prepare_filenames(filenames, 2)

# update external file information with cbc output, if necessary
if ipakcb is not None:
model.add_output_file(
ipakcb, fname=filenames[1], package=self._ftype()
)
else:
ipakcb = 0
# cbc output file
self.set_cbc_output_file(ipakcb, model, filenames[1])

# call base package constructor
super().__init__(
Expand All @@ -187,7 +181,6 @@ def __init__(
self.nflw = nflw
self.nhed = nhed
self.ifhbss = ifhbss
self.ipakcb = ipakcb
if nfhbx1 != 0:
nfhbx1 = 0
self.nfhbx1 = nfhbx1
Expand Down
Loading

0 comments on commit 09b59ce

Please sign in to comment.