Skip to content
Open
48 changes: 34 additions & 14 deletions flopy/modflow/mfwel.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ def __init__(
self.url = "wel.html"
self.np = 0

tabfiles = False
if options is None:
options = []
self.specify = False
Expand All @@ -178,6 +179,9 @@ def __init__(
self.phiramp = self.options.phiramp
self.iunitramp = self.options.iunitramp
# this is to grab the aux variables...
if self.options.tabfiles:
tabfiles = True

options = []

else:
Expand All @@ -196,7 +200,9 @@ def __init__(
self.dtype = self.get_default_dtype(structured=self.parent.structured)

# determine if any aux variables in dtype
dt = self.get_default_dtype(structured=self.parent.structured)
dt = self.get_default_dtype(
structured=self.parent.structured, tabfiles=tabfiles
)
if len(self.dtype.names) > len(dt.names):
for name in self.dtype.names[len(dt.names) :]:
ladd = True
Expand Down Expand Up @@ -295,24 +301,38 @@ def add_record(self, kper, index, values):
raise Exception(f"mfwel error adding record to list: {e!s}")

@staticmethod
def get_default_dtype(structured=True):
if structured:
dtype = np.dtype(
[
("k", int),
("i", int),
("j", int),
("flux", np.float32),
]
)
def get_default_dtype(structured=True, tabfiles=False):
if not tabfiles:
if structured:
dtype = np.dtype(
[
("k", int),
("i", int),
("j", int),
("flux", np.float32),
]
)
else:
dtype = np.dtype([("node", int), ("flux", np.float32)])
else:
dtype = np.dtype([("node", int), ("flux", np.float32)])
if structured:
dtype = np.dtype(
[
("tabunit", int),
("tabval", int),
("k", int),
("i", int),
("j", int),
]
)
else:
dtype = np.dtype([("tabunit", int), ("tabval", int), ("node", int)])
return dtype

@staticmethod
def get_empty(ncells=0, aux_names=None, structured=True):
def get_empty(ncells=0, aux_names=None, structured=True, tabfiles=False):
# get an empty recarray that corresponds to dtype
dtype = ModflowWel.get_default_dtype(structured=structured)
dtype = ModflowWel.get_default_dtype(structured=structured, tabfiles=tabfiles)
if aux_names is not None:
dtype = Package.add_to_dtype(dtype, aux_names, np.float32)
return create_empty_recarray(ncells, dtype, default_value=-1.0e10)
Expand Down
14 changes: 14 additions & 0 deletions flopy/pakbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ def load(
nwt_options = OptionBlock.load_options(f, pak_type)
line = f.readline()

nwt_tabfiles = False

# check for parameters
nppak = 0
if "parameter" in line.lower():
Expand Down Expand Up @@ -1062,6 +1064,11 @@ def load(
options = nwt_options
else:
f.seek(ipos)

if isinstance(options, OptionBlock):
if options.tabfiles:
nwt_tabfiles = True

elif "flopy.modflow.mfchd.modflowchd".lower() in pak_type_str:
partype = ["shead", "ehead"]

Expand All @@ -1085,6 +1092,13 @@ def load(
bnd_output_cln = None
stress_period_data_cln = {}
current_cln = None

if nwt_tabfiles:
# pass tabfile flag using the existing usg_args dict, change nper to 1
nper = 1
sfac_columns = []
usg_args["tabfiles"] = True

for iper in range(nper):
if model.verbose:
msg = f" loading {pak_type} for kper {iper + 1:5d}"
Expand Down
Loading