Note
Accessing MODFLOW 6 Output
This tutorial shows how to access output from MODFLOW 6 models and packages by using the built in .output
attribute on any MODFLOW 6 model or package object
[1]:
import os
from pathlib import Path
from tempfile import TemporaryDirectory
[2]:
import numpy as np
[3]:
# ## Package import
import flopy
Load a simple demonstration model
[4]:
exe_name = "mf6"
[5]:
def get_project_root_path(path=None):
"""
Infers the path to the project root given the path to the current working directory.
The current working location must be somewhere in the project, i.e. below the root.
Parameters
----------
path : the path to the current working directory
Returns
-------
The path to the project root
"""
cwd = Path(path) if path is not None else Path.cwd()
if cwd.name == "autotest":
# we're in top-level autotest folder
return cwd.parent
elif "autotest" in cwd.parts and cwd.parts.index(
"autotest"
) > cwd.parts.index("flopy"):
# we're somewhere inside autotests
parts = cwd.parts[0 : cwd.parts.index("autotest")]
return Path(*parts)
elif "examples" in cwd.parts and cwd.parts.index(
"examples"
) > cwd.parts.index("flopy"):
# we're somewhere inside examples folder
parts = cwd.parts[0 : cwd.parts.index("examples")]
return Path(*parts)
elif cwd.parts.count("flopy") >= 1:
# we're somewhere inside the project or flopy module
tries = [1]
if "CI" in os.environ:
tries.append(2)
for t in tries:
parts = cwd.parts[0 : cwd.parts.index("flopy") + (t)]
pth = Path(*parts)
if (
next(iter([p for p in pth.glob("pyproject.toml")]), None)
is not None
):
return pth
raise Exception(
f"Can't infer location of project root from {cwd}"
f"(run from project root, flopy module, examples, or autotest)"
)
elif cwd.parts.count("flopy") == 1 and cwd.name == "flopy":
# we're in project root
return cwd
else:
raise Exception(
f"Can't infer location of project root from {cwd}"
f"(run from project root, flopy module, examples, or autotest)"
)
[6]:
ws = os.path.abspath(os.path.dirname(""))
sim_ws = str(
get_project_root_path() / "examples" / "data" / "mf6" / "test001e_UZF_3lay"
)
[7]:
# load the model
sim = flopy.mf6.MFSimulation.load(
sim_ws=sim_ws,
exe_name=exe_name,
verbosity_level=0,
)
# change the simulation path, rewrite the files, and run the model
temp_dir = TemporaryDirectory()
sim_ws = temp_dir.name
sim.set_sim_path(sim_ws)
sim.write_simulation(silent=True)
sim.run_simulation(silent=True)
[7]:
(True, [])
Get output using the .output
attribute
The output attribute dynamically generates methods for each package based on the available output options within that package. A list of all available outputs are:
head() |
Method to get the |
budget() |
Method to get the |
budgetcsv() |
Method to get the MODFLOW-6 budget csv as a |
zonebudget() |
Method to get the |
obs() |
Method to get observation file data in the form of a |
csv() |
Method to get csv output data in the form of a |
package_convergence() |
Method to get csv based package convergence information from packages such as SFR, LAK, UZF, and MAW. Returns a |
stage() |
Method to get binary stage file output from the SFR and LAK packages |
concentration() |
Method to get the binary concentration file output from a groundwater transport model. Accessed from the model object or the OC package object |
cim() |
Method to get immobile concentration output from the CIM package |
density() |
Method to get density file output from the BUY package |
Get head file and cell budget file outputs
The head file output and cell budget file output can be loaded from either the model object or the OC package object.
[8]:
ml = sim.get_model("gwf_1")
[9]:
bud = ml.output.budget()
bud.get_data(idx=0, full3D=True)
[9]:
[array([[[ 0., 0., 0., 0., -0., 0., 0., 0., -0., 0., 0., 0.,
-0., 0., 0., 0., -0., 0., 0., 0., -0., 0., 0., 0.,
-0., 0., 0., 0., -0., 0., 0., 0., -0., 0., 0., 0.,
-0., 0., 0., -0., 0., 0., 0., -0., -0., 0., 0., 0.,
-0., -0., 0., 0., 0., -0., -0., 0., 0., 0., -0., -0.,
0., 0., 0., -0., -0., 0., 0., 0., -0., -0., 0., 0.,
0., -0., -0., 0., 0., 0., -0., -0., 0., 0., 0., -0.,
-0., 0., 0., -0., 0., 0., -0., -0., 0., 0., -0., -0.,
0., 0., -0., -0., 0., 0., -0., -0., 0., 0., -0., -0.,
0., 0., -0., -0., 0., 0., -0., -0., 0., 0., -0., -0.,
0., 0., -0., -0.]]])]
[10]:
budcsv = ml.output.budgetcsv()
budcsv.data
[10]:
rec.array([(2.00e+00, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.00e+00, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(6.00e+00, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(8.00e+00, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.00e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.20e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.40e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.60e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.80e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.00e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.20e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.40e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.60e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.80e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.00e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.20e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.40e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.60e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.80e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.00e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.20e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.40e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.60e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.80e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.00e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.20e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.40e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.60e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.80e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(6.00e+01, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.10e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.10e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(2.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.10e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(3.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.10e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(4.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.10e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(5.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(6.00e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(6.40e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(6.80e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(7.20e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(7.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(8.00e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(8.40e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(8.80e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(9.20e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(9.60e+02, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.00e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.04e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.08e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.12e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.16e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.20e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.24e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.28e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.32e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.36e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.40e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.44e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.48e+03, 0.00000000e+00, 0. , 0., 0. , 0., 0., 0. , 0. , 0. , 0., 0., 0., 0. , 0. , 0.00000000e+00),
(1.52e+03, 0.00000000e+00, 0. , 0., 128.0217841 , 0., 0., 0.02722978, 108.61508013, 19.37931792, 0., 0., 0., 128.0217841 , 128.02162783, 1.22061576e-04),
(1.56e+03, 0.00000000e+00, 0. , 0., 138.99381474, 0., 0., 0.02616677, 103.79225125, 35.17524461, 0., 0., 0., 138.99381474, 138.99366263, 1.09439391e-04),
(1.60e+03, 0.00000000e+00, 0. , 0., 136.4972012 , 0., 0., 0.0225728 , 89.06987566, 47.4046209 , 0., 0., 0., 136.4972012 , 136.49706937, 9.65814295e-05),
(1.64e+03, 0.00000000e+00, 0. , 0., 134.35958704, 0., 0., 0.01957412, 76.88688611, 57.45301299, 0., 0., 0., 134.35958704, 134.35947321, 8.47152128e-05),
(1.68e+03, 0.00000000e+00, 0. , 0., 131.24481479, 0., 0., 0.01672315, 65.43186869, 65.79613475, 0., 0., 0., 131.24481479, 131.24472659, 6.72047136e-05),
(1.72e+03, 0.00000000e+00, 0. , 0., 123.13434058, 0., 0., 0.01312794, 51.19484895, 71.92589496, 0., 0., 0., 123.13434058, 123.13387185, 3.80661214e-04),
(1.76e+03, 0.00000000e+00, 0. , 0., 114.00353442, 0., 0., 0.0097074 , 37.75854966, 76.23496189, 0., 0., 0., 114.00353442, 114.00321895, 2.76719717e-04),
(1.80e+03, 0.00000000e+00, 0. , 0., 110.11487407, 0., 0., 0.0078339 , 30.41322044, 79.693573 , 0., 0., 0., 110.11487407, 110.11462734, 2.24068325e-04),
(1.84e+03, 0.00000000e+00, 0. , 0., 105.40602911, 0., 0., 0.00594997, 23.06535254, 82.33456504, 0., 0., 0., 105.40602911, 105.40586755, 1.53273477e-04),
(1.88e+03, 0.00000000e+00, 0. , 0., 95.08914871, 0., 0., 0.00307764, 11.90628617, 83.17970019, 0., 0., 0., 95.08914871, 95.089064 , 8.90844871e-05),
(1.92e+03, 0.00000000e+00, 0. , 0., 94.69475504, 0., 0., 0.00271043, 10.48542653, 84.20654512, 0., 0., 0., 94.69475504, 94.69468209, 7.70440756e-05),
(1.96e+03, 0.00000000e+00, 0. , 0., 89.77312957, 0., 0., 0.00134165, 5.18451079, 84.58703172, 0., 0., 0., 89.77312957, 89.77288416, 2.73360282e-04),
(2.00e+03, 3.28550762e-05, 0.12927097, 0., 85.77949492, 0., 0., 0.00037754, 1.45488492, 84.45346195, 0., 0., 0., 85.90879875, 85.90872441, 8.65285791e-05),
(2.04e+03, 1.11673220e-03, 4.33428447, 0., 79.06662935, 0., 0., 0. , 0. , 83.40218928, 0., 0., 0., 83.40203055, 83.40218928, -1.90324298e-04),
(2.08e+03, 9.50436281e-04, 3.6847171 , 0., 79.01606345, 0., 0., 0. , 0. , 82.70187216, 0., 0., 0., 82.70173099, 82.70187216, -1.70697486e-04),
(2.12e+03, 8.09420799e-04, 3.13589527, 0., 79.07017251, 0., 0., 0. , 0. , 82.20700075, 0., 0., 0., 82.2068772 , 82.20700075, -1.50282359e-04),
(2.16e+03, 1.74634716e-03, 6.76514808, 0., 74.44436606, 0., 0., 0. , 0. , 81.21149171, 0., 0., 0., 81.21126049, 81.21149171, -2.84711568e-04),
(2.20e+03, 2.91726961e-03, 11.31295605, 0., 67.97128273, 0., 0., 0. , 0. , 79.28753204, 0., 0., 0., 79.28715604, 79.28753204, -4.74219376e-04),
(2.24e+03, 3.18846934e-03, 12.36643397, 0., 65.05084871, 0., 0., 0. , 0. , 77.42085884, 0., 0., 0., 77.42047115, 77.42085884, -5.00756338e-04),
(2.28e+03, 3.08245610e-03, 11.96212155, 0., 63.67724795, 0., 0., 0. , 0. , 75.64282768, 0., 0., 0., 75.64245196, 75.64282768, -4.96712518e-04),
(2.32e+03, 2.66394411e-03, 10.34112384, 0., 63.8844137 , 0., 0., 0. , 0. , 74.22852942, 0., 0., 0., 74.22820148, 74.22852942, -4.41794671e-04),
(2.36e+03, 2.31518433e-03, 8.99067397, 0., 64.05458652, 0., 0., 0. , 0. , 73.04786211, 0., 0., 0., 73.04757567, 73.04786211, -3.92124078e-04),
(2.40e+03, 2.17404830e-03, 8.44571365, 0., 63.52276663, 0., 0., 0. , 0. , 71.97090718, 0., 0., 0., 71.97065433, 71.97090718, -3.51328184e-04),
(2.44e+03, 2.81993508e-03, 10.96537535, 0., 59.39318153, 0., 0., 0. , 0. , 70.36169271, 0., 0., 0., 70.36137682, 70.36169271, -4.48957261e-04),
(2.48e+03, 2.99544059e-03, 11.65308129, 0., 57.07292771, 0., 0., 0. , 0. , 68.72930656, 0., 0., 0., 68.72900444, 68.72930656, -4.39583720e-04),
(2.52e+03, 4.00001313e-03, 15.57599202, 0., 50.80019371, 0., 0., 0. , 0. , 66.38055059, 0., 0., 0., 66.38018574, 66.38055059, -5.49633887e-04),
(2.56e+03, 3.81480656e-03, 14.86546946, 0., 49.32928447, 0., 0., 0. , 0. , 64.19891797, 0., 0., 0., 64.19856873, 64.19891797, -5.43997899e-04)],
dtype=[('totim', '<f8'), ('STO-SS(STORAGE)_IN', '<f8'), ('STO-SY(STORAGE)_IN', '<f8'), ('CHD(CHD-1)_IN', '<f8'), ('UZF-GWRCH(UZF-1)_IN', '<f8'), ('UZF-GWD(UZF-1)_IN', '<f8'), ('UZF-GWET(UZF-1)_IN', '<f8'), ('STO-SS(STORAGE)_OUT', '<f8'), ('STO-SY(STORAGE)_OUT', '<f8'), ('CHD(CHD-1)_OUT', '<f8'), ('UZF-GWRCH(UZF-1)_OUT', '<f8'), ('UZF-GWD(UZF-1)_OUT', '<f8'), ('UZF-GWET(UZF-1)_OUT', '<f8'), ('TOTAL_IN', '<f8'), ('TOTAL_OUT', '<f8'), ('PERCENT_DIFFERENCE', '<f8')])
[11]:
hds = ml.output.head()
hds.get_data()
[11]:
array([[[-25. , -24.93660487, -24.88816332, -24.85548043,
-24.83902108, -24.83902108, -24.85548043, -24.88816332,
-24.93660487, -25. ]],
[[-25. , -24.93660487, -24.88816332, -24.85548043,
-24.83902108, -24.83902108, -24.85548043, -24.88816332,
-24.93660487, -25. ]],
[[-25. , -24.93660487, -24.88816332, -24.85548043,
-24.83902108, -24.83902108, -24.85548043, -24.88816332,
-24.93660487, -25. ]]])
[12]:
bud = ml.oc.output.budget()
bud.get_data(idx=0, full3D=True)
[12]:
[array([[[ 0., 0., 0., 0., -0., 0., 0., 0., -0., 0., 0., 0.,
-0., 0., 0., 0., -0., 0., 0., 0., -0., 0., 0., 0.,
-0., 0., 0., 0., -0., 0., 0., 0., -0., 0., 0., 0.,
-0., 0., 0., -0., 0., 0., 0., -0., -0., 0., 0., 0.,
-0., -0., 0., 0., 0., -0., -0., 0., 0., 0., -0., -0.,
0., 0., 0., -0., -0., 0., 0., 0., -0., -0., 0., 0.,
0., -0., -0., 0., 0., 0., -0., -0., 0., 0., 0., -0.,
-0., 0., 0., -0., 0., 0., -0., -0., 0., 0., -0., -0.,
0., 0., -0., -0., 0., 0., -0., -0., 0., 0., -0., -0.,
0., 0., -0., -0., 0., 0., -0., -0., 0., 0., -0., -0.,
0., 0., -0., -0.]]])]
[13]:
hds = ml.oc.output.head()
hds.get_data()
[13]:
array([[[-25. , -24.93660487, -24.88816332, -24.85548043,
-24.83902108, -24.83902108, -24.85548043, -24.88816332,
-24.93660487, -25. ]],
[[-25. , -24.93660487, -24.88816332, -24.85548043,
-24.83902108, -24.83902108, -24.85548043, -24.88816332,
-24.93660487, -25. ]],
[[-25. , -24.93660487, -24.88816332, -24.85548043,
-24.83902108, -24.83902108, -24.85548043, -24.88816332,
-24.93660487, -25. ]]])
Get output associated with a specific package
The .output
attribute is tied to the package object and allows the user to get the output types specified in the MODFLOW 6 package. Here is an example with a UZF package that has UZF budget file output, budgetcsv file output, package convergence output, and observation data.
[14]:
uzf = ml.uzf
uzf_bud = uzf.output.budget()
uzf_bud.get_data(idx=0)
[14]:
[rec.array([( 1, 9, 0., 100000.), ( 9, 1, -0., 100000.),
( 2, 10, 0., 100000.), (10, 2, -0., 100000.),
( 3, 11, 0., 100000.), (11, 3, -0., 100000.),
( 4, 12, 0., 100000.), (12, 4, -0., 100000.),
( 5, 13, 0., 100000.), (13, 5, -0., 100000.),
( 6, 14, 0., 100000.), (14, 6, -0., 100000.),
( 7, 15, 0., 100000.), (15, 7, -0., 100000.),
( 8, 16, 0., 100000.), (16, 8, -0., 100000.),
( 9, 17, 0., 100000.), (17, 9, -0., 100000.),
(10, 18, 0., 100000.), (18, 10, -0., 100000.),
(11, 19, 0., 100000.), (19, 11, -0., 100000.),
(12, 20, 0., 100000.), (20, 12, -0., 100000.),
(13, 21, 0., 100000.), (21, 13, -0., 100000.),
(14, 22, 0., 100000.), (22, 14, -0., 100000.),
(15, 23, 0., 100000.), (23, 15, -0., 100000.),
(16, 24, 0., 100000.), (24, 16, -0., 100000.)],
dtype=[('node', '<i4'), ('node2', '<i4'), ('q', '<f8'), ('FLOW-AREA', '<f8')])]
[15]:
uzf_budcsv = uzf.output.budgetcsv()
uzf_budcsv.data
[15]:
rec.array([(2.00e+00, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.01124365, 7999.98875635, 8000. , 8000. , 3.41060513e-14),
(4.00e+00, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.02248729, 7999.97751271, 8000. , 8000. , -2.27373675e-14),
(6.00e+00, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.03373091, 7999.96626909, 8000. , 8000. , 6.82121026e-14),
(8.00e+00, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.04497452, 7999.95502458, 8000. , 7999.9999991 , 1.12417183e-08),
(1.00e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.10119265, 7999.89880735, 8000. , 8000. , 1.13686838e-13),
(1.20e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.15741054, 7999.84258946, 8000. , 8000. , -1.13686838e-14),
(1.40e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.21362819, 7999.78637181, 8000. , 8000. , 6.82121026e-14),
(1.60e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.26984561, 7999.73015439, 8000. , 8000. , -5.68434189e-14),
(1.80e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.32606279, 7999.67393721, 8000. , 8000. , -2.38742359e-13),
(2.00e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.38227973, 7999.61772027, 8000. , 8000. , 6.82121026e-14),
(2.20e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.43849643, 7999.56150357, 8000. , 8000. , 2.04636308e-13),
(2.40e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.13492205, 7999.86507795, 8000. , 8000. , -9.09494702e-14),
(2.60e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.19113979, 7999.80886021, 8000. , 8000. , -3.63797881e-13),
(2.80e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.2473573 , 7999.7526427 , 8000. , 8000. , 4.66116035e-13),
(3.00e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.3035747 , 7999.6964253 , 8000. , 8000. , -9.09494702e-14),
(3.20e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.35979212, 7999.64020788, 8000. , 8000. , -7.95807864e-14),
(3.40e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.4160093 , 7999.5839907 , 8000. , 8000. , -9.09494702e-14),
(3.60e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.47222624, 7999.52777376, 8000. , 8000. , -7.95807864e-14),
(3.80e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.52844295, 7999.47155705, 8000. , 8000. , -9.09494702e-14),
(4.00e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.22486856, 7999.77513144, 8000. , 8000. , 7.27595761e-13),
(4.20e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.28108631, 7999.71891369, 8000. , 8000. , 2.04636308e-13),
(4.40e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.33475407, 7999.66524593, 8000. , 8000. , -1.02318154e-13),
(4.60e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.38480503, 7999.61519497, 8000. , 8000. , -5.11590770e-13),
(4.80e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.43407536, 7999.56558735, 8000. , 7999.99966271, 4.21615857e-06),
(5.00e+01, 0., 8000., 0., 0., 1.18939114e-01, 0. , 0., 0., 0.48208139, 7999.63685772, 8000.11893911, 8000.11893911, 4.54740590e-13),
(5.20e+01, 0., 8000., 0., 0., 2.40000000e-01, 0. , 0., 0., 0.62375028, 7999.61624972, 8000.24 , 8000.24 , 4.54733709e-14),
(5.40e+01, 0., 8000., 0., 0., 2.40000000e-01, 0. , 0., 0., 0.64056589, 7999.59943411, 8000.24 , 8000.24 , -1.13683427e-13),
(5.60e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.32744504, 7999.67255496, 8000. , 8000. , -2.16004992e-13),
(5.80e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.36195984, 7999.63804016, 8000. , 8000. , 1.93267624e-13),
(6.00e+01, 0., 8000., 0., 0., 0.00000000e+00, 0. , 0., 0., 0.39268212, 7999.60731788, 8000. , 8000. , 4.66116035e-13),
(1.10e+02, 0., 0., 0., 0., 3.78724873e+03, 0. , 0., 0., 0.41882422, 3786.82970478, 3787.24873018, 3787.24852899, 5.31225330e-06),
(1.60e+02, 0., 0., 0., 0., 6.28239222e+02, 0. , 0., 0., 0.51502761, 627.69903841, 628.23922183, 628.21406602, 4.00425715e-03),
(2.10e+02, 0., 0., 0., 0., 3.79980452e+02, 0. , 0., 0., 0.56814228, 379.36208201, 379.98045151, 379.9302243 , 1.32192414e-02),
(2.60e+02, 0., 0., 0., 0., 1.22681840e+02, 0. , 0., 0., 0.60336166, 122.00319618, 122.68183971, 122.60655784, 6.13823347e-02),
(3.10e+02, 0., 0., 0., 0., 1.22634110e+02, 0. , 0., 0., 0.58736429, 121.9464052 , 122.63410992, 122.53376948, 8.18544694e-02),
(3.60e+02, 0., 0., 0., 0., 1.22586380e+02, 0. , 0., 0., 0.58904253, 121.8719518 , 122.58638012, 122.46099433, 1.02335961e-01),
(4.10e+02, 0., 0., 0., 0., 1.22538650e+02, 0. , 0., 0., 0.57596753, 121.81226742, 122.53865033, 122.38823496, 1.22824712e-01),
(4.60e+02, 0., 0., 0., 0., 1.22490921e+02, 0. , 0., 0., 0.56435326, 121.75113567, 122.49092053, 122.31548892, 1.43322724e-01),
(5.10e+02, 0., 0., 0., 0., 1.22443191e+02, 0. , 0., 0., 0.55419916, 121.68855904, 122.44319073, 122.2427582 , 1.63828398e-01),
(5.60e+02, 0., 0., 0., 0., 1.22395461e+02, 0. , 0., 0., 0.56040475, 121.60963737, 122.39546094, 122.17004212, 1.84342282e-01),
(6.00e+02, 0., 0., 0., 0., 1.74018709e+01, 0. , 0., 0., 0.55999969, 16.82414951, 17.4018709 , 17.3841492 , 1.01889790e-01),
(6.40e+02, 0., 0., 0., 0., 1.51944083e+02, 0. , 0., 0., 0.55144142, 151.39263928, 151.94408282, 151.9440807 , 1.39256758e-06),
(6.80e+02, 0., 0., 0., 0., 2.72064073e+02, 0. , 0., 0., 0.54288289, 271.52105105, 272.06407257, 272.06393394, 5.09554104e-05),
(7.20e+02, 0., 0., 0., 0., 2.43435052e+02, 0. , 0., 0., 0.53432434, 242.90043095, 243.43505167, 243.43475529, 1.21747747e-04),
(7.60e+02, 0., 0., 0., 0., 2.24436380e+02, 0. , 0., 0., 0.52576579, 223.91019007, 224.43638039, 224.43595586, 1.89152075e-04),
(8.00e+02, 0., 0., 0., 0., 1.92144820e+02, 0. , 0., 0., 0.51720724, 191.62706411, 192.14481959, 192.14427135, 2.85328186e-04),
(8.40e+02, 0., 0., 0., 0., 1.89295138e+02, 0. , 0., 0., 0.50864868, 188.7858185 , 189.29513782, 189.29446718, 3.54282046e-04),
(8.80e+02, 0., 0., 0., 0., 1.59711534e+02, 0. , 0., 0., 0.50009013, 159.2106566 , 159.71153439, 159.71074673, 4.93175545e-04),
(9.20e+02, 0., 0., 0., 0., 1.54912199e+02, 0. , 0., 0., 0.49153158, 154.41976469, 154.91219927, 154.91129626, 5.82916597e-04),
(9.60e+02, 0., 0., 0., 0., 1.53348712e+02, 0. , 0., 0., 0.48297303, 152.8647234 , 153.34871173, 153.34769643, 6.62088144e-04),
(1.00e+03, 0., 0., 0., 0., 1.22470337e+02, 0. , 0., 0., 0.47441447, 121.99480078, 122.47033704, 122.46921525, 9.15973800e-04),
(1.04e+03, 0., 0., 0., 0., 1.22428683e+02, 0. , 0., 0., 0.46585592, 121.9616002 , 122.42868329, 122.42745612, 1.00236285e-03),
(1.08e+03, 0., 0., 0., 0., 1.22381264e+02, 0. , 0., 0., 0.45729737, 121.92263707, 122.38126375, 122.37993444, 1.08621048e-03),
(1.12e+03, 0., 0., 0., 0., 1.22333850e+02, 0. , 0., 0., 0.44873881, 121.88368331, 122.33385014, 122.33242212, 1.16731720e-03),
(1.16e+03, 0., 0., 0., 0., 1.22274162e+02, 0. , 0., 0., 0.44018026, 121.83245857, 122.27416212, 122.27263883, 1.24580486e-03),
(1.20e+03, 0., 0., 0., 0., 1.22222909e+02, 0. , 0., 0., 0.43162171, 121.78967189, 122.22290873, 122.2212936 , 1.32147141e-03),
(1.24e+03, 0., 0., 0., 0., 1.22175517e+02, 0. , 0., 0., 0.42306316, 121.75075005, 122.17551675, 122.17381321, 1.39435034e-03),
(1.28e+03, 0., 0., 0., 0., 1.22128131e+02, 0. , 0., 0., 0.4145046 , 121.71183756, 122.12813069, 122.12634217, 1.46447817e-03),
(1.32e+03, 0., 0., 0., 0., 1.22080751e+02, 0. , 0., 0., 0.40594605, 121.67293442, 122.08075056, 122.07888047, 1.53185243e-03),
(1.36e+03, 0., 0., 0., 0., 1.22022484e+02, 0. , 0., 0., 0.3973875 , 121.62314831, 122.02248402, 122.0205358 , 1.59661237e-03),
(1.40e+03, 0., 0., 0., 0., 1.21761590e+02, 0. , 0., 0., 0.38882895, 121.3707379 , 121.76158975, 121.75956685, 1.66137130e-03),
(1.44e+03, 0., 0., 0., 0., 1.15127548e+02, 0. , 0., 0., 0.38027039, 114.74518428, 115.1275483 , 115.12545468, 1.81853759e-03),
(1.48e+03, 0., 0., 0., 0., 1.06834995e+02, 0. , 0., 0., 0.37171184, 106.46112218, 106.83499475, 106.83283402, 2.02250892e-03),
(1.52e+03, 0., 0., 0., 0., 1.28387162e+02, 128.0217841 , 0., 0., 0.36315329, 0. , 128.3871623 , 128.38493739, 1.73299045e-03),
(1.56e+03, 0., 0., 0., 0., 1.39350694e+02, 138.99381474, 0., 0., 0.35459473, 0. , 139.35069441, 139.34840947, 1.63971258e-03),
(1.60e+03, 0., 0., 0., 0., 1.36845580e+02, 136.4972012 , 0., 0., 0.34603618, 0. , 136.84557981, 136.84323738, 1.71174694e-03),
(1.64e+03, 0., 0., 0., 0., 1.34699461e+02, 134.35958704, 0., 0., 0.33747763, 0. , 134.69946073, 134.69706466, 1.77884019e-03),
(1.68e+03, 0., 0., 0., 0., 1.31576180e+02, 131.24481479, 0., 0., 0.32891908, 0. , 131.57617996, 131.57373387, 1.85908572e-03),
(1.72e+03, 0., 0., 0., 0., 1.23457194e+02, 123.13434058, 0., 0., 0.32036052, 0. , 123.45719445, 123.4547011 , 2.01962857e-03),
(1.76e+03, 0., 0., 0., 0., 1.14317874e+02, 114.00353442, 0., 0., 0.31180197, 0. , 114.31787365, 114.31533639, 2.21950275e-03),
(1.80e+03, 0., 0., 0., 0., 1.10420694e+02, 110.11487407, 0., 0., 0.30324342, 0. , 110.42069432, 110.41811749, 2.33367700e-03),
(1.84e+03, 0., 0., 0., 0., 1.05703327e+02, 105.40602911, 0., 0., 0.29468487, 0. , 105.7033274 , 105.70071398, 2.47244563e-03),
(1.88e+03, 0., 0., 0., 0., 9.53779221e+01, 95.08914871, 0., 0., 0.28612631, 0. , 95.37792207, 95.37527503, 2.77535835e-03),
(1.92e+03, 0., 0., 0., 0., 9.49750001e+01, 94.69475504, 0., 0., 0.27756776, 0. , 94.97500009, 94.9723228 , 2.81897970e-03),
(1.96e+03, 0., 0., 0., 0., 9.00448429e+01, 89.77312957, 0., 0., 0.26900921, 0. , 90.0448429 , 90.04213878, 3.00312769e-03),
(2.00e+03, 0., 0., 0., 0., 8.60426727e+01, 85.77949492, 0., 0., 0.26045065, 0. , 86.04267268, 86.03994557, 3.16952968e-03),
(2.04e+03, 0., 0., 0., 0., 7.93212676e+01, 79.06662935, 0., 0., 0.2518921 , 0. , 79.3212676 , 79.31852145, 3.46212104e-03),
(2.08e+03, 0., 0., 0., 0., 7.92621596e+01, 79.01606345, 0., 0., 0.24333355, 0. , 79.26215964, 79.259397 , 3.48550200e-03),
(2.12e+03, 0., 0., 0., 0., 7.93077233e+01, 79.07017251, 0., 0., 0.234775 , 0. , 79.30772334, 79.30494751, 3.50012862e-03),
(2.16e+03, 0., 0., 0., 0., 7.46733681e+01, 74.44436606, 0., 0., 0.22621644, 0. , 74.67336811, 74.67058251, 3.73045242e-03),
(2.20e+03, 0., 0., 0., 0., 6.81917326e+01, 67.97128273, 0., 0., 0.21765789, 0. , 68.19173259, 68.18894062, 4.09438250e-03),
(2.24e+03, 0., 0., 0., 0., 6.52627430e+01, 65.05084871, 0., 0., 0.20909934, 0. , 65.26274298, 65.25994805, 4.28268329e-03),
(2.28e+03, 0., 0., 0., 0., 6.38805832e+01, 63.67724795, 0., 0., 0.20054079, 0. , 63.88058323, 63.87778874, 4.37465570e-03),
(2.32e+03, 0., 0., 0., 0., 6.40791861e+01, 63.8844137 , 0., 0., 0.19198223, 0. , 64.07918605, 64.07639593, 4.35427472e-03),
(2.36e+03, 0., 0., 0., 0., 6.42407922e+01, 64.05458652, 0., 0., 0.18342368, 0. , 64.2407922 , 64.2380102 , 4.33067676e-03),
(2.40e+03, 0., 0., 0., 0., 6.37004030e+01, 63.52276663, 0., 0., 0.17486513, 0. , 63.70040299, 63.69763176, 4.35050707e-03),
(2.44e+03, 0., 0., 0., 0., 5.95622453e+01, 59.39318153, 0., 0., 0.16630658, 0. , 59.56224528, 59.55948811, 4.62916709e-03),
(2.48e+03, 0., 0., 0., 0., 5.72334154e+01, 57.07292771, 0., 0., 0.15774802, 0. , 57.23341545, 57.23067573, 4.78702424e-03),
(2.52e+03, 0., 0., 0., 0., 5.09521020e+01, 50.80019371, 0., 0., 0.14918947, 0. , 50.95210203, 50.94938318, 5.33623414e-03),
(2.56e+03, 0., 0., 0., 0., 4.94726100e+01, 49.32928447, 0., 0., 0.14063092, 0. , 49.47260998, 49.46991539, 5.44677831e-03)],
dtype=[('totim', '<f8'), ('GWF_IN', '<f8'), ('INFILTRATION_IN', '<f8'), ('REJ-INF_IN', '<f8'), ('UZET_IN', '<f8'), ('STORAGE_IN', '<f8'), ('GWF_OUT', '<f8'), ('INFILTRATION_OUT', '<f8'), ('REJ-INF_OUT', '<f8'), ('UZET_OUT', '<f8'), ('STORAGE_OUT', '<f8'), ('TOTAL_IN', '<f8'), ('TOTAL_OUT', '<f8'), ('PERCENT_DIFFERENCE', '<f8')])
[16]:
uzf_conv = uzf.output.package_convergence()
if uzf_conv is not None:
uzf_conv.data[0:10]
[17]:
uzf_obs = uzf.output.obs()
uzf_obs.data[0:10]
[17]:
rec.array([( 2., 0.05, 0.05, 0.), ( 4., 0.05, 0.05, 0.),
( 6., 0.05, 0.05, 0.), ( 8., 0.05, 0.05, 0.),
(10., 0.05, 0.05, 0.), (12., 0.05, 0.05, 0.),
(14., 0.05, 0.05, 0.), (16., 0.05, 0.05, 0.),
(18., 0.05, 0.05, 0.), (20., 0.05, 0.05, 0.)],
dtype=[('totim', '<f8'), ('ID3_DPTH=8.0', '<f8'), ('ID3_DPTH=24.0', '<f8'), ('ID3_RCH', '<f8')])
Check which output types are available in a package
The .output
attribute also has a methods()
function that returns a list of available output functions for a given package. Here are a couple of examples
[18]:
print("UZF package: ", uzf.output.methods())
print("Model object: ", ml.output.methods())
print("OC package: ", ml.oc.output.methods())
print("DIS package: ", ml.dis.output.methods())
UZF package: ['zonebudget()', 'budget()', 'budgetcsv()', 'package_convergence()', 'obs()']
Model object: ['list()', 'zonebudget()', 'budget()', 'budgetcsv()', 'head()']
OC package: ['list()', 'zonebudget()', 'budget()', 'budgetcsv()', 'head()']
DIS package: None
Managing multiple observation and csv file outputs in the same package
For many packages, multiple observation output files can be used. The obs()
and csv()
functions allow the user to specify a observation file or csv file name. If no name is specified, the obs()
and csv()
methods will return the first file that is listed in the package.
[19]:
output = ml.obs[0].output
obs_names = output.obs_names
output.obs(f=obs_names[0]).data[0:10]
[19]:
rec.array([( 2., 0.05, 0.05, 0.), ( 4., 0.05, 0.05, 0.),
( 6., 0.05, 0.05, 0.), ( 8., 0.05, 0.05, 0.),
(10., 0.05, 0.05, 0.), (12., 0.05, 0.05, 0.),
(14., 0.05, 0.05, 0.), (16., 0.05, 0.05, 0.),
(18., 0.05, 0.05, 0.), (20., 0.05, 0.05, 0.)],
dtype=[('totim', '<f8'), ('ID3_DPTH=8.0', '<f8'), ('ID3_DPTH=24.0', '<f8'), ('ID3_RCH', '<f8')])
Creating and running ZoneBudget for MF6
For the model and many packages, zonebudget can be run on the cell budget file. The .output
method allows the user to easily build a ZoneBudget6 instance, then run the model, and view output. First we’ll build a layered zone array, then build and run zonebudget
[20]:
zarr = np.ones(ml.modelgrid.shape, dtype=int)
for i in range(1, 4):
zarr[i - 1] *= i
[21]:
zonbud = ml.output.zonebudget(zarr)
zonbud.change_model_ws(sim_ws)
zonbud.write_input()
zonbud.run_model()
FloPy is using the following executable to run the model: ../../home/runner/.local/bin/modflow/zbud6
ZONEBUDGET Version 6
U.S. GEOLOGICAL SURVEY
VERSION 6.4.1 Release 12/09/2022
...........................................................................................
Normal Termination
[21]:
(True, [])
[22]:
df = zonbud.get_dataframes(net=True)
df = df.reset_index()
df
[22]:
totim | name | ZONE_1 | ZONE_2 | ZONE_3 | |
---|---|---|---|---|---|
0 | 2.0 | ZONE_0 | 0.0 | 0.000000e+00 | 0.000000e+00 |
1 | 2.0 | ZONE_1 | 0.0 | 0.000000e+00 | 0.000000e+00 |
2 | 2.0 | ZONE_2 | 0.0 | 0.000000e+00 | 0.000000e+00 |
3 | 2.0 | ZONE_3 | 0.0 | 0.000000e+00 | 0.000000e+00 |
4 | 4.0 | ZONE_0 | 0.0 | 0.000000e+00 | 0.000000e+00 |
... | ... | ... | ... | ... | ... |
355 | 2520.0 | ZONE_3 | 0.0 | 0.000000e+00 | 0.000000e+00 |
356 | 2560.0 | ZONE_0 | 0.0 | 0.000000e+00 | 0.000000e+00 |
357 | 2560.0 | ZONE_1 | 0.0 | 0.000000e+00 | 0.000000e+00 |
358 | 2560.0 | ZONE_2 | 0.0 | 0.000000e+00 | -5.684342e-10 |
359 | 2560.0 | ZONE_3 | 0.0 | 5.684342e-10 | 0.000000e+00 |
360 rows × 5 columns
[23]:
try:
temp_dir.cleanup()
except:
# prevent windows permission error
pass