Skip to content

Commit

Permalink
groundwater_paper_uspb_example.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 12, 2024
1 parent 6792fde commit 83975f2
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions .docs/Notebooks/groundwater_paper_uspb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
# +
import os
import sys
from pathlib import Path
from pprint import pformat

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

import flopy
Expand All @@ -41,9 +44,23 @@
if not os.path.exists(ws):
os.makedirs(ws)

fn = os.path.join(
"..", "groundwater_paper", "uspb", "results", "USPB_capture_fraction_04_01.dat"
# 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 / ".docs" / "groundwater_paper" if root else Path.cwd()

fname = "USPB_capture_fraction_04_01.dat"
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/.docs/groundwater_paper/uspb/results/{fname}",
fname=fname,
path=data_path / "uspb" / "results",
known_hash=None,
)
fn = data_path / "uspb" / "results" / fname
cf = np.loadtxt(fn)
print(cf.shape)

Expand All @@ -53,7 +70,7 @@
c = plt.imshow(cf2, cmap="jet")
plt.colorbar(c)

wsl = os.path.join("..", "groundwater_paper", "uspb", "flopy")
wsl = data_path / "uspb" / "flopy"
ml = flopy.modflow.Modflow.load("DG.nam", model_ws=wsl, verbose=False)

nlay, nrow, ncol = ml.nlay, ml.dis.nrow, ml.dis.ncol
Expand Down Expand Up @@ -191,9 +208,14 @@
plt.savefig(os.path.join(ws, "uspb_heads.png"), dpi=300)
# -

fn = os.path.join(
"..", "groundwater_paper", "uspb", "results", "USPB_capture_fraction_04_10.dat"
fname = "USPB_capture_fraction_04_10.dat"
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/.docs/groundwater_paper/uspb/results/{fname}",
fname=fname,
path=data_path / "uspb" / "results",
known_hash=None,
)
fn = data_path / "uspb" / "results" / fname
cf = np.loadtxt(fn)
cf2 = scipy.ndimage.zoom(cf, 4, order=0)

Expand Down

0 comments on commit 83975f2

Please sign in to comment.