Skip to content

Commit

Permalink
3 more
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 12, 2024
1 parent 1038342 commit 6792fde
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 6 deletions.
29 changes: 26 additions & 3 deletions .docs/Notebooks/groundwater2023_watershed_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import pathlib as pl
import sys

import git
import matplotlib as mpl
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt
import numpy as np
import pooch
import shapely
import yaml
from shapely.geometry import LineString, Polygon
Expand Down Expand Up @@ -106,10 +108,25 @@ def set_idomain(grid, boundary):
grid.idomain = idomain


geometries = yaml.safe_load(
open(pl.Path("../../examples/data/groundwater2023/geometries.yml"))
# Check if we are in the repository and define the data path.

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

data_path = root / "examples" / "data" if root else pl.Path.cwd()
folder_name = "groundwater2023"
fname = "geometries.yml"
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mf6//{fname}",
fname=fname,
path=data_path / folder_name,
known_hash=None,
)

geometries = yaml.safe_load(open(data_path / folder_name / fname))

# basic figure size
figwidth = 180 # 90 # mm
figwidth = figwidth / 10 / 2.54 # inches
Expand Down Expand Up @@ -161,7 +178,13 @@ def set_idomain(grid, boundary):
os.mkdir(temp_path)

# Load the fine topography that will be sampled
ascii_file = pl.Path("../../examples/data/geospatial/fine_topo.asc")
fname = "fine_topo.asc"
ascii_file = pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/geospatial/{fname}",
fname=fname,
path=data_path / "geospatial",
known_hash=None,
)
fine_topo = flopy.utils.Raster.load(ascii_file)

# Define the problem size and extents
Expand Down
33 changes: 32 additions & 1 deletion .docs/Notebooks/load_swr_binary_data_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@

import os
import sys
from pathlib import Path

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

# +
from IPython.display import Image
Expand All @@ -35,9 +38,37 @@
print(f"matplotlib version: {mpl.__version__}")
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()
folder_name = "swr_test"

# +
# Set the paths
datapth = os.path.join("..", "..", "examples", "data", "swr_test")
datapth = data_path / folder_name

file_names = [
"SWR004.dis.ref",
"SWR004.flow",
"SWR004.obs",
"SWR004.stg",
"SWR004.str",
"SWR004.vel",
"swr005.qaq",
"swr005.str",
]
for fname in file_names:
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/{folder_name}/{fname}",
fname=fname,
path=datapth,
known_hash=None,
)

# SWR Process binary files
files = ("SWR004.obs", "SWR004.vel", "SWR004.str", "SWR004.stg", "SWR004.flow")
Expand Down
57 changes: 55 additions & 2 deletions .docs/Notebooks/mf6_complex_model_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
# ### Setup the Notebook Environment

import os
import sys

# +
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 @@ -39,13 +42,63 @@
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()
sim_name = "test005_advgw_tidal"
file_names = [
"AdvGW_tidal.dis",
"AdvGW_tidal.evt",
"AdvGW_tidal.ghb",
"AdvGW_tidal.ghb.obs",
"AdvGW_tidal.head.cont.opncls",
"AdvGW_tidal.ic",
"AdvGW_tidal.nam",
"AdvGW_tidal.npf",
"AdvGW_tidal.obs",
"AdvGW_tidal.oc",
"AdvGW_tidal.riv",
"AdvGW_tidal.riv.obs",
"AdvGW_tidal.riv.single.opncls",
"AdvGW_tidal.sto",
"AdvGW_tidal.wel",
"AdvGW_tidal_1.rch",
"AdvGW_tidal_2.rch",
"AdvGW_tidal_3.rch",
"advgw_tidal.dis.grb",
"mfsim.nam",
"model.ims",
"recharge_rates.ts",
"recharge_rates_1.ts",
"recharge_rates_2.ts",
"recharge_rates_3.ts",
"river_stages.ts",
"simulation.tdis",
"tides.ts",
"tides.txt",
"well_rates.ts",
]
for fname in file_names:
pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mf6/{sim_name}/{fname}",
fname=fname,
path=data_path / "mf6" / sim_name,
known_hash=None,
)

# For this example, we will set up a temporary workspace.
# Model input files and output files will reside here.
temp_dir = TemporaryDirectory()
model_name = "advgw_tidal"
workspace = os.path.join(temp_dir.name, model_name)

data_pth = os.path.join("..", "..", "examples", "data", "mf6", "test005_advgw_tidal")
data_pth = data_path / "mf6" / sim_name
assert os.path.isdir(data_pth)

# +
Expand Down

0 comments on commit 6792fde

Please sign in to comment.