Build a Wflow Sediment model#
This notebook demonstrates how to prepare a Wflow Sediment model using the command line interace (CLI).
All lines in this notebook which start with !
are executed from the command line. Within the notebook environment the logging messages are shown after completion. You can also copy these lines and paste these in your shell to get more direct feedback.
HydroMT CLI build interface#
Lets first check if the Wflow sediment model is recognized by HydroMT
[1]:
# this should return "wflow, wflow_sediment"
# as well as hydromt generic models "grid_model, lumped_model, network_model (mesh_model)"
!hydromt --models
model plugins:
- wflow (hydromt_wflow 0.7.1.dev0)
- wflow_sediment (hydromt_wflow 0.7.1.dev0)
generic models (hydromt 0.10.0):
- grid_model
- vector_model
- network_model
Using the HydroMT build API we can setup a complete model from scratch. Let’s get an overview of all the available options:
[2]:
!hydromt build --help
Usage: hydromt build [OPTIONS] MODEL MODEL_ROOT
Build models from scratch.
Example usage: --------------
To build a wflow model for a subbasin using a point coordinates snapped to
cells with upstream area >= 50 km2 hydromt build wflow /path/to/model_root
-i /path/to/wflow_config.yml -r "{'subbasin': [-7.24, 62.09], 'uparea':
50}" -d deltares_data -d /path/to/data_catalog.yml -v
To build a sfincs model based on a bbox hydromt build sfincs
/path/to/model_root -i /path/to/sfincs_config.yml -r "{'bbox':
[4.6891,52.9750,4.9576,53.1994]}" -d /path/to/data_catalog.yml -v
Options:
--opt TEXT Method specific keyword arguments, see the method
documentation of the specific model for more
information about the arguments.
-i, --config PATH Path to hydroMT configuration file, for the model
specific implementation.
-r, --region TEXT Set the region for which to build the model, e.g.
{'subbasin': [-7.24, 62.09]}
-d, --data TEXT Path to local yaml data catalog file OR name of
predefined data catalog.
--dd, --deltares-data Flag: Shortcut to add the "deltares_data" catalog
--fo, --force-overwrite Flag: If provided overwrite existing model files
--cache Flag: If provided cache tiled rasterdatasets
-v, --verbose Increase verbosity.
-q, --quiet Decrease verbosity.
--help Show this message and exit.
Model setup configuration#
The HydroMT configuration file (YAML) contains the model setup configuration and determines which methods are used to prepare the different components of a Wflow Sediment model and in which order and optionally sets non-default arguments for each method. This configuration is passed to HydroMT using -i <path_to_config_file>
. We have prepared several example files which are available in the model repository examples folder and
from the docs (building a model).
Each header (without indent) (e.g. setup_basemaps:
) corresponds to a model method. All model methods are explained in the docs (model methods).
We will load the default wflow sediment build configuration yaml file for inspection:
[3]:
fn_config = "wflow_sediment_build.yml"
with open(fn_config, "r") as f:
txt = f.read()
print(txt)
setup_config: # options parsed to wflow toml file <section>.<option>
starttime: 2010-01-01T00:00:00
endtime: 2010-03-31T00:00:00
timestepsecs: 86400
setup_basemaps:
hydrography_fn: merit_hydro # source hydrography data {merit_hydro, merit_hydro_1k}
basin_index_fn: merit_hydro_index # source of basin index corresponding to hydrography_fn
upscale_method: ihu # upscaling method for flow direction data, by default 'ihu'
res: 0.00833 # build the model at a 30 arc sec (~1km) resolution
setup_rivers:
hydrography_fn: merit_hydro # source hydrography data, should correspond to hydrography_fn in setup_basemaps
river_geom_fn: hydro_rivers_lin # river source data with river width and bankfull discharge
river_upa: 30 # minimum upstream area threshold for the river map [km2]
rivdph_method: powlaw # method to estimate depth {'powlaw', 'manning', 'gvf'}
min_rivdph: 1 # minimum river depth [m]
min_rivwth: 30 # minimum river width [m]
slope_len: 2000 # length over which tp calculate river slope [m]
smooth_len: 5000 # length over which to smooth river depth and river width [m]
setup_reservoirs:
reservoirs_fn: hydro_reservoirs # source for reservoirs shape and attributes
timeseries_fn: gww # additionnal source for reservoir are timeseries to compute reservoirs, Either 'gww' using gwwapi or 'jrc' using hydroengine.
min_area: 1.0 # minimum lake area to consider [km2]
setup_lakes:
lakes_fn: hydro_lakes # source for lakes based on hydroLAKES: {hydro_lakes}
min_area: 1.0 # minimum reservoir area to consider [km2]
setup_riverbedsed:
setup_lulcmaps:
lulc_fn: globcover_2009 # source for lulc maps: {globcover, vito, corine}
lulc_mapping_fn: globcover_mapping_default # default mapping for lulc classes
setup_laimaps:
lai_fn: modis_lai # source for LAI: {modis_lai}
setup_canopymaps:
canopy_fn: simard # source for vegetation canopy height: {simard}
setup_soilmaps:
soil_fn: soilgrids # source for soilmaps: {soilgrids}
usleK_method: renard # method to compute the USLE K factor: {renard, epic}
setup_outlets:
river_only: True
setup_gauges:
gauges_fn: grdc # If not None add gaugemap. Either a path or known gauges_fn: {grdc}
snap_to_river: True # If True snaps gauges from source to river
derive_subcatch: False # if True derive subcatch map based on gauges.
setup_constant_pars: # constant parameters values
c_Bagnold: 0.0000175
eros_expo: 1.5
eros_ov: 0.9
eros_spl_EUROSEM: 2.0
exp_Bagnold: 1.4
ResTrapEff: 1.0
Setup Wflow Sediment model from scratch#
[4]:
# NOTE: copy this line (without !) to your shell for more direct feedback
# NOTE: as of hydromt version 0.7.0 the region argument is optional and should be preceded by -r or --region
# NOTE: the resolution argument has been removed since hydromt v0.7.0 and can now only be configured from the configuration file under the setup_basemap header
!hydromt build wflow_sediment "./wflow_test_sediment" -r "{'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.70, 45.35, 12.95, 46.70]}" -i wflow_sediment_build.yml -d artifact_data -vv
2024-12-18 18:36:48,923 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/hydromt.log.
2024-12-18 18:36:48,923 - build - log - INFO - HydroMT version: 0.10.0
2024-12-18 18:36:48,923 - build - main - INFO - Building instance of wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment.
2024-12-18 18:36:48,923 - build - main - INFO - User settings:
2024-12-18 18:36:49,295 - build - data_catalog - INFO - Reading data catalog artifact_data latest
2024-12-18 18:36:49,295 - build - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.9/data_catalog.yml
2024-12-18 18:36:49,886 - build - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.7.1.dev0).
2024-12-18 18:36:49,886 - build - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2024-12-18 18:36:49,899 - build - model_api - DEBUG - Setting model config options.
2024-12-18 18:36:49,900 - build - model_api - DEBUG - Default config read from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow_sediment/wflow_sediment.toml
2024-12-18 18:36:49,900 - build - model_api - INFO - setup_basemaps.region: {'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7]}
2024-12-18 18:36:49,901 - build - model_api - INFO - setup_basemaps.hydrography_fn: merit_hydro
2024-12-18 18:36:49,901 - build - model_api - INFO - setup_basemaps.basin_index_fn: merit_hydro_index
2024-12-18 18:36:49,901 - build - model_api - INFO - setup_basemaps.res: 0.00833
2024-12-18 18:36:49,901 - build - model_api - INFO - setup_basemaps.upscale_method: ihu
2024-12-18 18:36:49,901 - build - wflow - INFO - Preparing base hydrography basemaps.
2024-12-18 18:36:49,902 - build - rasterdataset - INFO - Reading merit_hydro raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/merit_hydro/{variable}.tif
2024-12-18 18:36:49,982 - build - basin_mask - DEBUG - Parsed region (kind=subbasin): {'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7], 'xy': [12.2051, 45.8331]}
2024-12-18 18:36:53,993 - build - basin_mask - INFO - subbasin bbox: [11.7750, 45.8042, 12.7450, 46.6900]
2024-12-18 18:36:54,049 - build - wflow - DEBUG - Adding basins vector to geoms.
2024-12-18 18:36:54,050 - build - basemaps - DEBUG - Mask in dataset assumed to represent subbasins.
2024-12-18 18:36:54,051 - build - basemaps - DEBUG - (Sub)basin at original resolution has 664756 cells.
2024-12-18 18:36:54,215 - build - basemaps - DEBUG - Burn subbasin outlet in upstream area data.
2024-12-18 18:36:54,262 - build - basemaps - INFO - Upscale flow direction data: 10x, ihu method.
2024-12-18 18:37:08,968 - build - basemaps - DEBUG - Derive stream order.
2024-12-18 18:37:09,126 - build - basemaps - DEBUG - Map shape: (106, 116); active cells: 6637.
2024-12-18 18:37:09,127 - build - basemaps - DEBUG - Outlet coordinates (1/1): (12.20750,45.83583).
2024-12-18 18:37:09,297 - build - wflow - DEBUG - Adding region vector to geoms.
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.args: ()
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.hydrography_fn: merit_hydro
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.river_geom_fn: hydro_rivers_lin
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.river_upa: 30
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.rivdph_method: powlaw
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.min_rivdph: 1
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.min_rivwth: 30
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.slope_len: 2000
2024-12-18 18:37:09,300 - build - model_api - INFO - setup_rivers.smooth_len: 5000
2024-12-18 18:37:09,300 - build - wflow - INFO - Preparing river maps.
2024-12-18 18:37:09,301 - build - rasterdataset - INFO - Reading merit_hydro raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/merit_hydro/{variable}.tif
2024-12-18 18:37:09,361 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-12-18 18:37:09,368 - build - river - DEBUG - Set river mask (min uparea: 30 km2) and prepare flow dirs.
2024-12-18 18:37:09,494 - build - river - DEBUG - Derive river length.
2024-12-18 18:37:14,511 - build - river - DEBUG - Derive river slope.
2024-12-18 18:37:15,338 - build - river - DEBUG - Derive rivwth from hydrography dataset.
2024-12-18 18:37:15,352 - build - dataframe - INFO - Reading roughness_river_mapping_default csv data from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow/N_river_mapping.csv
2024-12-18 18:37:15,357 - build - landuse - INFO - Deriving N_River using average resampling (nodata=-999.0).
2024-12-18 18:37:15,364 - build - geodataframe - INFO - Reading hydro_rivers_lin vector data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/rivers_lin2019_v1.gpkg
2024-12-18 18:37:15,374 - build - geodataframe - DEBUG - Clip intersects [11.778, 45.807, 12.745, 46.690] (EPSG:4326)
2024-12-18 18:37:15,575 - build - river - DEBUG - Derive ['rivwth', 'qbankfull'] from shapefile.
2024-12-18 18:37:15,623 - build - river - DEBUG - Valid for 381/655 river cells (max dist: 392 m).
2024-12-18 18:37:19,682 - build - wflow - DEBUG - Adding rivers vector to geoms.
2024-12-18 18:37:20,497 - build - model_api - INFO - setup_reservoirs.reservoirs_fn: hydro_reservoirs
2024-12-18 18:37:20,497 - build - model_api - INFO - setup_reservoirs.timeseries_fn: gww
2024-12-18 18:37:20,497 - build - model_api - INFO - setup_reservoirs.min_area: 1.0
2024-12-18 18:37:20,498 - build - wflow - INFO - Preparing reservoir maps.
2024-12-18 18:37:20,498 - build - geodataframe - INFO - Reading hydro_reservoirs vector data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/hydro_reservoirs.gpkg
2024-12-18 18:37:20,515 - build - geodataframe - DEBUG - Clip contains [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-12-18 18:37:20,517 - build - geodataframe - DEBUG - Convert units for 5 columns.
2024-12-18 18:37:20,519 - build - wflow - WARNING - No reservoirs of sufficient size found within region! Skipping reservoir procedures!
2024-12-18 18:37:20,519 - build - wflow - INFO - Skipping method, as no data has been found
2024-12-18 18:37:20,519 - build - model_api - INFO - setup_lakes.lakes_fn: hydro_lakes
2024-12-18 18:37:20,519 - build - model_api - INFO - setup_lakes.min_area: 1.0
2024-12-18 18:37:20,519 - build - wflow - INFO - Preparing lake maps.
2024-12-18 18:37:20,520 - build - geodataframe - INFO - Reading hydro_lakes vector data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/hydro_lakes.gpkg
2024-12-18 18:37:20,530 - build - geodataframe - DEBUG - Clip contains [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-12-18 18:37:20,531 - build - geodataframe - DEBUG - Convert units for 1 columns.
2024-12-18 18:37:20,532 - build - wflow - INFO - 1 lake(s) of sufficient size found within region.
2024-12-18 18:37:20,536 - build - waterbodies - DEBUG - Setting lake outlet map based maximum upstream area.
2024-12-18 18:37:20,546 - build - wflow - INFO - No rating curve data provided. Using default storage/outflow function parameters.
2024-12-18 18:37:20,583 - build - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2024-12-18 18:37:20,584 - build - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2024-12-18 18:37:20,584 - build - dataframe - INFO - Reading riverbedsed_mapping_default csv data from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow_sediment/riverbedsed_mapping.csv
2024-12-18 18:37:20,589 - build - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2024-12-18 18:37:20,593 - build - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:20,597 - build - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:20,601 - build - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:20,605 - build - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:20,612 - build - model_api - INFO - setup_lulcmaps.lulc_fn: globcover_2009
2024-12-18 18:37:20,613 - build - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: globcover_mapping_default
2024-12-18 18:37:20,613 - build - model_api - INFO - setup_lulcmaps.planted_forest_fn: None
2024-12-18 18:37:20,613 - build - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Kext', 'PathFrac', 'Sl', 'Swood', 'USLE_C']
2024-12-18 18:37:20,613 - build - model_api - INFO - setup_lulcmaps.planted_forest_c: 0.0881
2024-12-18 18:37:20,613 - build - model_api - INFO - setup_lulcmaps.orchard_name: Orchard
2024-12-18 18:37:20,613 - build - model_api - INFO - setup_lulcmaps.orchard_c: 0.2188
2024-12-18 18:37:20,613 - build - wflow - INFO - Preparing LULC parameter maps.
2024-12-18 18:37:20,613 - build - rasterdataset - INFO - Reading globcover_2009 raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/globcover.tif
2024-12-18 18:37:20,623 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-12-18 18:37:20,624 - build - dataframe - INFO - Reading globcover_mapping_default csv data from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/lulc/globcover_mapping.csv
2024-12-18 18:37:20,630 - build - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2024-12-18 18:37:20,647 - build - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2024-12-18 18:37:20,667 - build - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2024-12-18 18:37:20,684 - build - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2024-12-18 18:37:20,701 - build - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2024-12-18 18:37:20,719 - build - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2024-12-18 18:37:20,741 - build - model_api - INFO - setup_laimaps.lai_fn: modis_lai
2024-12-18 18:37:20,741 - build - model_api - INFO - setup_laimaps.lulc_fn: None
2024-12-18 18:37:20,741 - build - model_api - INFO - setup_laimaps.lulc_sampling_method: any
2024-12-18 18:37:20,741 - build - model_api - INFO - setup_laimaps.lulc_zero_classes: []
2024-12-18 18:37:20,741 - build - model_api - INFO - setup_laimaps.buffer: 2
2024-12-18 18:37:20,741 - build - wflow - INFO - Preparing LAI maps.
2024-12-18 18:37:20,741 - build - rasterdataset - INFO - Reading modis_lai netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/modis_lai.nc
2024-12-18 18:37:20,768 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-12-18 18:37:20,769 - build - rasterdataset - DEBUG - Convert units for 1 variables.
2024-12-18 18:37:20,774 - build - landuse - INFO - Deriving LAI using average resampling (nodata=nan).
2024-12-18 18:37:20,846 - build - model_api - INFO - setup_canopymaps.canopy_fn: simard
2024-12-18 18:37:20,846 - build - wflow_sediment - INFO - Preparing canopy height map.
2024-12-18 18:37:20,847 - build - rasterdataset - INFO - Reading simard raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/simard.tif
2024-12-18 18:37:20,856 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-12-18 18:37:20,883 - build - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2024-12-18 18:37:20,883 - build - model_api - INFO - setup_soilmaps.usleK_method: renard
2024-12-18 18:37:20,883 - build - wflow_sediment - INFO - Preparing soil parameter maps.
2024-12-18 18:37:20,884 - build - rasterdataset - INFO - Reading soilgrids raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/soilgrids/{variable}.tif
2024-12-18 18:37:21,168 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-12-18 18:37:21,179 - build - rasterdataset - DEBUG - Convert units for 21 variables.
2024-12-18 18:37:21,530 - build - soilgrids - INFO - Interpolate NAN values for PercentClay
2024-12-18 18:37:21,544 - build - soilgrids - INFO - Interpolate NAN values for PercentSilt
2024-12-18 18:37:21,560 - build - soilgrids - INFO - Interpolate NAN values for PercentOC
2024-12-18 18:37:21,580 - build - soilgrids - INFO - Interpolate NAN values for ErosK
2024-12-18 18:37:21,599 - build - soilgrids - INFO - Interpolate NAN values for USLE_K
2024-12-18 18:37:21,605 - build - model_api - INFO - setup_outlets.river_only: True
2024-12-18 18:37:21,605 - build - model_api - INFO - setup_outlets.toml_output: csv
2024-12-18 18:37:21,605 - build - model_api - INFO - setup_outlets.gauge_toml_header: ['TSS']
2024-12-18 18:37:21,605 - build - model_api - INFO - setup_outlets.gauge_toml_param: ['lateral.river.SSconc']
2024-12-18 18:37:21,605 - build - wflow - INFO - Gauges locations set based on river outlets.
2024-12-18 18:37:21,609 - build - wflow - INFO - Gauges map based on catchment river outlets added.
2024-12-18 18:37:21,609 - build - wflow - INFO - Adding ['lateral.river.SSconc'] to csv section of toml.
2024-12-18 18:37:21,609 - build - model_api - INFO - setup_gauges.gauges_fn: grdc
2024-12-18 18:37:21,609 - build - model_api - INFO - setup_gauges.index_col: None
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.snap_to_river: True
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.mask: None
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.snap_uparea: False
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.max_dist: 10000.0
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.wdw: 3
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.rel_error: 0.05
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.abs_error: 50.0
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.fillna: False
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.derive_subcatch: False
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.basename: None
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.toml_output: csv
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'TSS']
2024-12-18 18:37:21,610 - build - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_riv', 'lateral.river.SSconc']
2024-12-18 18:37:21,610 - build - geodataframe - INFO - Reading grdc csv data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/grdc.csv
2024-12-18 18:37:21,614 - build - geodataframe - DEBUG - Clip intersects [11.778, 45.807, 12.745, 46.690] (EPSG:4326)
2024-12-18 18:37:21,615 - build - wflow - INFO - 3 grdc gauge locations found within domain
2024-12-18 18:37:21,980 - build - wflow - INFO - Adding ['lateral.river.q_riv', 'lateral.river.SSconc'] to csv section of toml.
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.dtype: float32
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.nodata: -999
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2024-12-18 18:37:21,980 - build - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2024-12-18 18:37:21,981 - build - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2024-12-18 18:37:21,990 - build - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment
2024-12-18 18:37:22,018 - build - wflow - INFO - Write grid to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/staticmaps.nc
2024-12-18 18:37:22,189 - build - wflow - INFO - Writing model staticgeom to file.
2024-12-18 18:37:22,230 - build - wflow - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/wflow_sediment.toml
The example above means the following: run hydromt build with:
wflow_sediment
: i.e. build a wflow sediment model./wflow_test_sediment
: output model folder-r "{'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.70, 45.35, 12.95, 46.70]}"
: derive a subbasin with its outlet at the given x,y coordinates and within the given bounds [xmin, ymin, xmax, ymax] (WGS84) snapped to a river with minimum stream order (strord) of 4. All REGION options are described in the docs-i wflow_sediment_build.yml
: model setup configuration file-d artifact_data
: use pre-defined artifact_data catalog.-vv
: give some extra verbosity (2 * v) to display feedback on screen. Now debug messages are provided.
Next we check which files have been created. The model root should contain two netcdf (.nc) files, one for the staticmaps and one for the forcing data, a wflow run configuration (.toml) file. These files are sufficient to run the wflow sediment model. In addition several geometry (.geojson) files are saved in the staticgeoms folder. Finally, the setup process is logged in the hydromt.log file.
[5]:
import os
root = "wflow_test_sediment"
for path, _, files in os.walk(root):
print(path)
for name in files:
if name.endswith(".xml"):
continue
print(f" - {name}")
wflow_test_sediment
- hydromt.log
- staticmaps.nc
- wflow_sediment.toml
- hydromt_data.yml
wflow_test_sediment/staticgeoms
- gauges_grdc.geojson
- region.geojson
- rivers.geojson
- basins_highres.geojson
- gauges.geojson
- basins.geojson
- lakes.geojson
wflow_test_sediment/instate
wflow_test_sediment/run_default
Visualize and/or inspect model schematization#
You can (copy and) adapt the following example notebooks in order to visualize your Wflow Sediment model:
The wflow plot example notebook contains scripts to visualize your model
The wflow nc to raster files example notebook contains scripts to write the nc model files to a netcdf which can be used to inspect (and modify) the model layers in e.g. QGIS.
Add Wflow Sediment layers to an existing Wflow model#
If you already have a hydrological Wflow model and you want to extend it in order to include sediment as well, then you do not need to build the wflow_sediment from scratch. You can instead update the wflow model with the additional components needed by wflow_sediment.
These components are available in the template wflow_extend_sediment.yml:
[6]:
fn_config = "wflow_extend_sediment.yml"
with open(fn_config, "r") as f:
txt = f.read()
print(txt)
setup_config: # options parsed to wflow toml file <section>.<option>
starttime: 2010-02-02T00:00:00
endtime: 2010-02-10T00:00:00
timestepsecs: 86400
input.path_forcing: inmaps-era5-2010.nc
# model.dolake: True # uncomment if there are lakes in the wflow model
# model.doreservoir: True # uncomment if there are reservoirs in the wflow model
setup_riverbedsed:
bedsed_mapping_fn: # path to a mapping csv file from streamorder to river bed particles characteristics if any, else default is used
setup_lulcmaps:
lulc_fn: globcover_2009 # source for lulc maps: {globcover, vito, corine}
lulc_mapping_fn: globcover_mapping_default # default mapping for lulc classes
setup_canopymaps:
canopy_fn: simard # source for vegetation canopy height: {simard}
setup_soilmaps:
soil_fn: soilgrids # source for soilmaps: {soilgrids}
usleK_method: renard # method to compute the USLE K factor: {renard, epic}
setup_gauges:
gauges_fn: grdc # If not None add gaugemap. Either a path or known gauges_fn: {grdc}
snap_to_river: True # If True snaps gauges from source to river
derive_subcatch: False # if True derive subcatch map based on gauges.
setup_constant_pars: # constant parameters values
c_Bagnold: 0.0000175
eros_expo: 1.5
eros_ov: 0.9
eros_spl_EUROSEM: 2.0
exp_Bagnold: 1.4
ResTrapEff: 1.0
Let’s update the hydrological Wflow model available from our example for the Piave subbasin:
[7]:
# NOTE: copy this line (without !) to your shell for more direct feedback
!hydromt update wflow_sediment "wflow_piave_subbasin" -o "./wflow_test_extend_sediment" -i wflow_extend_sediment.yml -d artifact_data -vv
2024-12-18 18:37:24,661 - update - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/hydromt.log.
2024-12-18 18:37:24,661 - update - log - INFO - HydroMT version: 0.10.0
2024-12-18 18:37:24,661 - update - main - INFO - Updating wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin (r).
2024-12-18 18:37:24,662 - update - main - INFO - Output dir: /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2024-12-18 18:37:24,662 - update - main - INFO - User settings:
2024-12-18 18:37:25,028 - update - data_catalog - INFO - Reading data catalog artifact_data latest
2024-12-18 18:37:25,028 - update - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.9/data_catalog.yml
2024-12-18 18:37:25,620 - update - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/hydromt.log.
2024-12-18 18:37:25,620 - update - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.7.1.dev0).
2024-12-18 18:37:25,620 - update - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2024-12-18 18:37:25,633 - update - model_api - ERROR - Model config file not found at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/wflow_sediment.toml
2024-12-18 18:37:25,633 - update - wflow - INFO - Read grid from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/staticmaps.nc
2024-12-18 18:37:25,685 - update - wflow - INFO - Reading model staticgeom files.
2024-12-18 18:37:25,723 - update - wflow - INFO - Read forcing from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/inmaps.nc
2024-12-18 18:37:25,739 - update - wflow - INFO - Reading model intbl files.
2024-12-18 18:37:25,739 - update - wflow - INFO - Reading model table files.
2024-12-18 18:37:25,739 - update - wflow - INFO - Model read
2024-12-18 18:37:25,740 - update - log - DEBUG - Appending log messages to file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/hydromt.log.
2024-12-18 18:37:25,742 - update - model_api - DEBUG - Setting model config options.
2024-12-18 18:37:25,742 - update - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2024-12-18 18:37:25,742 - update - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2024-12-18 18:37:25,743 - update - dataframe - INFO - Reading riverbedsed_mapping_default csv data from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow_sediment/riverbedsed_mapping.csv
2024-12-18 18:37:25,749 - update - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2024-12-18 18:37:25,753 - update - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:25,756 - update - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:25,760 - update - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:25,763 - update - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.lulc_fn: globcover_2009
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: globcover_mapping_default
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.planted_forest_fn: None
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Kext', 'PathFrac', 'Sl', 'Swood', 'USLE_C']
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.planted_forest_c: 0.0881
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.orchard_name: Orchard
2024-12-18 18:37:25,773 - update - model_api - INFO - setup_lulcmaps.orchard_c: 0.2188
2024-12-18 18:37:25,773 - update - wflow - INFO - Preparing LULC parameter maps.
2024-12-18 18:37:25,775 - update - rasterdataset - INFO - Reading globcover_2009 raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/globcover.tif
2024-12-18 18:37:25,788 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-12-18 18:37:25,789 - update - dataframe - INFO - Reading globcover_mapping_default csv data from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/lulc/globcover_mapping.csv
2024-12-18 18:37:25,909 - update - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2024-12-18 18:37:25,934 - update - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2024-12-18 18:37:25,950 - update - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2024-12-18 18:37:25,967 - update - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2024-12-18 18:37:25,983 - update - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2024-12-18 18:37:26,000 - update - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2024-12-18 18:37:26,024 - update - model_api - INFO - setup_canopymaps.canopy_fn: simard
2024-12-18 18:37:26,024 - update - wflow_sediment - INFO - Preparing canopy height map.
2024-12-18 18:37:26,026 - update - rasterdataset - INFO - Reading simard raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/simard.tif
2024-12-18 18:37:26,035 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-12-18 18:37:26,072 - update - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2024-12-18 18:37:26,072 - update - model_api - INFO - setup_soilmaps.usleK_method: renard
2024-12-18 18:37:26,072 - update - wflow_sediment - INFO - Preparing soil parameter maps.
2024-12-18 18:37:26,075 - update - rasterdataset - INFO - Reading soilgrids raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/soilgrids/{variable}.tif
2024-12-18 18:37:26,351 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-12-18 18:37:26,361 - update - rasterdataset - DEBUG - Convert units for 21 variables.
2024-12-18 18:37:26,713 - update - soilgrids - INFO - Interpolate NAN values for PercentClay
2024-12-18 18:37:26,726 - update - soilgrids - INFO - Interpolate NAN values for PercentSilt
2024-12-18 18:37:26,739 - update - soilgrids - INFO - Interpolate NAN values for PercentOC
2024-12-18 18:37:26,758 - update - soilgrids - INFO - Interpolate NAN values for ErosK
2024-12-18 18:37:26,776 - update - soilgrids - INFO - Interpolate NAN values for USLE_K
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.gauges_fn: grdc
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.index_col: None
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.snap_to_river: True
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.mask: None
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.snap_uparea: False
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.max_dist: 10000.0
2024-12-18 18:37:26,784 - update - model_api - INFO - setup_gauges.wdw: 3
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.rel_error: 0.05
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.abs_error: 50.0
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.fillna: False
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.derive_subcatch: False
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.basename: None
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.toml_output: csv
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'TSS']
2024-12-18 18:37:26,785 - update - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_riv', 'lateral.river.SSconc']
2024-12-18 18:37:26,785 - update - geodataframe - INFO - Reading grdc csv data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/grdc.csv
2024-12-18 18:37:26,790 - update - geodataframe - DEBUG - Clip intersects [11.775, 45.808, 12.742, 46.692] (EPSG:4326)
2024-12-18 18:37:26,790 - update - wflow - INFO - 3 grdc gauge locations found within domain
2024-12-18 18:37:28,529 - update - model_api - WARNING - Replacing geom: gauges_grdc
2024-12-18 18:37:28,529 - update - wflow - INFO - Adding ['lateral.river.q_riv', 'lateral.river.SSconc'] to csv section of toml.
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.dtype: float32
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.nodata: -999
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2024-12-18 18:37:28,530 - update - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2024-12-18 18:37:28,541 - update - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2024-12-18 18:37:28,587 - update - wflow - INFO - Write grid to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/staticmaps.nc
2024-12-18 18:37:28,851 - update - wflow - INFO - Writing model staticgeom to file.
2024-12-18 18:37:28,933 - update - wflow - INFO - Write forcing file
2024-12-18 18:37:28,941 - update - wflow - INFO - Process forcing; saving to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/inmaps-era5-2010.nc
[########################################] | 100% Completed | 101.02 ms
2024-12-18 18:37:29,049 - update - wflow - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/wflow_sediment.toml
The example above means the following: run hydromt update with:
wflow_sediment
: i.e. update a wflow_sediment model (in our case a wflow model but with wflow_sediment components)wflow_piave_subbasin
: hydrological wflow model folder-o "./wflow_test_extend_sediment"
: output combined wflow hydrology+sediment models-i wflow_extend_sediment.yml
: setup configuration file containing wflow sediment specific components-d artifact_data
: use the pre-defined artifact_data catalog-vv
: give some extra verbosity (2 * v) to display feedback on screen. Now debug messages are provided.