| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
A self-contained example project that walks through every public way to drive HydroModPy on the Nancon catchment (Brittany, France). It is designed as a teaching ground: each TOML is short, every block carries the official CLI comments (exported by hmp config template), every Python script exercises a different entry point.
This is the v2 layout of the original 02_nancon_watershed example. The old folder is kept untouched as a migration record.
mamba activate hmp_refact
hmp install-binaries # one-time MODFLOW download
hmp doctor # confirm the env is healthyThe example data shipped under examples/data/ is auto-resolved through the workspace scaffold (HydroModPy walks up from this folder and finds the sibling data/ directory).
11_nancon_watershed/
|-- README.md <- this file
|-- project.toml <- canonical base config
|
|-- 01_run_simulation_nwt.toml <- workflow = simulation, MODFLOW-NWT
|-- 02_run_simulation_mf6.toml <- workflow = simulation, MODFLOW 6
|-- 03_run_overview.toml <- workflow = overview (data report)
|-- 04_run_hydrographic_compare.toml <- workflow = simulation + hydro figures
|-- 05_run_calibration_k.toml <- workflow = calibration (K only)
|-- 06_run_calibration_k_sy.toml <- workflow = calibration (K + Sy)
|-- 07_run_comparison.toml <- workflow = comparison (low-K vs high-K)
|-- 08_run_testbed.toml <- workflow = testbed (K sensitivity)
|
|-- overlays/
| |-- overlay_short_window.toml <- --overlay, shrink dates
| |-- overlay_no_display.toml <- --overlay, kill figures
| |-- overlay_high_resolution.toml <- --overlay, 200x200 grid
|
|-- python/
| |-- 01_run_from_toml.py <- Project("01_run_simulation_nwt.toml")
| |-- 02_full_python_config.py <- HydroModPyConfig.from_dict(...)
| |-- 03_toml_plus_overrides.py <- load TOML, patch via model_copy
| |-- 04_lazy_phase_api.py <- Project.lazy + phase API
| |-- 05_sweep_sy.py <- two ways to sweep Sy
| |-- 06_python_calibration.py <- TOML mode + Python mode
| |-- 07_inspect_catalog.py <- read DuckDB + Zarr after a run
|
|-- figures/ <- auto-created (one subfolder per simulation name)
|-- simulations/ <- auto-created (Zarr v2 stores, CF-1.11 + UGRID-1.0)
`-- catalog.duckdb <- per-project catalog (auto-created on first run)
The shared input cache lives at <workspace>/data/cache.duckdb and the machine-wide registry at <state>/index.duckdb (managed by hmp index register|search|forget|prune).
project.toml is the canonical, fully-annotated configuration for the Nancon basin. Every run TOML in this folder inherits from it via base_config = "project.toml" and only redefines the orchestration block plus the parameter values used for that specific run.
Comments above each option come from hmp config template --profile user and explain what the field means and how its value is read. Use it as your map of the public surface.
Validate this TOML without running anything:
hmp config check examples/projects/11_nancon_watershed/project.tomlRegenerate a fresh template from the CLI (no Nancon values, every option commented out):
hmp config template ref.toml --profile user
hmp config template ref_expert.toml --profile expert # more knobs visible
hmp config template --list-modules # see all moduleshmp doctor --toml examples/projects/11_nancon_watershed/project.toml
hmp config schema > /tmp/hmp_schema.json # JSON Schema (handy for IDE plugins)hmp run examples/projects/11_nancon_watershed/01_run_simulation_nwt.tomlInspect the result:
hmp list 11_nancon_watershed # all runs in this project
hmp show nancon_sim_nwt # metadata + metrics
hmp inspect nancon_sim_nwt # mesh / storage layout
hmp display 01_run_simulation_nwt.toml --list # which figures exist# MODFLOW 6 instead of MODFLOW-NWT.
hmp run 02_run_simulation_mf6.toml
# Same TOML, layered overlays + a dotted override.
hmp run 01_run_simulation_nwt.toml \
--overlay overlays/overlay_short_window.toml \
--overlay overlays/overlay_no_display.toml \
--set flow.param.K.field.value=1e-4
# Print the resolved plan WITHOUT executing anything.
hmp run 01_run_simulation_nwt.toml --dry-runCompare the two solvers head to head:
hmp compare nancon_sim_nwt nancon_sim_mf6hmp run 03_run_overview.toml
# -> PNG panels under figures/overview/This one hits live APIs (BRGM, BD TOPAGE, Hub'Eau, SIM2). The first run may take several minutes; downloads are cached under examples/data/.
hmp run 04_run_hydrographic_compare.tomlOutputs the canonical hydrographic_network_comparison.png plus four companion figures under figures/nancon_hydrographic_compare/.
# One parameter (K) optimised with Optuna against KGE(discharge).
hmp run 05_run_calibration_k.toml
# Two parameters (K + Sy) with the same objective.
hmp run 06_run_calibration_k_sy.toml
# Browse the resulting sessions:
hmp catalog query "SELECT session_id, n_iterations FROM all_calibration_sessions"
# HTML report for one session:
hmp report <session_id> --open# Side-by-side run of two K values, with diff maps and metrics.
hmp run 07_run_comparison.toml
# K sensitivity testbed: materialise child TOMLs, optionally execute them.
hmp run 08_run_testbed.tomlpython python/01_run_from_toml.py # simplest Python entry point
python python/02_full_python_config.py # no TOML at all, Python dict
python python/03_toml_plus_overrides.py # TOML + model_copy + run kwargs
python python/04_lazy_phase_api.py # Project.lazy + phase API
python python/05_sweep_sy.py # Sy sweep, two ways
python python/06_python_calibration.py # TOML mode + Python mode
python python/07_inspect_catalog.py # read the catalog post-runBoth paths write to the same Zarr stores and DuckDB rows, so they can be mixed freely.
When hmp run <toml> is called, HydroModPy resolves the final configuration in this order:
Heads-up. The files in overlays/ are intentionally minimal fragments ([simulation.time], [display].enabled = false, ...). They do not validate standalone via hmp config check: they only make sense layered on top of a leaf TOML through --overlay.
The same precedence applies in Python: load the TOML, patch with HydroModPyConfig.model_copy(update=...), hand to Project(cfg), optionally pass run-level overrides at project.run(**kw) time.
After any run, the project root contains:
Export a simulation as a portable, signed .hmp archive (tar.zst + RO-Crate manifest, optional COG GeoTIFF / STAC collection):
hmp export-package nancon_sim_nwt \
--workspace examples/projects/11_nancon_watershed \
-o /tmp/nancon_sim_nwt.hmp
# Round-trip into any other workspace:
hmp add /tmp/nancon_sim_nwt.hmp
hmp import /tmp/nancon_sim_nwt.hmpOpen a browser UI on top of the catalogs:
hmp manage --workspace examples/projects/11_nancon_watershedInspect the catalog from Python (recommended):
import hydromodpy as hmp
catalog = hmp.open_catalog("examples/projects/11_nancon_watershed")
catalog.simulations.to_dataframe()
catalog.inputs.list() # shared input cache
catalog.projects.list() # registered projectshmp.open(...) keeps returning the legacy simulations-only facade (Catalog) for backwards-compatible flows.
The runtime writes an append-only journal (workflow_steps) and a HeartbeatPulse so interrupted runs can be resumed cascade-aware:
hmp run 01_run_simulation_nwt.toml --resume <RUN_ID>
hmp run 01_run_simulation_nwt.toml --from <STEP>Use hmp gc to garbage-collect zombie runs whose heartbeat went stale.
hmp delete nancon_sim_nwt -y # one simulation
hmp workspace clean --workspace . # everything (be careful)02_nancon_watershed/ is the original example. 11_nancon_watershed/ is a reorganised, fully-CLI-driven rewrite that will replace it. The old folder is kept as a migration record until the swap lands.
for toml in project.toml [0-9][0-9]_*.toml; do
hmp config check "$toml"
done
for toml in [0-9][0-9]_*.toml; do
hmp run "$toml" --dry-run > /dev/null && echo "OK dry-run $toml" || echo "FAIL $toml"
donehmp config check enforces the Pydantic schema of HydroModPyConfig sections (simulation / overview / calibration). The comparison and testbed schemas live in their own packages and are only validated at hmp run time, so a --dry-run pass is the canonical check.
| Back | FazBrowse Home | New Git URL |