diff --git a/.docs/Notebooks/export_vtk_tutorial.py b/.docs/Notebooks/export_vtk_tutorial.py index e701e69cb..2719da25d 100644 --- a/.docs/Notebooks/export_vtk_tutorial.py +++ b/.docs/Notebooks/export_vtk_tutorial.py @@ -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 @@ -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. diff --git a/.docs/Notebooks/mf_load_tutorial.py b/.docs/Notebooks/mf_load_tutorial.py index 91db0b0db..4ea9077c2 100644 --- a/.docs/Notebooks/mf_load_tutorial.py +++ b/.docs/Notebooks/mf_load_tutorial.py @@ -23,6 +23,10 @@ # + import os import sys +from pathlib import Path + +import git +import pooch import flopy @@ -30,6 +34,14 @@ 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: @@ -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, @@ -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,