Skip to content

Commit

Permalink
last few
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Dec 12, 2024
1 parent 83975f2 commit 6236595
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .docs/Notebooks/groundwater_paper_uspb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
if not os.path.exists(ws):
os.makedirs(ws)

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

try:
root = Path(git.Repo(".", search_parent_directories=True).working_dir)
Expand Down
39 changes: 37 additions & 2 deletions .docs/Notebooks/shapefile_export_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@
# * general exporting and importing of geographic data from other sources

import os
import sys

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

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

import flopy

Expand All @@ -47,8 +50,40 @@
temp_dir = TemporaryDirectory()
outdir = os.path.join(temp_dir.name, "shapefile_export")

# 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 = "freyberg"

file_names = {
"freyberg.bas": "63266024019fef07306b8b639c6c67d5e4b22f73e42dcaa9db18b5e0f692c097",
"freyberg.dis": "62d0163bf36c7ee9f7ee3683263e08a0abcdedf267beedce6dd181600380b0a2",
"freyberg.githds": "abe92497b55e6f6c73306e81399209e1cada34cf794a7867d776cfd18303673b",
"freyberg.gitlist": "aef02c664344a288264d5f21e08a748150e43bb721a16b0e3f423e6e3e293056",
"freyberg.lpf": "06500bff979424f58e5e4fbd07a7bdeb0c78f31bd08640196044b6ccefa7a1fe",
"freyberg.nam": "e66321007bb603ef55ed2ba41f4035ba6891da704a4cbd3967f0c66ef1532c8f",
"freyberg.oc": "532905839ccbfce01184980c230b6305812610b537520bf5a4abbcd3bd703ef4",
"freyberg.pcg": "0d1686fac4680219fffdb56909296c5031029974171e25d4304e70fa96ebfc38",
"freyberg.rch": "37a1e113a7ec16b61417d1fa9710dd111a595de738a367bd34fd4a359c480906",
"freyberg.riv": "7492a1d5eb23d6812ec7c8227d0ad4d1e1b35631a765c71182b71e3bd6a6d31d",
"freyberg.wel": "00aa55f59797c02f0be5318a523b36b168fc6651f238f34e8b0938c04292d3e7",
}
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 an existing model
model_ws = "../../examples/data/freyberg"
model_ws = data_path / sim_name
m = flopy.modflow.Modflow.load(
"freyberg.nam",
model_ws=model_ws,
Expand Down
30 changes: 28 additions & 2 deletions .docs/Notebooks/shapefile_feature_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@
import shutil
import sys
import warnings
from pathlib import Path
from tempfile import TemporaryDirectory

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

import flopy
from flopy.export.shapefile_utils import recarray2shp, shp2recarray
Expand All @@ -58,6 +61,15 @@
temp_dir = TemporaryDirectory()
workspace = temp_dir.name

# 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()

m = flopy.modflow.Modflow("toy_model", model_ws=workspace)
botm = np.zeros((2, 10, 10))
botm[0, :, :] = 1.5
Expand Down Expand Up @@ -129,7 +141,14 @@
# * create geometry objects for pathlines from a MODPATH simulation
# * plot the paths using the built in plotting method

pthfile = PathlineFile("../../examples/data/mp6/EXAMPLE-3.pathline")
fname = "EXAMPLE-3.pathline"
pthfile = pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mp6/{fname}",
fname=fname,
path=data_path / "mp6",
known_hash=None,
)
pthfile = PathlineFile(pthfile)
pthdata = pthfile._data.view(np.recarray)

# +
Expand Down Expand Up @@ -162,7 +181,14 @@

# ## Points

eptfile = EndpointFile("../../examples/data/mp6/EXAMPLE-3.endpoint")
fname = "EXAMPLE-3.endpoint"
eptfile = pooch.retrieve(
url=f"https://github.com/modflowpy/flopy/raw/develop/examples/data/mp6/{fname}",
fname=fname,
path=data_path / "mp6",
known_hash=None,
)
eptfile = EndpointFile(eptfile)
eptdata = eptfile.get_alldata()

# +
Expand Down

0 comments on commit 6236595

Please sign in to comment.