Skip to content

Commit

Permalink
export_vtk_tutorial.py, mf_load_tutorial.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 12, 2024
1 parent 93a3d61 commit b83b1d0
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 5 deletions.
36 changes: 33 additions & 3 deletions .docs/Notebooks/export_vtk_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
from pprint import pformat
from tempfile import TemporaryDirectory

import git
import numpy as np
import pooch

import flopy
from flopy.export import vtk
Expand All @@ -42,11 +44,39 @@
print(f"flopy version: {flopy.__version__}")
# -

try:
root = Path(git.Repo(".", search_parent_directories=True).working_dir)
except:
root = None

data_path = root / "examples" / "data" if root else Path.cwd()
sim_name = "freyberg_multilayer_transient"
file_names = {
"freyberg.bas": None,
"freyberg.cbc": None,
"freyberg.ddn": None,
"freyberg.dis": None,
"freyberg.drn": None,
"freyberg.hds": None,
"freyberg.list": None,
"freyberg.nam": None,
"freyberg.nwt": None,
"freyberg.oc": None,
"freyberg.rch": None,
"freyberg.upw": None,
"freyberg.wel": None,
}
for fname, fhash in file_names.items():
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/{sim_name}/{fname}",
fname=fname,
path=data_path / sim_name,
known_hash=fhash,
)

# load model for examples
nam_file = "freyberg.nam"
model_ws = Path(
os.path.join("..", "..", "examples", "data", "freyberg_multilayer_transient")
)
model_ws = data_path / sim_name
ml = flopy.modflow.Modflow.load(nam_file, model_ws=model_ws, check=False)

# Create a temporary workspace.
Expand Down
58 changes: 56 additions & 2 deletions .docs/Notebooks/mf_load_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,25 @@
# +
import os
import sys
from pathlib import Path

import git
import pooch

import flopy

print(sys.version)
print(f"flopy version: {flopy.__version__}")
# -

try:
root = Path(git.Repo(".", search_parent_directories=True).working_dir)
except:
root = None

data_path = root / "examples" / "data" if root else Path.cwd()


# ## The `load()` method
#
# To load a MODFLOW 2005 model, use the `Modflow.load()` method. The method's first argument is the path or name of the model namefile. Other parameters include:
Expand All @@ -38,7 +50,25 @@
# - `verbose`: whether to write diagnostic information useful for troubleshooting
# - `check`: whether to check for model configuration errors

model_ws = os.path.join("..", "..", "examples", "data", "mf2005_test")
file_names = [
"bcf2ss.ba6",
"bcf2ss.bc6",
"bcf2ss.dis",
"bcf2ss.nam",
"bcf2ss.oc",
"bcf2ss.pcg",
"bcf2ss.rch",
"bcf2ss.riv",
"bcf2ss.wel",
]
for fname in file_names:
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mf2005_test/{fname}",
fname=fname,
path=data_path / "mf2005_test",
known_hash=None,
)
model_ws = data_path / "mf2005_test"
ml = flopy.modflow.Modflow.load(
"bcf2ss.nam",
model_ws=model_ws,
Expand All @@ -51,7 +81,31 @@
#
# Below we load a model containig auxiliary variables, then access them.

model_ws = os.path.join("..", "..", "examples", "data", "mp6")
file_names = [
"EXAMPLE.BA6",
"EXAMPLE.BUD",
"EXAMPLE.DIS",
"EXAMPLE.DIS.metadata",
"EXAMPLE.HED",
"EXAMPLE.LPF",
"EXAMPLE.LST",
"EXAMPLE.MPBAS",
"EXAMPLE.OC",
"EXAMPLE.PCG",
"EXAMPLE.RCH",
"EXAMPLE.RIV",
"EXAMPLE.WEL",
"EXAMPLE.mpnam",
"EXAMPLE.nam",
]
for fname in file_names:
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mp6/{fname}",
fname=fname,
path=data_path / "mp6",
known_hash=None,
)
model_ws = data_path / "mp6"
ml = flopy.modflow.Modflow.load(
"EXAMPLE.nam",
model_ws=model_ws,
Expand Down

0 comments on commit b83b1d0

Please sign in to comment.