diff --git a/.docs/Notebooks/modpath7_structured_transient_example.py b/.docs/Notebooks/modpath7_structured_transient_example.py index fb76ebff6b..0e4c22b033 100644 --- a/.docs/Notebooks/modpath7_structured_transient_example.py +++ b/.docs/Notebooks/modpath7_structured_transient_example.py @@ -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" @@ -410,5 +412,3 @@ def add_legend(ax): temp_dir.cleanup() except: pass - - diff --git a/autotest/regression/test_mf6_pandas.py b/autotest/regression/test_mf6_pandas.py index c8123396b5..183ed2ff0f 100644 --- a/autotest/regression/test_mf6_pandas.py +++ b/autotest/regression/test_mf6_pandas.py @@ -48,7 +48,6 @@ ) from flopy.mf6.data.mfdataplist import MFPandasList - pytestmark = pytest.mark.mf6 diff --git a/autotest/test_mbase.py b/autotest/test_mbase.py index 8a2eddcadc..8e3ee5d828 100644 --- a/autotest/test_mbase.py +++ b/autotest/test_mbase.py @@ -10,7 +10,6 @@ from flopy.mbase import resolve_exe from flopy.utils.flopy_io import relpath_safe - _system = system() diff --git a/flopy/mfusg/mfusgbcf.py b/flopy/mfusg/mfusgbcf.py index 6bda77d7cb..fcd99d4729 100644 --- a/flopy/mfusg/mfusgbcf.py +++ b/flopy/mfusg/mfusgbcf.py @@ -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) @@ -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. diff --git a/flopy/mfusg/mfusglpf.py b/flopy/mfusg/mfusglpf.py index 52d0dcf259..42476656d1 100644 --- a/flopy/mfusg/mfusglpf.py +++ b/flopy/mfusg/mfusglpf.py @@ -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 @@ -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. diff --git a/flopy/mfusg/mfusgwel.py b/flopy/mfusg/mfusgwel.py index 1735fd8670..47ecc26d49 100644 --- a/flopy/mfusg/mfusgwel.py +++ b/flopy/mfusg/mfusgwel.py @@ -8,16 +8,10 @@ MODFLOW Guide `_. """ -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 @@ -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 @@ -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. diff --git a/flopy/modflow/mfbcf.py b/flopy/modflow/mfbcf.py index 5c7e10540a..a7aed46a83 100644 --- a/flopy/modflow/mfbcf.py +++ b/flopy/modflow/mfbcf.py @@ -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) @@ -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. @@ -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__( @@ -168,7 +162,6 @@ def __init__( ) # item 1 - self.ipakcb = ipakcb self.hdry = hdry self.iwdflg = iwdflg self.wetfct = wetfct diff --git a/flopy/modflow/mfdrn.py b/flopy/modflow/mfdrn.py index c4614f5aa7..9c3a64f432 100644 --- a/flopy/modflow/mfdrn.py +++ b/flopy/modflow/mfdrn.py @@ -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), @@ -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. @@ -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 = [] @@ -157,8 +151,6 @@ def __init__( self._generate_heading() self.url = "drn.html" - self.ipakcb = ipakcb - self.np = 0 self.options = options diff --git a/flopy/modflow/mfdrt.py b/flopy/modflow/mfdrt.py index 781ddcd3dd..425f6d873d 100644 --- a/flopy/modflow/mfdrt.py +++ b/flopy/modflow/mfdrt.py @@ -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), @@ -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. @@ -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 = [] @@ -152,9 +146,6 @@ def __init__( self._generate_heading() self.url = "drt.html" - - self.ipakcb = ipakcb - self.np = 0 self.options = options diff --git a/flopy/modflow/mfevt.py b/flopy/modflow/mfevt.py index e15cc9bb73..3cd1ad6855 100644 --- a/flopy/modflow/mfevt.py +++ b/flopy/modflow/mfevt.py @@ -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__( @@ -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 diff --git a/flopy/modflow/mffhb.py b/flopy/modflow/mffhb.py index 64764078e3..9ea0c88f44 100644 --- a/flopy/modflow/mffhb.py +++ b/flopy/modflow/mffhb.py @@ -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 @@ -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. @@ -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__( @@ -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 diff --git a/flopy/modflow/mfghb.py b/flopy/modflow/mfghb.py index 903c88c646..fb9ed02116 100644 --- a/flopy/modflow/mfghb.py +++ b/flopy/modflow/mfghb.py @@ -23,12 +23,10 @@ class ModflowGhb(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 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, recarray, dataframe or dictionary of boundaries. - Each ghb cell is defined through definition of layer(int), row(int), column(int), stage(float), conductance(float) The simplest form is a dictionary with a lists of boundaries for each @@ -73,9 +71,9 @@ class ModflowGhb(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. @@ -123,13 +121,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__( @@ -143,7 +136,6 @@ def __init__( self._generate_heading() self.url = "ghb.html" - self.ipakcb = ipakcb self.no_print = no_print self.np = 0 if options is None: diff --git a/flopy/modflow/mflak.py b/flopy/modflow/mflak.py index 50644a4f29..e8a05730fe 100644 --- a/flopy/modflow/mflak.py +++ b/flopy/modflow/mflak.py @@ -28,13 +28,9 @@ class ModflowLak(Package): Sublakes of multiple-lake systems are considered separate lakes for input purposes. The variable NLAKES is used, with certain internal assumptions and approximations, to dimension arrays for the simulation. - ipakcb : int - (ILKCB in MODFLOW documentation) - Whether or not to write cell-by-cell flows (yes if ILKCB> 0, no - otherwise). If ILKCB< 0 and "Save Budget" is specified in the Output - Control or ICBCFL is not equal to 0, the cell-by-cell flows will be - printed in the standard output file. ICBCFL is specified in the input - to the Output Control Option of MODFLOW. + 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). lwrt : int or list of ints (one per SP) lwrt > 0, suppresses printout from the lake package. Default is 0 (to print budget information) @@ -228,9 +224,9 @@ class ModflowLak(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. @@ -296,13 +292,8 @@ def __init__( break filenames = self._prepare_filenames(filenames, nlen) - # 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]) # table input files if tabdata: @@ -351,7 +342,6 @@ def __init__( options = [] self.options = options self.nlakes = nlakes - self.ipakcb = ipakcb self.theta = theta self.nssitr = nssitr self.sscncr = sscncr diff --git a/flopy/modflow/mflpf.py b/flopy/modflow/mflpf.py index 68eabd729a..dd2e589150 100644 --- a/flopy/modflow/mflpf.py +++ b/flopy/modflow/mflpf.py @@ -24,10 +24,9 @@ class ModflowLpf(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 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 @@ -149,9 +148,9 @@ class ModflowLpf(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. @@ -220,13 +219,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__( @@ -242,7 +236,6 @@ def __init__( nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper # item 1 - self.ipakcb = ipakcb self.hdry = ( hdry # Head in cells that are converted to dry during a simulation ) diff --git a/flopy/modflow/mfmnw1.py b/flopy/modflow/mfmnw1.py index ba80376c27..316f323138 100644 --- a/flopy/modflow/mfmnw1.py +++ b/flopy/modflow/mfmnw1.py @@ -19,10 +19,9 @@ class ModflowMnw1(Package): this package will be added. mxmnw : integer maximum number of multi-node wells to be simulated - ipakcb : integer - 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). iwelpt : integer verbosity flag nomoiter : integer @@ -103,13 +102,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__( @@ -126,7 +120,6 @@ def __init__( self.mxmnw = ( mxmnw # -maximum number of multi-node wells to be simulated ) - self.ipakcb = ipakcb self.iwelpt = iwelpt # -verbosity flag self.nomoiter = nomoiter # -integer indicating the number of iterations for which flow in MNW wells is calculated self.kspref = kspref # -alphanumeric key indicating which set of water levels are to be used as reference values for calculating drawdown diff --git a/flopy/modflow/mfmnw2.py b/flopy/modflow/mfmnw2.py index 7a9a5548f5..fd8f1d764f 100644 --- a/flopy/modflow/mfmnw2.py +++ b/flopy/modflow/mfmnw2.py @@ -901,19 +901,9 @@ class ModflowMnw2(Package): value of "NODTOT". The model will then reset "MNWMAX" to its absolute value. The value of "ipakcb" will become the third value on that line, etc. - ipakcb : int - is a flag and a unit number: - if ipakcb > 0, then it is the unit number to which MNW cell-by-cell - flow terms will be recorded whenever cell-by-cell budget data are - written to a file (as determined by the outputcontrol options of - MODFLOW). - if ipakcb = 0, then MNW cell-by-cell flow terms will not be printed - or recorded. - if ipakcb < 0, then well injection or withdrawal rates and water - levels in the well and its multiple cells will be printed in - the main MODFLOW listing (output) file whenever cell-by-cell - budget data are written to a file (as determined by the output - control options of MODFLOW). + 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). mnwprnt : integer Flag controlling the level of detail of information about multi-node wells to be written to the main MODFLOW listing (output) file. @@ -966,9 +956,9 @@ class ModflowMnw2(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. @@ -1001,7 +991,7 @@ def __init__( model, mnwmax=0, nodtot=None, - ipakcb=0, + ipakcb=None, mnwprnt=0, aux=[], node_data=None, @@ -1020,13 +1010,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__( @@ -1050,7 +1035,6 @@ def __init__( # maximum number of multi-node wells to be simulated self.mnwmax = int(mnwmax) self.nodtot = nodtot # user-specified maximum number of nodes - self.ipakcb = ipakcb self.mnwprnt = int(mnwprnt) # -verbosity flag self.aux = aux # -list of optional auxiliary parameters diff --git a/flopy/modflow/mfrch.py b/flopy/modflow/mfrch.py index eae2a0e16b..70861a9c4e 100644 --- a/flopy/modflow/mfrch.py +++ b/flopy/modflow/mfrch.py @@ -25,10 +25,9 @@ class ModflowRch(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 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). nrchop : int is the recharge option code. 1: Recharge to top grid layer only @@ -49,9 +48,9 @@ class ModflowRch(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. @@ -108,13 +107,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__( @@ -130,7 +124,6 @@ def __init__( self.url = "rch.html" self.nrchop = nrchop - self.ipakcb = ipakcb rech_u2d_shape = get_pak_vals_shape(model, rech) irch_u2d_shape = get_pak_vals_shape(model, irch) diff --git a/flopy/modflow/mfriv.py b/flopy/modflow/mfriv.py index a557da18a3..7cbdf57c3f 100644 --- a/flopy/modflow/mfriv.py +++ b/flopy/modflow/mfriv.py @@ -23,10 +23,9 @@ class ModflowRiv(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 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, recarray, dataframe, or dictionary of boundaries. Each river cell is defined through definition of layer (int), row (int), column (int), stage (float), cond (float), @@ -76,9 +75,9 @@ class ModflowRiv(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. @@ -131,13 +130,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__( @@ -151,7 +145,6 @@ def __init__( self._generate_heading() self.url = "riv.html" - self.ipakcb = ipakcb self.mxactr = 0 self.np = 0 if options is None: diff --git a/flopy/modflow/mfsfr2.py b/flopy/modflow/mfsfr2.py index 1287948070..bc030770be 100644 --- a/flopy/modflow/mfsfr2.py +++ b/flopy/modflow/mfsfr2.py @@ -68,14 +68,9 @@ class ModflowSfr2(Package): computing leakage between each stream reach and active model cell. Value is in units of length. Usually a value of 0.0001 is sufficient when units of feet or meters are used in model. - ipakcb : integer - An integer value used as a flag for writing stream-aquifer leakage - values. If ipakcb > 0, unformatted leakage between each stream reach - and corresponding model cell will be saved to the main cell-by-cell - budget file whenever when a cell-by-cell budget has been specified in - Output Control (see Harbaugh and others, 2000, pages 52-55). If - ipakcb = 0, leakage values will not be printed or saved. Printing to - the listing file (ipakcb < 0) is not supported. + 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). istcb2 : integer An integer value used as a flag for writing to a separate formatted file all information on inflows and outflows from each reach; on @@ -228,7 +223,7 @@ class ModflowSfr2(Package): filenames=None the package name will be created using the model name and package extension and the cbc output and sfr output name will be created using the model name and .cbc the .sfr.bin/.sfr.out extensions - (for example, modflowtest.cbc, and modflowtest.sfr.bin), if ipakcbc and + (for example, modflowtest.cbc, and modflowtest.sfr.bin), if ipakcb and istcb2 are numbers greater than zero. If a single string is passed the package name will be set to the string and other uzf output files will be set to the model name with the appropriate output file extensions. @@ -358,13 +353,8 @@ def __init__( # set filenames filenames = self._prepare_filenames(filenames, 3) - # 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]) # add sfr flow output file if istcb2 is not None: @@ -451,7 +441,6 @@ def __init__( dleak # tolerance level of stream depth used in computing leakage ) - self.ipakcb = ipakcb # flag; unit number for writing table of SFR output to text file self.istcb2 = istcb2 diff --git a/flopy/modflow/mfstr.py b/flopy/modflow/mfstr.py index cb480f5235..07cb545f49 100644 --- a/flopy/modflow/mfstr.py +++ b/flopy/modflow/mfstr.py @@ -47,10 +47,9 @@ class ModflowStr(Package): The constant must be multiplied by 86,400 when using time units of days in the simulation. If ICALC is 0, const can be any real value. (default is 86400.) - 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). istcb2 : int A flag that is used flag and a unit number for the option to store streamflow out of each reach in an unformatted (binary) file. @@ -191,11 +190,11 @@ class ModflowStr(Package): filenames=None the package name will be created using the model name and package extension and the cbc output and str output name will be created using the model name and .cbc the .sfr.bin/.sfr.out extensions - (for example, modflowtest.cbc, and modflowtest.str.bin), if ipakcbc and + (for example, modflowtest.cbc, and modflowtest.str.bin), if ipakcb and istcb2 are numbers greater than zero. If a single string is passed the package will be set to the string and cbc and sf routput names will be created using the model name and .cbc and .str.bin/.str.out - extensions, if ipakcbc and istcb2 are numbers greater than zero. To + extensions, if ipakcb and istcb2 are numbers greater than zero. To define the names for all package files (input and output) the length of the list of strings should be 3. Default is None. @@ -250,13 +249,8 @@ def __init__( # set filenames filenames = self._prepare_filenames(filenames, 3) - # 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 istcb2 is not None: model.add_output_file( @@ -282,7 +276,6 @@ def __init__( self.ntrib = ntrib self.ndiv = ndiv self.const = const - self.ipakcb = ipakcb self.istcb2 = istcb2 # issue exception if ntrib is greater than 10 diff --git a/flopy/modflow/mfsub.py b/flopy/modflow/mfsub.py index f56d14e653..0453ed2a91 100644 --- a/flopy/modflow/mfsub.py +++ b/flopy/modflow/mfsub.py @@ -22,10 +22,9 @@ class ModflowSub(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 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). isuboc : int isuboc is a flag used to control output of information generated by the SUB Package. (default is 0). @@ -254,13 +253,8 @@ def __init__( # set filenames filenames = self._prepare_filenames(filenames, 9) - # 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 idsave is not None: model.add_output_file( @@ -312,7 +306,6 @@ def __init__( self._generate_heading() self.url = "sub.html" - self.ipakcb = ipakcb self.isuboc = isuboc self.idsave = idsave self.idrest = idrest diff --git a/flopy/modflow/mfswi2.py b/flopy/modflow/mfswi2.py index a28ef5e9f7..63acd3b947 100644 --- a/flopy/modflow/mfswi2.py +++ b/flopy/modflow/mfswi2.py @@ -26,10 +26,9 @@ class ModflowSwi2(Package): flag indicating the density distribution. (default is 1). iswizt : int unit number for zeta output. (default is None). - 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). iswiobs : int flag and unit number SWI2 observation output. (default is 0). options : list of strings @@ -242,13 +241,8 @@ def __init__( else: iswizt = 0 - # update external file information with swi2 cell-by-cell output, - # if necessary - if ipakcb is not None: - fname = filenames[2] - model.add_output_file(ipakcb, fname=fname, package=self._ftype()) - else: - ipakcb = 0 + # cbc output file + self.set_cbc_output_file(ipakcb, model, filenames[2]) # Process observations if nobs != 0: @@ -338,8 +332,6 @@ def __init__( self.nobs = nobs self.iswizt = iswizt self.iswiobs = iswiobs - # set cbc unit - self.ipakcb = ipakcb # set solver flags self.nsolver = nsolver diff --git a/flopy/modflow/mfswt.py b/flopy/modflow/mfswt.py index 4d8d1c7650..8c9e67f757 100644 --- a/flopy/modflow/mfswt.py +++ b/flopy/modflow/mfswt.py @@ -22,10 +22,9 @@ class ModflowSwt(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 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). iswtoc : int iswtoc is a flag used to control output of information generated by the SUB Package. (default is 0). @@ -193,7 +192,7 @@ class ModflowSwt(Package): filenames=None the package name will be created using the model name and package extension and the cbc output name and other swt output files will be created using the model name and .cbc and swt output - extensions (for example, modflowtest.cbc), if ipakcbc and other + extensions (for example, modflowtest.cbc), if ipakcb and other swt output files (dataset 16) are numbers greater than zero. If a single string is passed the package name will be set to the string and other swt output files will be set to the model name with @@ -368,13 +367,8 @@ def __init__( # set filenames filenames = self._prepare_filenames(filenames, 15) - # 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]) item16_extensions = [ "swt_subsidence.hds", @@ -420,7 +414,6 @@ def __init__( self._generate_heading() self.url = "swt.html" - self.ipakcb = ipakcb self.iswtoc = iswtoc self.nsystm = nsystm @@ -624,9 +617,6 @@ def load(cls, f, model, ext_unit_dict=None): int(t[6]), ) - # if ipakcb > 0: - # ipakcb = 53 - # read dataset 2 lnwt = None if nsystm > 0: diff --git a/flopy/modflow/mfupw.py b/flopy/modflow/mfupw.py index 093ef0b4f5..e26097ff1d 100644 --- a/flopy/modflow/mfupw.py +++ b/flopy/modflow/mfupw.py @@ -25,10 +25,9 @@ class ModflowUpw(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 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 @@ -108,9 +107,9 @@ class ModflowUpw(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. @@ -172,13 +171,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__( @@ -193,8 +187,6 @@ def __init__( self.url = "upw_upstream_weighting_package.html" nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper - # item 1 - self.ipakcb = ipakcb # Head in cells that are converted to dry during a simulation self.hdry = hdry # number of UPW parameters diff --git a/flopy/modflow/mfuzf1.py b/flopy/modflow/mfuzf1.py index c680876407..5acc699eb3 100644 --- a/flopy/modflow/mfuzf1.py +++ b/flopy/modflow/mfuzf1.py @@ -7,7 +7,6 @@ `_. """ -import warnings import numpy as np @@ -58,14 +57,9 @@ class ModflowUzf1(Package): specifies whether or not evapotranspiration (ET) will be simulated. ET will not be simulated if IETFLG is zero, otherwise it will be simulated. (default is 0) - ipakcb : integer - flag for writing ground-water recharge, ET, and ground-water - discharge to land surface rates to a separate unformatted file using - subroutine UBUDSV. If ipakcb>0, it is the unit number to which the - cell-by-cell rates will be written when 'SAVE BUDGET' or a non-zero - value for ICBCFL is specified in Output Control. If ipakcb less than - or equal to 0, cell-by-cell rates will not be written to a file. - (default is 57) + 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). iuzfcb2 : integer flag for writing ground-water recharge, ET, and ground-water discharge to land surface rates to a separate unformatted file using @@ -266,7 +260,7 @@ class ModflowUzf1(Package): and package extension and the cbc output, uzf output, and uzf observation names will be created using the model name and .cbc, uzfcb2.bin, and .uzf#.out extensions (for example, modflowtest.cbc, - and modflowtest.uzfcd2.bin), if ipakcbc, iuzfcb2, and len(uzgag) are + and modflowtest.uzfcd2.bin), if ipakcb, iuzfcb2, and len(uzgag) are numbers greater than zero. For uzf observations the file extension is created using the uzf observation file unit number (for example, for uzf observations written to unit 123 the file extension would be @@ -397,13 +391,8 @@ def __init__( nlen += len(uzgag) filenames = self._prepare_filenames(filenames, nlen) - # update external file information with cbc output, if necessary - if ipakcb is not None: - model.add_output_file( - abs(ipakcb), fname=filenames[1], package=self._ftype() - ) - else: - ipakcb = 0 + # cbc output file + self.set_cbc_output_file(ipakcb, model, filenames[1]) if iuzfcb2 is not None: model.add_output_file( @@ -524,7 +513,6 @@ def __init__( # must be active if IRUNFLG is not zero. self.irunflg = irunflg self.ietflg = ietflg - self.ipakcb = ipakcb self.iuzfcb2 = iuzfcb2 if iuzfopt > 0: self.ntrail2 = ntrail2 diff --git a/flopy/modflow/mfwel.py b/flopy/modflow/mfwel.py index 69a51e42f5..c9e82d3b82 100644 --- a/flopy/modflow/mfwel.py +++ b/flopy/modflow/mfwel.py @@ -24,10 +24,9 @@ class ModflowWel(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 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, recarray, dataframe or dictionary of boundaries. Each well is defined through definition of layer (int), row (int), column (int), flux (float). @@ -73,9 +72,9 @@ class ModflowWel(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. @@ -159,13 +158,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__( @@ -178,8 +172,6 @@ def __init__( self._generate_heading() self.url = "wel.html" - - self.ipakcb = ipakcb self.np = 0 if options is None: diff --git a/flopy/pakbase.py b/flopy/pakbase.py index 21a8a8ce16..c7b4297d07 100644 --- a/flopy/pakbase.py +++ b/flopy/pakbase.py @@ -1258,3 +1258,12 @@ def load( level=0, ) return pak + + def set_cbc_output_file(self, ipakcb, model, fname): + if ipakcb is None: + ipakcb = 0 + else: + if ipakcb == "default": + ipakcb = 53 + model.add_output_file(ipakcb, fname=fname, package=self._ftype()) + self.ipakcb = ipakcb