Note
How FloPy handles external files for arrays
[1]:
import os
import sys
import shutil
from tempfile import TemporaryDirectory
import numpy as np
# run installed version of flopy or add local path
try:
import flopy
except:
fpth = os.path.abspath(os.path.join("..", ".."))
sys.path.append(fpth)
import flopy
from flopy.utils import flopy_io
print(sys.version)
print("numpy version: {}".format(np.__version__))
print("flopy version: {}".format(flopy.__version__))
3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0]
numpy version: 1.24.3
flopy version: 3.3.7
[2]:
# make a model
nlay, nrow, ncol = 10, 20, 5
temp_dir = TemporaryDirectory()
model_ws = temp_dir.name
# the place for all of your hand made and costly model inputs
array_dir = os.path.join(temp_dir.name, "array_dir")
os.mkdir(array_dir)
ml = flopy.modflow.Modflow(model_ws=model_ws)
dis = flopy.modflow.ModflowDis(
ml, nlay=nlay, nrow=nrow, ncol=ncol, steady=False, nper=2
)
make an hk
and vka
array. We’ll save hk
to files - pretent that you spent months making this important model property. Then make an lpf
[3]:
hk = np.zeros((nlay, nrow, ncol)) + 5.0
vka = np.zeros_like(hk)
fnames = []
for i, h in enumerate(hk):
fname = os.path.join(array_dir, "hk_{0}.ref".format(i + 1))
fnames.append(fname)
np.savetxt(fname, h)
vka[i] = i + 1
lpf = flopy.modflow.ModflowLpf(ml, hk=fnames, vka=vka)
Let’s also have some recharge with mixed args as well. Pretend the recharge in the second stress period is very important and precise
[4]:
warmup_recharge = np.ones((nrow, ncol))
important_recharge = np.random.random((nrow, ncol))
fname = os.path.join(array_dir, "important_recharge.ref")
np.savetxt(fname, important_recharge)
rch = flopy.modflow.ModflowRch(ml, rech={0: warmup_recharge, 1: fname})
[5]:
ml.write_input()
Let’s look at the files that were created
[6]:
from pprint import pprint
print("model_ws:", flopy_io.scrub_login(ml.model_ws))
pprint([flopy_io.scrub_login(p) for p in os.listdir(ml.model_ws)])
model_ws: /tmp/tmp8sc8xnk7
['modflowtest.nam',
'modflowtest.lpf',
'hk_5.ref',
'important_recharge.ref',
'hk_7.ref',
'hk_10.ref',
'array_dir',
'hk_4.ref',
'hk_9.ref',
'hk_1.ref',
'modflowtest.dis',
'hk_2.ref',
'hk_3.ref',
'hk_8.ref',
'modflowtest.rch',
'hk_6.ref']
We see that a copy of the hk
files as well as the important recharge file were made in the model_ws
.Let’s looks at the lpf
file
[7]:
open(os.path.join(ml.model_ws, ml.name + ".lpf"), "r").readlines()[:20]
[7]:
['# LPF package for MODFLOW-2005 generated by Flopy 3.3.7\n',
' 0 -1E+30 0 \n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 0 0 0 0 0 0 0 0 0 0\n',
'OPEN/CLOSE hk_1.ref 1 (FREE) -1 hk layer 1 \n',
'INTERNAL 1 (5E15.6) -1 #vka1 \n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n']
We see that the open/close
approach was used - this is because ml.array_free_format
is True
. Notice that vka
is written internally
[8]:
ml.array_free_format
[8]:
True
Now change model_ws
[9]:
ml.model_ws = os.path.join(model_ws, "new_external_demo_dir")
creating model workspace...
../../../../../../../tmp/tmp8sc8xnk7/new_external_demo_dir
Now when we call write_input()
, a copy of external files are made in the current model_ws
[10]:
ml.write_input()
[11]:
# list the files in model_ws that have 'hk' in the name
print(
"\n".join(
[
name
for name in os.listdir(ml.model_ws)
if "hk" in name or "impor" in name
]
)
)
hk_5.ref
important_recharge.ref
hk_7.ref
hk_10.ref
hk_4.ref
hk_9.ref
hk_1.ref
hk_2.ref
hk_3.ref
hk_8.ref
hk_6.ref
Now we see that the external files were copied to the new model_ws
Using external_path
It is sometimes useful when first building a model to write the model arrays as external files for processing and parameter estimation. The model
attribute external_path
triggers this behavior
[12]:
# make a model - same code as before except for the model constructor
nlay, nrow, ncol = 10, 20, 5
model_ws = os.path.join(model_ws, "external_demo")
os.mkdir(model_ws)
# the place for all of your hand made and costly model inputs
array_dir = os.path.join(model_ws, "array_dir")
os.mkdir(array_dir)
# lets make an external path relative to the model_ws
ml = flopy.modflow.Modflow(
model_ws=model_ws, external_path=os.path.join(model_ws, "ref")
)
dis = flopy.modflow.ModflowDis(
ml, nlay=nlay, nrow=nrow, ncol=ncol, steady=False, nper=2
)
hk = np.zeros((nlay, nrow, ncol)) + 5.0
vka = np.zeros_like(hk)
fnames = []
for i, h in enumerate(hk):
fname = os.path.join(array_dir, "hk_{0}.ref".format(i + 1))
fnames.append(fname)
np.savetxt(fname, h)
vka[i] = i + 1
lpf = flopy.modflow.ModflowLpf(ml, hk=fnames, vka=vka)
warmup_recharge = np.ones((nrow, ncol))
important_recharge = np.random.random((nrow, ncol))
fname = os.path.join(array_dir, "important_recharge.ref")
np.savetxt(fname, important_recharge)
rch = flopy.modflow.ModflowRch(ml, rech={0: warmup_recharge, 1: fname})
We can see that the model constructor created both model_ws
and external_path
which is relative to the model_ws
[13]:
os.listdir(ml.model_ws)
[13]:
['array_dir', 'ref']
Now, when we call write_input()
, any array properties that were specified as np.ndarray
will be written externally. If a scalar was passed as the argument, the value remains internal to the model input files
[14]:
ml.write_input()
# open(os.path.join(ml.model_ws, ml.name + ".lpf"), "r").readlines()[:20]
Util2d:delr: resetting 'how' to external
Util2d:delc: resetting 'how' to external
Util2d:model_top: resetting 'how' to external
Util2d:botm layer 1: resetting 'how' to external
Util2d:botm layer 2: resetting 'how' to external
Util2d:botm layer 3: resetting 'how' to external
Util2d:botm layer 4: resetting 'how' to external
Util2d:botm layer 5: resetting 'how' to external
Util2d:botm layer 6: resetting 'how' to external
Util2d:botm layer 7: resetting 'how' to external
Util2d:botm layer 8: resetting 'how' to external
Util2d:botm layer 9: resetting 'how' to external
Util2d:botm layer 10: resetting 'how' to external
Util2d:ss layer 1: resetting 'how' to external
Util2d:ss layer 2: resetting 'how' to external
Util2d:ss layer 3: resetting 'how' to external
Util2d:ss layer 4: resetting 'how' to external
Util2d:ss layer 5: resetting 'how' to external
Util2d:ss layer 6: resetting 'how' to external
Util2d:ss layer 7: resetting 'how' to external
Util2d:ss layer 8: resetting 'how' to external
Util2d:ss layer 9: resetting 'how' to external
Util2d:ss layer 10: resetting 'how' to external
Now, vka
was also written externally, but not the storage properties.Let’s verify the contents of the external path directory. We see our hard-fought hk
and important_recharge
arrays, as well as the vka
arrays.
[15]:
ml.lpf.ss.how = "internal"
ml.write_input()
# open(os.path.join(ml.model_ws, ml.name + ".lpf"), "r").readlines()[:20]
Util2d:delr: resetting 'how' to external
Util2d:delc: resetting 'how' to external
Util2d:model_top: resetting 'how' to external
Util2d:botm layer 1: resetting 'how' to external
Util2d:botm layer 2: resetting 'how' to external
Util2d:botm layer 3: resetting 'how' to external
Util2d:botm layer 4: resetting 'how' to external
Util2d:botm layer 5: resetting 'how' to external
Util2d:botm layer 6: resetting 'how' to external
Util2d:botm layer 7: resetting 'how' to external
Util2d:botm layer 8: resetting 'how' to external
Util2d:botm layer 9: resetting 'how' to external
Util2d:botm layer 10: resetting 'how' to external
Util2d:ss layer 1: resetting 'how' to external
Util2d:ss layer 2: resetting 'how' to external
Util2d:ss layer 3: resetting 'how' to external
Util2d:ss layer 4: resetting 'how' to external
Util2d:ss layer 5: resetting 'how' to external
Util2d:ss layer 6: resetting 'how' to external
Util2d:ss layer 7: resetting 'how' to external
Util2d:ss layer 8: resetting 'how' to external
Util2d:ss layer 9: resetting 'how' to external
Util2d:ss layer 10: resetting 'how' to external
[16]:
print("\n".join(os.listdir(os.path.join(ml.model_ws, ml.external_path))))
vka4.ref
botm_layer_2.ref
ss_layer_2.ref
delr.ref
botm_layer_1.ref
botm_layer_7.ref
ss_layer_8.ref
model_top.ref
vka1.ref
vka10.ref
ss_layer_6.ref
botm_layer_6.ref
ss_layer_7.ref
botm_layer_4.ref
hk_5.ref
vka3.ref
vka9.ref
vka2.ref
vka6.ref
botm_layer_5.ref
important_recharge.ref
rech_0.ref
hk_7.ref
botm_layer_3.ref
botm_layer_10.ref
hk_10.ref
hk_4.ref
vka8.ref
botm_layer_9.ref
vka7.ref
hk_9.ref
hk_1.ref
vka5.ref
delc.ref
botm_layer_8.ref
ss_layer_3.ref
hk_2.ref
ss_layer_5.ref
hk_3.ref
hk_8.ref
ss_layer_4.ref
ss_layer_10.ref
ss_layer_9.ref
hk_6.ref
ss_layer_1.ref
Fixed format
All of this behavior also works for fixed-format type models (really, really old models - I mean OLD!)
[17]:
# make a model - same code as before except for the model constructor
nlay, nrow, ncol = 10, 20, 5
# lets make an external path relative to the model_ws
ml = flopy.modflow.Modflow(model_ws=model_ws, external_path="ref")
# explicitly reset the free_format flag BEFORE ANY PACKAGES ARE MADE!!!
ml.array_free_format = False
dis = flopy.modflow.ModflowDis(
ml, nlay=nlay, nrow=nrow, ncol=ncol, steady=False, nper=2
)
hk = np.zeros((nlay, nrow, ncol)) + 5.0
vka = np.zeros_like(hk)
fnames = []
for i, h in enumerate(hk):
fname = os.path.join(array_dir, "hk_{0}.ref".format(i + 1))
fnames.append(fname)
np.savetxt(fname, h)
vka[i] = i + 1
lpf = flopy.modflow.ModflowLpf(ml, hk=fnames, vka=vka)
ml.lpf.ss.how = "internal"
warmup_recharge = np.ones((nrow, ncol))
important_recharge = np.random.random((nrow, ncol))
fname = os.path.join(array_dir, "important_recharge.ref")
np.savetxt(fname, important_recharge)
rch = flopy.modflow.ModflowRch(ml, rech={0: warmup_recharge, 1: fname})
ml.write_input()
Note: external_path ref already exists
Util2d:delr: resetting 'how' to external
Util2d:delc: resetting 'how' to external
Util2d:model_top: resetting 'how' to external
Util2d:botm layer 1: resetting 'how' to external
Util2d:botm layer 2: resetting 'how' to external
Util2d:botm layer 3: resetting 'how' to external
Util2d:botm layer 4: resetting 'how' to external
Util2d:botm layer 5: resetting 'how' to external
Util2d:botm layer 6: resetting 'how' to external
Util2d:botm layer 7: resetting 'how' to external
Util2d:botm layer 8: resetting 'how' to external
Util2d:botm layer 9: resetting 'how' to external
Util2d:botm layer 10: resetting 'how' to external
Util2d hk layer 1: can't be free format...resetting
Util2d:ss layer 1: resetting 'how' to external
Util2d hk layer 2: can't be free format...resetting
Util2d:ss layer 2: resetting 'how' to external
Util2d hk layer 3: can't be free format...resetting
Util2d:ss layer 3: resetting 'how' to external
Util2d hk layer 4: can't be free format...resetting
Util2d:ss layer 4: resetting 'how' to external
Util2d hk layer 5: can't be free format...resetting
Util2d:ss layer 5: resetting 'how' to external
Util2d hk layer 6: can't be free format...resetting
Util2d:ss layer 6: resetting 'how' to external
Util2d hk layer 7: can't be free format...resetting
Util2d:ss layer 7: resetting 'how' to external
Util2d hk layer 8: can't be free format...resetting
Util2d:ss layer 8: resetting 'how' to external
Util2d hk layer 9: can't be free format...resetting
Util2d:ss layer 9: resetting 'how' to external
Util2d hk layer 10: can't be free format...resetting
Util2d:ss layer 10: resetting 'how' to external
Util2d rech_2: can't be free format...resetting
We see that now the external arrays are being handled through the name file. Let’s look at the name file
[18]:
open(os.path.join(ml.model_ws, ml.name + ".nam"), "r").readlines()
[18]:
['# Name file for MODFLOW-2005, generated by Flopy version 3.3.7.\n',
'#xll:0.0; yll:0.0; rotation:0.0; units:meters; lenuni:2; start_datetime:1-1-1970\n',
'LIST 2 modflowtest.list\n',
'DIS 11 modflowtest.dis\n',
'LPF 15 modflowtest.lpf\n',
'RCH 19 modflowtest.rch\n',
'DATA 1001 ref/delr.ref\n',
'DATA 1002 ref/delc.ref\n',
'DATA 1003 ref/model_top.ref\n',
'DATA 1004 ref/botm_layer_1.ref\n',
'DATA 1005 ref/botm_layer_2.ref\n',
'DATA 1006 ref/botm_layer_3.ref\n',
'DATA 1007 ref/botm_layer_4.ref\n',
'DATA 1008 ref/botm_layer_5.ref\n',
'DATA 1009 ref/botm_layer_6.ref\n',
'DATA 1010 ref/botm_layer_7.ref\n',
'DATA 1011 ref/botm_layer_8.ref\n',
'DATA 1012 ref/botm_layer_9.ref\n',
'DATA 1013 ref/botm_layer_10.ref\n',
'DATA 1014 ref/hk_1.ref\n',
'DATA 1015 ref/vka1.ref\n',
'DATA 1016 ref/ss_layer_1.ref\n',
'DATA 1017 ref/hk_2.ref\n',
'DATA 1018 ref/vka2.ref\n',
'DATA 1019 ref/ss_layer_2.ref\n',
'DATA 1020 ref/hk_3.ref\n',
'DATA 1021 ref/vka3.ref\n',
'DATA 1022 ref/ss_layer_3.ref\n',
'DATA 1023 ref/hk_4.ref\n',
'DATA 1024 ref/vka4.ref\n',
'DATA 1025 ref/ss_layer_4.ref\n',
'DATA 1026 ref/hk_5.ref\n',
'DATA 1027 ref/vka5.ref\n',
'DATA 1028 ref/ss_layer_5.ref\n',
'DATA 1029 ref/hk_6.ref\n',
'DATA 1030 ref/vka6.ref\n',
'DATA 1031 ref/ss_layer_6.ref\n',
'DATA 1032 ref/hk_7.ref\n',
'DATA 1033 ref/vka7.ref\n',
'DATA 1034 ref/ss_layer_7.ref\n',
'DATA 1035 ref/hk_8.ref\n',
'DATA 1036 ref/vka8.ref\n',
'DATA 1037 ref/ss_layer_8.ref\n',
'DATA 1038 ref/hk_9.ref\n',
'DATA 1039 ref/vka9.ref\n',
'DATA 1040 ref/ss_layer_9.ref\n',
'DATA 1041 ref/hk_10.ref\n',
'DATA 1042 ref/vka10.ref\n',
'DATA 1043 ref/ss_layer_10.ref\n',
'DATA 1044 ref/rech_0.ref\n',
'DATA 1045 ref/important_recharge.ref\n']
“free” and “binary” format
[19]:
ml.dis.botm[0].format.binary = True
ml.write_input()
Util2d:delr: resetting 'how' to external
Util2d:delc: resetting 'how' to external
Util2d:model_top: resetting 'how' to external
Util2d:botm layer 1: resetting 'how' to external
Util2d:botm layer 2: resetting 'how' to external
Util2d:botm layer 3: resetting 'how' to external
Util2d:botm layer 4: resetting 'how' to external
Util2d:botm layer 5: resetting 'how' to external
Util2d:botm layer 6: resetting 'how' to external
Util2d:botm layer 7: resetting 'how' to external
Util2d:botm layer 8: resetting 'how' to external
Util2d:botm layer 9: resetting 'how' to external
Util2d:botm layer 10: resetting 'how' to external
Util2d:ss layer 1: resetting 'how' to external
Util2d:ss layer 2: resetting 'how' to external
Util2d:ss layer 3: resetting 'how' to external
Util2d:ss layer 4: resetting 'how' to external
Util2d:ss layer 5: resetting 'how' to external
Util2d:ss layer 6: resetting 'how' to external
Util2d:ss layer 7: resetting 'how' to external
Util2d:ss layer 8: resetting 'how' to external
Util2d:ss layer 9: resetting 'how' to external
Util2d:ss layer 10: resetting 'how' to external
[20]:
open(os.path.join(ml.model_ws, ml.name + ".nam"), "r").readlines()
[20]:
['# Name file for MODFLOW-2005, generated by Flopy version 3.3.7.\n',
'#xll:0.0; yll:0.0; rotation:0.0; units:meters; lenuni:2; start_datetime:1-1-1970\n',
'LIST 2 modflowtest.list\n',
'DIS 11 modflowtest.dis\n',
'LPF 15 modflowtest.lpf\n',
'RCH 19 modflowtest.rch\n',
'DATA 1046 ref/delr.ref\n',
'DATA 1047 ref/delc.ref\n',
'DATA 1048 ref/model_top.ref\n',
'DATA(BINARY) 1049 ref/botm_layer_1.ref\n',
'DATA 1050 ref/botm_layer_2.ref\n',
'DATA 1051 ref/botm_layer_3.ref\n',
'DATA 1052 ref/botm_layer_4.ref\n',
'DATA 1053 ref/botm_layer_5.ref\n',
'DATA 1054 ref/botm_layer_6.ref\n',
'DATA 1055 ref/botm_layer_7.ref\n',
'DATA 1056 ref/botm_layer_8.ref\n',
'DATA 1057 ref/botm_layer_9.ref\n',
'DATA 1058 ref/botm_layer_10.ref\n',
'DATA 1059 ref/hk_1.ref\n',
'DATA 1060 ref/vka1.ref\n',
'DATA 1061 ref/ss_layer_1.ref\n',
'DATA 1062 ref/hk_2.ref\n',
'DATA 1063 ref/vka2.ref\n',
'DATA 1064 ref/ss_layer_2.ref\n',
'DATA 1065 ref/hk_3.ref\n',
'DATA 1066 ref/vka3.ref\n',
'DATA 1067 ref/ss_layer_3.ref\n',
'DATA 1068 ref/hk_4.ref\n',
'DATA 1069 ref/vka4.ref\n',
'DATA 1070 ref/ss_layer_4.ref\n',
'DATA 1071 ref/hk_5.ref\n',
'DATA 1072 ref/vka5.ref\n',
'DATA 1073 ref/ss_layer_5.ref\n',
'DATA 1074 ref/hk_6.ref\n',
'DATA 1075 ref/vka6.ref\n',
'DATA 1076 ref/ss_layer_6.ref\n',
'DATA 1077 ref/hk_7.ref\n',
'DATA 1078 ref/vka7.ref\n',
'DATA 1079 ref/ss_layer_7.ref\n',
'DATA 1080 ref/hk_8.ref\n',
'DATA 1081 ref/vka8.ref\n',
'DATA 1082 ref/ss_layer_8.ref\n',
'DATA 1083 ref/hk_9.ref\n',
'DATA 1084 ref/vka9.ref\n',
'DATA 1085 ref/ss_layer_9.ref\n',
'DATA 1086 ref/hk_10.ref\n',
'DATA 1087 ref/vka10.ref\n',
'DATA 1088 ref/ss_layer_10.ref\n',
'DATA 1089 ref/rech_0.ref\n',
'DATA 1090 ref/important_recharge.ref\n']
[21]:
open(os.path.join(ml.model_ws, ml.name + ".dis"), "r").readlines()
[21]:
['# DIS package for MODFLOW-2005 generated by Flopy 3.3.7\n',
' 10 20 5 2 4 2\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 1046 1 (5E15.6) -1 #delr\n',
' 1047 1 (20E15.6) -1 #delc\n',
' 1048 1 (5E15.6) -1 #model_top\n',
' -1049 1 (BINARY) -1 #botm layer 1\n',
' 1050 1 (5E15.6) -1 #botm layer 2\n',
' 1051 1 (5E15.6) -1 #botm layer 3\n',
' 1052 1 (5E15.6) -1 #botm layer 4\n',
' 1053 1 (5E15.6) -1 #botm layer 5\n',
' 1054 1 (5E15.6) -1 #botm layer 6\n',
' 1055 1 (5E15.6) -1 #botm layer 7\n',
' 1056 1 (5E15.6) -1 #botm layer 8\n',
' 1057 1 (5E15.6) -1 #botm layer 9\n',
' 1058 1 (5E15.6) -1 #botm layer 10\n',
' 1.000000 1 1.000000 TR\n',
' 1.000000 1 1.000000 TR\n']
The .how
attribute
Util2d
includes a .how
attribute that gives finer grained control of how arrays will written
[22]:
ml.lpf.hk[0].how
[22]:
'external'
This will raise an error since our model does not support free format…
[23]:
try:
ml.lpf.hk[0].how = "openclose"
ml.lpf.hk[0].how
ml.write_input()
except Exception as e:
print("\n", e, "\n")
Util2d:delr: resetting 'how' to external
Util2d:delc: resetting 'how' to external
Util2d:model_top: resetting 'how' to external
Util2d:botm layer 1: resetting 'how' to external
Util2d:botm layer 2: resetting 'how' to external
Util2d:botm layer 3: resetting 'how' to external
Util2d:botm layer 4: resetting 'how' to external
Util2d:botm layer 5: resetting 'how' to external
Util2d:botm layer 6: resetting 'how' to external
Util2d:botm layer 7: resetting 'how' to external
Util2d:botm layer 8: resetting 'how' to external
Util2d:botm layer 9: resetting 'how' to external
Util2d:botm layer 10: resetting 'how' to external
Util2d error: 'how' is openclose, but model doesn't support free fmt
So let’s reset hk layer 1 back to external…
[24]:
ml.lpf.hk[0].how = "external"
ml.lpf.hk[0].how
[24]:
'external'
[25]:
ml.dis.top.how = "external"
[26]:
ml.write_input()
Util2d:delr: resetting 'how' to external
Util2d:delc: resetting 'how' to external
Util2d:botm layer 1: resetting 'how' to external
Util2d:botm layer 2: resetting 'how' to external
Util2d:botm layer 3: resetting 'how' to external
Util2d:botm layer 4: resetting 'how' to external
Util2d:botm layer 5: resetting 'how' to external
Util2d:botm layer 6: resetting 'how' to external
Util2d:botm layer 7: resetting 'how' to external
Util2d:botm layer 8: resetting 'how' to external
Util2d:botm layer 9: resetting 'how' to external
Util2d:botm layer 10: resetting 'how' to external
Util2d:ss layer 1: resetting 'how' to external
Util2d:ss layer 2: resetting 'how' to external
Util2d:ss layer 3: resetting 'how' to external
Util2d:ss layer 4: resetting 'how' to external
Util2d:ss layer 5: resetting 'how' to external
Util2d:ss layer 6: resetting 'how' to external
Util2d:ss layer 7: resetting 'how' to external
Util2d:ss layer 8: resetting 'how' to external
Util2d:ss layer 9: resetting 'how' to external
Util2d:ss layer 10: resetting 'how' to external
[27]:
open(os.path.join(ml.model_ws, ml.name + ".dis"), "r").readlines()
[27]:
['# DIS package for MODFLOW-2005 generated by Flopy 3.3.7\n',
' 10 20 5 2 4 2\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 1104 1 (5E15.6) -1 #delr\n',
' 1105 1 (20E15.6) -1 #delc\n',
' 1106 1 (5E15.6) -1 #model_top\n',
' -1107 1 (BINARY) -1 #botm layer 1\n',
' 1108 1 (5E15.6) -1 #botm layer 2\n',
' 1109 1 (5E15.6) -1 #botm layer 3\n',
' 1110 1 (5E15.6) -1 #botm layer 4\n',
' 1111 1 (5E15.6) -1 #botm layer 5\n',
' 1112 1 (5E15.6) -1 #botm layer 6\n',
' 1113 1 (5E15.6) -1 #botm layer 7\n',
' 1114 1 (5E15.6) -1 #botm layer 8\n',
' 1115 1 (5E15.6) -1 #botm layer 9\n',
' 1116 1 (5E15.6) -1 #botm layer 10\n',
' 1.000000 1 1.000000 TR\n',
' 1.000000 1 1.000000 TR\n']
[28]:
open(os.path.join(ml.model_ws, ml.name + ".lpf"), "r").readlines()
[28]:
['# LPF package for MODFLOW-2005 generated by Flopy 3.3.7\n',
' 0 -1E+30 0 \n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00 1.000000E+00\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 0 0 0 0 0 0 0 0 0 0\n',
' 1117 1 (5E15.6) -1 #hk layer 1\n',
' 1118 1 (5E15.6) -1 #vka1\n',
' 1119 1 (5E15.6) -1 #ss layer 1\n',
' 1120 1 (5E15.6) -1 #hk layer 2\n',
' 1121 1 (5E15.6) -1 #vka2\n',
' 1122 1 (5E15.6) -1 #ss layer 2\n',
' 1123 1 (5E15.6) -1 #hk layer 3\n',
' 1124 1 (5E15.6) -1 #vka3\n',
' 1125 1 (5E15.6) -1 #ss layer 3\n',
' 1126 1 (5E15.6) -1 #hk layer 4\n',
' 1127 1 (5E15.6) -1 #vka4\n',
' 1128 1 (5E15.6) -1 #ss layer 4\n',
' 1129 1 (5E15.6) -1 #hk layer 5\n',
' 1130 1 (5E15.6) -1 #vka5\n',
' 1131 1 (5E15.6) -1 #ss layer 5\n',
' 1132 1 (5E15.6) -1 #hk layer 6\n',
' 1133 1 (5E15.6) -1 #vka6\n',
' 1134 1 (5E15.6) -1 #ss layer 6\n',
' 1135 1 (5E15.6) -1 #hk layer 7\n',
' 1136 1 (5E15.6) -1 #vka7\n',
' 1137 1 (5E15.6) -1 #ss layer 7\n',
' 1138 1 (5E15.6) -1 #hk layer 8\n',
' 1139 1 (5E15.6) -1 #vka8\n',
' 1140 1 (5E15.6) -1 #ss layer 8\n',
' 1141 1 (5E15.6) -1 #hk layer 9\n',
' 1142 1 (5E15.6) -1 #vka9\n',
' 1143 1 (5E15.6) -1 #ss layer 9\n',
' 1144 1 (5E15.6) -1 #hk layer 10\n',
' 1145 1 (5E15.6) -1 #vka10\n',
' 1146 1 (5E15.6) -1 #ss layer 10\n']
[29]:
open(os.path.join(ml.model_ws, ml.name + ".nam"), "r").readlines()
[29]:
['# Name file for MODFLOW-2005, generated by Flopy version 3.3.7.\n',
'#xll:0.0; yll:0.0; rotation:0.0; units:meters; lenuni:2; start_datetime:1-1-1970\n',
'LIST 2 modflowtest.list\n',
'DIS 11 modflowtest.dis\n',
'LPF 15 modflowtest.lpf\n',
'RCH 19 modflowtest.rch\n',
'DATA 1104 ref/delr.ref\n',
'DATA 1105 ref/delc.ref\n',
'DATA 1106 ref/model_top.ref\n',
'DATA(BINARY) 1107 ref/botm_layer_1.ref\n',
'DATA 1108 ref/botm_layer_2.ref\n',
'DATA 1109 ref/botm_layer_3.ref\n',
'DATA 1110 ref/botm_layer_4.ref\n',
'DATA 1111 ref/botm_layer_5.ref\n',
'DATA 1112 ref/botm_layer_6.ref\n',
'DATA 1113 ref/botm_layer_7.ref\n',
'DATA 1114 ref/botm_layer_8.ref\n',
'DATA 1115 ref/botm_layer_9.ref\n',
'DATA 1116 ref/botm_layer_10.ref\n',
'DATA 1117 ref/hk_1.ref\n',
'DATA 1118 ref/vka1.ref\n',
'DATA 1119 ref/ss_layer_1.ref\n',
'DATA 1120 ref/hk_2.ref\n',
'DATA 1121 ref/vka2.ref\n',
'DATA 1122 ref/ss_layer_2.ref\n',
'DATA 1123 ref/hk_3.ref\n',
'DATA 1124 ref/vka3.ref\n',
'DATA 1125 ref/ss_layer_3.ref\n',
'DATA 1126 ref/hk_4.ref\n',
'DATA 1127 ref/vka4.ref\n',
'DATA 1128 ref/ss_layer_4.ref\n',
'DATA 1129 ref/hk_5.ref\n',
'DATA 1130 ref/vka5.ref\n',
'DATA 1131 ref/ss_layer_5.ref\n',
'DATA 1132 ref/hk_6.ref\n',
'DATA 1133 ref/vka6.ref\n',
'DATA 1134 ref/ss_layer_6.ref\n',
'DATA 1135 ref/hk_7.ref\n',
'DATA 1136 ref/vka7.ref\n',
'DATA 1137 ref/ss_layer_7.ref\n',
'DATA 1138 ref/hk_8.ref\n',
'DATA 1139 ref/vka8.ref\n',
'DATA 1140 ref/ss_layer_8.ref\n',
'DATA 1141 ref/hk_9.ref\n',
'DATA 1142 ref/vka9.ref\n',
'DATA 1143 ref/ss_layer_9.ref\n',
'DATA 1144 ref/hk_10.ref\n',
'DATA 1145 ref/vka10.ref\n',
'DATA 1146 ref/ss_layer_10.ref\n',
'DATA 1147 ref/rech_0.ref\n',
'DATA 1148 ref/important_recharge.ref\n']
[30]:
try:
# ignore PermissionError on Windows
temp_dir.cleanup()
except:
pass