Skip to content

Add build_model_python.ipynb, update prepare_ldd.ipynb - #864

Open
PeterNelemans wants to merge 1 commit into
Deltares:mainfrom
PeterNelemans:update_tutorials_and_docs
Open

PeterNelemans wants to merge 1 commit into
Deltares:mainfrom
PeterNelemans:update_tutorials_and_docs

Conversation

@PeterNelemans

@PeterNelemans PeterNelemans commented Oct 21, 2026 •

Copy link
Copy Markdown

Issue addressed

Fixes #768 and #767

Explanation

I added another example notebook for building a Wflow model using Python, and improved the one for deriving some data from the DEM.

New: build_model_python.ipynb
The existing build example builds a complete model with a single CLI command. That works, but if something goes wrong it is hard to tell what caused it, and users cannot inspect intermediate results. The new notebook builds a model step by step with the Python API, plotting or inspecting the result after each step:

  • explore the data catalog and delineate the subbasin from an outlet point (get_basin_geometry)
  • model settings (setup_config), basemaps (MERIT Hydro), rivers (hydro_rivers_lin) and river roughness
  • reservoirs with and without control (hydro_reservoirs, hydro_lakes) and glaciers (rgi)
  • land use (CORINE), leaf area index (MODIS) and soil (SoilGrids)
  • forcing: precipitation (CHIRPS) and temperature and PET (ERA5, De Bruin)
  • outlets and gauges from test_stations.csv, with subcatchments
  • constant parameters, and finally writing the model with model.write()

Renamed: build_model.ipynb → build_model_cli.ipynb

  • Renamed so the two build examples are clearly paired (CLI vs. Python).
  • Updated the title and intro, and added a link to the Python example.
  • Fixed small typos and grammar.

Reworked: prepare_ldd.ipynb
On main, this notebook takes flow directions from MERIT Hydro, derives a river network from them and uses that to re-derive flow directions, which is a bit circular and not very helpful for most users. It now starts from a DEM only (GEBCO), which is the realistic case:

  • derive D8 flow directions from the DEM with hydromt.gis.flw.d8_from_dem
  • derive upstream area, Strahler stream order, slope and basins
  • compare two river definitions (Strahler order >= 3 vs. upstream area > 10 km²) and explain why there is no one-size-fits-all choice
  • export the derived data to examples/gebco_derived_hydrography/ and load it again through a data catalog

Output folders

  • The CLI and Python notebooks now write to wflow_test_cli_full and wflow_test_python_full, so they don't overwrite each other when the docs execute them. Updated .gitignore and the build-example-model-full pixi task to match.

Docs

  • example_index.rst: renamed the dropdown to "Build model", linked both build notebooks and added build_model_python to the toctree.
  • user_guide/2_sbm_model/2_build.rst: updated the references to build_model_cli and added a link to build_model_python.

Checklist

  • Updated tests or added new tests (not applicable, documentation only)
  • Branch is up to date with main
  • Tests & pre-commit hooks pass
  • Updated documentation if needed

Additional Notes (optional)

  • The notebooks run on artifact_data only, so no extra data is needed.
  • The example label example-build_model is now example-build_model_cli. All internal references are updated.

Let me know what you think!

@PeterNelemans
PeterNelemans force-pushed the update_tutorials_and_docs branch from ac975e3 to febf215 Compare October 21, 2026 21:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add example notebook: building a Wflow model step-by-step with Python

1 participant