Skip to content

Commit 610b9ea

Browse files
authored
docs(models): improve docs for models api (#204)
1 parent b520bc1 commit 610b9ea

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

docs/md/models.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,51 @@
11
# Models API
22

3-
The `modflow_devtools.models` module provides programmatic access to MODFLOW 6 example models via [Pooch](https://www.fatiando.org/pooch/latest/index.html). Example usage:
3+
The `modflow_devtools.models` module provides programmatic access to MODFLOW 6 example models via [Pooch](https://www.fatiando.org/pooch/latest/index.html).
4+
5+
## Listing models
6+
7+
The `get_models()` function returns a mapping of model names to model input files.
48

59
```python
10+
from pprint import pprint
611
import modflow_devtools.models as models
7-
from flopy.mf6 import MFSimulation
812

9-
workspace = models.copy_to("some/path", "some_model")
10-
sim = MFSimulation.load(sim_ws=workspace)
13+
pprint(list(models.get_models())[:5])
14+
```
15+
16+
```
17+
['example/ex-gwe-ates',
18+
'example/ex-gwe-barends/mf6gwe',
19+
'example/ex-gwe-barends/mf6gwf',
20+
'example/ex-gwe-danckwerts',
21+
'example/ex-gwe-geotherm/mf6gwe']
1122
```
1223

24+
Model names follow a hierarchical addressing scheme.
25+
26+
The leading prefix identifies where the model came from. Currently three prefixes are in use:
27+
28+
- `example/...`: example models in https://github.com/MODFLOW-ORG/modflow6-examples
29+
- `test/...`: test models in https://github.com/MODFLOW-ORG/modflow6-testmodels
30+
- `large/...`: large test models in https://github.com/MODFLOW-ORG/modflow6-largetestmodels
31+
32+
The remaining path parts reflect the relative location of the model within the source repository.
33+
34+
**Note**: until this module stabilizes, model naming conventions may change without notice.
35+
36+
## Using models
37+
38+
To copy model input files to a workspace of your choosing:
39+
40+
```python
41+
from tempfile import TemporaryDirectory
42+
43+
with TemporaryDirectory() as td:
44+
workspace = models.copy_to(td, "example/ex-gwe-ates", verbose=True)
45+
```
46+
47+
If the target directory doesn't exist, it will be created.
48+
1349
## Developers
1450

1551
The `make_registry.py` script is responsible for generating a registry text file and a mapping between files and models. This script should be run in the CI pipeline at release time before the package is built. The generated registry file and model mapping are used to create a pooch instance for fetching model files, and should be distributed with the package.

0 commit comments

Comments
 (0)