Skip to content

Commit

Permalink
fixes after nuking examples/data/ and seeing what fails
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 12, 2024
1 parent 6236595 commit 5bf2a4d
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .docs/Notebooks/groundwater2023_watershed_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def set_idomain(grid, boundary):
folder_name = "groundwater2023"
fname = "geometries.yml"
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mf6//{fname}",
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/{folder_name}/{fname}",
fname=fname,
path=data_path / folder_name,
known_hash=None,
Expand Down
41 changes: 38 additions & 3 deletions .docs/Notebooks/mf6_mnw2_tutorial01.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
# # Working with the Multi-node Well (MNW2) Package

import os
import sys

# +
import sys
from pathlib import Path
from tempfile import TemporaryDirectory

import git
import numpy as np
import pandas as pd
import pooch

import flopy

Expand All @@ -33,6 +36,15 @@
print(f"flopy version: {flopy.__version__}")
# -

# Check if we are in the repository and define the data path.

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

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

# ### Make an MNW2 package from scratch

# +
Expand Down Expand Up @@ -181,7 +193,30 @@

# ### Load some example MNW2 packages

path = os.path.join("..", "..", "examples", "data", "mnw2_examples")
folder_name = "mnw2_examples"

file_names = {
"BadRiver_cal.mnw2": None,
"MNW2-Fig28.bas": None,
"MNW2-Fig28.dis": None,
"MNW2-Fig28.lpf": None,
"MNW2-Fig28.mnw2": None,
"MNW2-Fig28.mnwi": None,
"MNW2-Fig28.nam": None,
"MNW2-Fig28.oc": None,
"MNW2-Fig28.pcg": None,
"MNW2-Fig28.rch": None,
"MNW2-Fig28.wel": None,
}
for fname, fhash in file_names.items():
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/{folder_name}/{fname}",
fname=fname,
path=data_path / folder_name,
known_hash=fhash,
)

path = data_path / folder_name
m = flopy.modflow.Modflow("MNW2-Fig28", model_ws=model_ws)
dis = flopy.modflow.ModflowDis.load(os.path.join(path, "MNW2-Fig28.dis"), m)

Expand All @@ -198,7 +233,7 @@

pd.DataFrame(mnw2.mnw["well-a"].stress_period_data)

path = os.path.join("..", "..", "examples", "data", "mnw2_examples")
path = data_path / "mnw2_examples"
m = flopy.modflow.Modflow("br", model_ws=model_ws)
mnw2 = flopy.modflow.ModflowMnw2.load(os.path.join(path, "BadRiver_cal.mnw2"), m)

Expand Down
21 changes: 19 additions & 2 deletions .docs/Notebooks/mf6_support_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,20 @@
from shutil import copyfile
from tempfile import TemporaryDirectory

import git
import pooch

proj_root = Path.cwd().parent.parent

# Check if we are in the repository and define the data path.

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

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

import flopy

# temporary directory
Expand Down Expand Up @@ -244,9 +256,14 @@
model, pname="ic", strt=strt, filename=f"{model_name}.ic"
)
# move external file data into model folder
icv_data_path = os.path.join(
"..", "..", "examples", "data", "mf6", "notebooks", "iconvert.txt"
fname = "iconvert.txt"
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mf6/notebooks/{fname}",
fname=fname,
path=data_path / "mf6" / "notebooks",
known_hash=None,
)
icv_data_path = data_path / "mf6" / "notebooks" / fname
copyfile(icv_data_path, os.path.join(sim_path, "iconvert.txt"))
# create storage package
sto_package = flopy.mf6.ModflowGwfsto(
Expand Down
39 changes: 38 additions & 1 deletion .docs/Notebooks/mfusg_freyberg_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,47 @@
# +
from pprint import pformat

import git
import pooch

import flopy

root_name = "freyberg.usg"
model_ws = Path.cwd().parent / "../examples/data" / root_name.replace(".", "_")

# Check if we are in the repository and define the data path.

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

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

file_names = {
"freyberg.usg.bas": None,
"freyberg.usg.disu": None,
"freyberg.usg.ghb": None,
"freyberg.usg.gnc": None,
"freyberg.usg.gsf": None,
"freyberg.usg.gsf.with_comment": None,
"freyberg.usg.lpf": None,
"freyberg.usg.nam": None,
"freyberg.usg.oc": None,
"freyberg.usg.rch": None,
"freyberg.usg.sfr": None,
"freyberg.usg.sms": None,
"freyberg.usg.wel": None,
}
for fname, fhash in file_names.items():
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/{root_name.replace('.', '_')}/{fname}",
fname=fname,
path=data_path / root_name.replace(".", "_"),
known_hash=None,
)


model_ws = data_path / root_name.replace(".", "_")
# -

# Now construct an `UnstructuredGrid` from a grid specification file.
Expand Down
21 changes: 19 additions & 2 deletions .docs/Notebooks/mt3d-usgs_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@

# +
import sys
from pathlib import Path
from pprint import pformat
from tempfile import TemporaryDirectory

import git
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pooch

import flopy

Expand All @@ -56,6 +59,15 @@
mfexe = "mfnwt"
mtexe = "mt3dusgs"

# Check if we are in the repository and define the data path.

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

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

# Make sure modelpth directory exists
if not os.path.isdir(modelpth):
os.makedirs(modelpth, exist_ok=True)
Expand Down Expand Up @@ -587,8 +599,13 @@ def load_ts_from_otis(fname, iobs=1):
ts5_mt3d = load_ts_from_SFT_output(fname_SFTout, nd=619)

# OTIS results located here
fname_OTIS = (
"../../examples/data/mt3d_test/mfnwt_mt3dusgs/sft_crnkNic/OTIS_solution.out"
fname = "OTIS_solution.out"
fname_OTIS = data_path / "mt3d_test" / "mfnwt_mt3dusgs" / "sft_crnkNic" / fname
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mt3d_test/mfnwt_mt3dusgs/sft_crnkNic/{fname}",
fname=fname,
path=data_path / "mt3d_test" / "mfnwt_mt3dusgs" / "sft_crnkNic",
known_hash=None,
)

# Loading OTIS output
Expand Down
Loading

0 comments on commit 5bf2a4d

Please sign in to comment.