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.5.1.dev0)
- wflow_sediment (hydromt_wflow 0.5.1.dev0)
generic models (hydromt 0.9.5.dev0):
- 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: rivers_lin2019_v1 # 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 # source for lulc maps: {globcover, vito, corine}
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-06-07 11:17:50,013 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/hydromt.log.
2024-06-07 11:17:50,013 - build - log - INFO - HydroMT version: 0.9.5.dev0
2024-06-07 11:17:50,013 - build - main - INFO - Building instance of wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment.
2024-06-07 11:17:50,013 - build - main - INFO - User settings:
2024-06-07 11:17:50,045 - build - data_catalog - INFO - Reading data catalog artifact_data latest
2024-06-07 11:17:50,045 - build - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.9/data_catalog.yml
2024-06-07 11:17:50,634 - build - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.5.1.dev0).
2024-06-07 11:17:50,635 - build - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2024-06-07 11:17:50,643 - build - model_api - DEBUG - Setting model config options.
2024-06-07 11:17:50,645 - build - model_api - DEBUG - Default config read from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow_sediment/wflow_sediment.toml
2024-06-07 11:17:50,645 - build - model_api - INFO - setup_basemaps.region: {'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7]}
2024-06-07 11:17:50,645 - build - model_api - INFO - setup_basemaps.hydrography_fn: merit_hydro
2024-06-07 11:17:50,645 - build - model_api - INFO - setup_basemaps.basin_index_fn: merit_hydro_index
2024-06-07 11:17:50,645 - build - model_api - INFO - setup_basemaps.res: 0.00833
2024-06-07 11:17:50,645 - build - model_api - INFO - setup_basemaps.upscale_method: ihu
2024-06-07 11:17:50,645 - build - wflow - INFO - Preparing base hydrography basemaps.
2024-06-07 11:17:50,646 - 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-06-07 11:17:50,751 - 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-06-07 11:17:54,128 - build - basin_mask - INFO - subbasin bbox: [11.7750, 45.8042, 12.7450, 46.6900]
2024-06-07 11:17:54,185 - build - wflow - DEBUG - Adding basins vector to geoms.
2024-06-07 11:17:54,186 - build - basemaps - DEBUG - Mask in dataset assumed to represent subbasins.
2024-06-07 11:17:54,186 - build - basemaps - DEBUG - (Sub)basin at original resolution has 664756 cells.
2024-06-07 11:17:54,246 - build - basemaps - DEBUG - Burn subbasin outlet in upstream area data.
2024-06-07 11:17:54,273 - build - basemaps - INFO - Upscale flow direction data: 10x, ihu method.
2024-06-07 11:18:08,457 - build - basemaps - DEBUG - Derive stream order.
2024-06-07 11:18:08,614 - build - basemaps - DEBUG - Map shape: (106, 116); active cells: 6637.
2024-06-07 11:18:08,614 - build - basemaps - DEBUG - Outlet coordinates (1/1): (12.20750,45.83583).
2024-06-07 11:18:08,772 - build - wflow - DEBUG - Adding region vector to geoms.
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.args: ()
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.hydrography_fn: merit_hydro
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.river_geom_fn: rivers_lin2019_v1
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.river_upa: 30
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.rivdph_method: powlaw
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.min_rivdph: 1
2024-06-07 11:18:08,777 - build - model_api - INFO - setup_rivers.min_rivwth: 30
2024-06-07 11:18:08,778 - build - model_api - INFO - setup_rivers.slope_len: 2000
2024-06-07 11:18:08,778 - build - model_api - INFO - setup_rivers.smooth_len: 5000
2024-06-07 11:18:08,778 - build - wflow - INFO - Preparing river maps.
2024-06-07 11:18:08,779 - 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-06-07 11:18:08,867 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-06-07 11:18:08,875 - build - river - DEBUG - Set river mask (min uparea: 30 km2) and prepare flow dirs.
2024-06-07 11:18:08,973 - build - river - DEBUG - Derive river length.
2024-06-07 11:18:13,924 - build - river - DEBUG - Derive river slope.
2024-06-07 11:18:14,645 - build - river - DEBUG - Derive rivwth from hydrography dataset.
2024-06-07 11:18:14,655 - 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-06-07 11:18:14,662 - build - landuse - INFO - Deriving N_River using average resampling (nodata=-999.0).
2024-06-07 11:18:14,668 - build - geodataframe - INFO - Reading rivers_lin2019_v1 vector data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/rivers_lin2019_v1.gpkg
2024-06-07 11:18:14,691 - build - geodataframe - DEBUG - Clip intersects [11.778, 45.807, 12.745, 46.690] (EPSG:4326)
2024-06-07 11:18:14,889 - build - river - DEBUG - Derive ['rivwth', 'qbankfull'] from shapefile.
2024-06-07 11:18:14,948 - build - river - DEBUG - Valid for 381/655 river cells (max dist: 392 m).
2024-06-07 11:18:18,862 - build - wflow - DEBUG - Adding rivers vector to geoms.
2024-06-07 11:18:19,619 - build - model_api - INFO - setup_reservoirs.reservoirs_fn: hydro_reservoirs
2024-06-07 11:18:19,619 - build - model_api - INFO - setup_reservoirs.timeseries_fn: gww
2024-06-07 11:18:19,619 - build - model_api - INFO - setup_reservoirs.min_area: 1.0
2024-06-07 11:18:19,619 - build - wflow - INFO - Preparing reservoir maps.
2024-06-07 11:18:19,619 - build - geodataframe - INFO - Reading hydro_reservoirs vector data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/hydro_reservoirs.gpkg
2024-06-07 11:18:19,640 - build - geodataframe - DEBUG - Clip contains [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-06-07 11:18:19,641 - build - geodataframe - DEBUG - Convert units for 5 columns.
2024-06-07 11:18:19,643 - build - wflow - WARNING - No reservoirs of sufficient size found within region! Skipping reservoir procedures!
2024-06-07 11:18:19,643 - build - wflow - INFO - Skipping method, as no data has been found
2024-06-07 11:18:19,644 - build - model_api - INFO - setup_lakes.lakes_fn: hydro_lakes
2024-06-07 11:18:19,644 - build - model_api - INFO - setup_lakes.min_area: 1.0
2024-06-07 11:18:19,644 - build - wflow - INFO - Preparing lake maps.
2024-06-07 11:18:19,644 - build - geodataframe - INFO - Reading hydro_lakes vector data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/hydro_lakes.gpkg
2024-06-07 11:18:19,657 - build - geodataframe - DEBUG - Clip contains [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-06-07 11:18:19,658 - build - geodataframe - DEBUG - Convert units for 1 columns.
2024-06-07 11:18:19,659 - build - wflow - INFO - 1 lake(s) of sufficient size found within region.
2024-06-07 11:18:19,663 - build - waterbodies - DEBUG - Setting lake outlet map based maximum upstream area.
2024-06-07 11:18:19,673 - build - wflow - INFO - No rating curve data provided. Using default storage/outflow function parameters.
2024-06-07 11:18:19,713 - build - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2024-06-07 11:18:19,713 - build - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2024-06-07 11:18:19,714 - 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-06-07 11:18:19,720 - build - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2024-06-07 11:18:19,725 - build - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:19,730 - build - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:19,735 - build - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:19,740 - build - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.planted_forest_fn: None
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.lulc_vars: {'landuse': None, 'Kext': 'input.vertical.kext', 'PathFrac': 'input.vertical.pathfrac', 'Sl': 'input.vertical.specific_leaf', 'Swood': 'input.vertical.storage_wood', 'USLE_C': 'input.vertical.usleC'}
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.planted_forest_c: 0.0881
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.orchard_name: Orchard
2024-06-07 11:18:19,749 - build - model_api - INFO - setup_lulcmaps.orchard_c: 0.2188
2024-06-07 11:18:19,749 - build - wflow - INFO - Preparing LULC parameter maps.
2024-06-07 11:18:19,749 - build - rasterdataset - INFO - Reading globcover raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/globcover.tif
2024-06-07 11:18:19,764 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-06-07 11:18:19,764 - 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-06-07 11:18:19,772 - build - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2024-06-07 11:18:19,790 - build - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2024-06-07 11:18:19,809 - build - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2024-06-07 11:18:19,828 - build - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2024-06-07 11:18:19,847 - build - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2024-06-07 11:18:19,865 - build - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2024-06-07 11:18:19,889 - build - model_api - INFO - setup_laimaps.lai_fn: modis_lai
2024-06-07 11:18:19,889 - build - model_api - INFO - setup_laimaps.lulc_fn: None
2024-06-07 11:18:19,889 - build - model_api - INFO - setup_laimaps.lulc_sampling_method: any
2024-06-07 11:18:19,889 - build - model_api - INFO - setup_laimaps.lulc_zero_classes: []
2024-06-07 11:18:19,889 - build - model_api - INFO - setup_laimaps.buffer: 2
2024-06-07 11:18:19,889 - build - wflow - INFO - Preparing LAI maps.
2024-06-07 11:18:19,889 - build - rasterdataset - INFO - Reading modis_lai netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/modis_lai.nc
2024-06-07 11:18:19,918 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-06-07 11:18:19,919 - build - rasterdataset - DEBUG - Convert units for 1 variables.
2024-06-07 11:18:19,924 - build - landuse - INFO - Deriving LAI using average resampling (nodata=nan).
2024-06-07 11:18:19,992 - build - model_api - INFO - setup_canopymaps.canopy_fn: simard
2024-06-07 11:18:19,992 - build - wflow_sediment - INFO - Preparing canopy height map.
2024-06-07 11:18:19,993 - build - rasterdataset - INFO - Reading simard raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/simard.tif
2024-06-07 11:18:20,005 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-06-07 11:18:20,041 - build - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2024-06-07 11:18:20,041 - build - model_api - INFO - setup_soilmaps.usleK_method: renard
2024-06-07 11:18:20,041 - build - wflow_sediment - INFO - Preparing soil parameter maps.
2024-06-07 11:18:20,042 - build - rasterdataset - INFO - Reading soilgrids raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/soilgrids/{variable}.tif
2024-06-07 11:18:20,430 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-06-07 11:18:20,439 - build - rasterdataset - DEBUG - Convert units for 21 variables.
2024-06-07 11:18:20,769 - build - soilgrids - INFO - Interpolate NAN values for PercentClay
2024-06-07 11:18:20,785 - build - soilgrids - INFO - Interpolate NAN values for PercentSilt
2024-06-07 11:18:20,802 - build - soilgrids - INFO - Interpolate NAN values for PercentOC
2024-06-07 11:18:20,827 - build - soilgrids - INFO - Interpolate NAN values for ErosK
2024-06-07 11:18:20,848 - build - soilgrids - INFO - Interpolate NAN values for USLE_K
2024-06-07 11:18:20,854 - build - model_api - INFO - setup_outlets.river_only: True
2024-06-07 11:18:20,854 - build - model_api - INFO - setup_outlets.toml_output: csv
2024-06-07 11:18:20,854 - build - model_api - INFO - setup_outlets.gauge_toml_header: ['TSS']
2024-06-07 11:18:20,854 - build - model_api - INFO - setup_outlets.gauge_toml_param: ['lateral.river.SSconc']
2024-06-07 11:18:20,854 - build - wflow - INFO - Gauges locations set based on river outlets.
2024-06-07 11:18:20,861 - build - wflow - INFO - Gauges map based on catchment river outlets added.
2024-06-07 11:18:20,861 - build - wflow - INFO - Adding ['lateral.river.SSconc'] to csv section of toml.
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.gauges_fn: grdc
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.index_col: None
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.snap_to_river: True
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.mask: None
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.snap_uparea: False
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.max_dist: 10000.0
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.wdw: 3
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.rel_error: 0.05
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.abs_error: 50.0
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.fillna: False
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.derive_subcatch: False
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.basename: None
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.toml_output: csv
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'TSS']
2024-06-07 11:18:20,861 - build - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_riv', 'lateral.river.SSconc']
2024-06-07 11:18:20,862 - build - geodataframe - INFO - Reading grdc csv data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/grdc.csv
2024-06-07 11:18:20,867 - build - geodataframe - DEBUG - Clip intersects [11.778, 45.807, 12.745, 46.690] (EPSG:4326)
2024-06-07 11:18:20,867 - build - wflow - INFO - 3 grdc gauge locations found within domain
2024-06-07 11:18:21,230 - build - wflow - INFO - Adding ['lateral.river.q_riv', 'lateral.river.SSconc'] to csv section of toml.
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.dtype: float32
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.nodata: -999
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2024-06-07 11:18:21,231 - build - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2024-06-07 11:18:21,240 - build - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment
2024-06-07 11:18:21,248 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/wflow_sediment.toml
2024-06-07 11:18:21,269 - build - wflow - INFO - Write grid to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/staticmaps.nc
2024-06-07 11:18:21,449 - build - wflow - INFO - Writing model staticgeom to file.
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
- wflow_sediment.toml
- staticmaps.nc
- hydromt_data.yml
- hydromt.log
wflow_test_sediment/staticgeoms
- gauges.geojson
- rivers.geojson
- lakes.geojson
- gauges_grdc.geojson
- region.geojson
- basins_highres.geojson
- basins.geojson
wflow_test_sediment/run_default
wflow_test_sediment/instate
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 # source for lulc maps: {globcover, vito, corine}
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-06-07 11:18:23,785 - 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-06-07 11:18:23,785 - update - log - INFO - HydroMT version: 0.9.5.dev0
2024-06-07 11:18:23,785 - update - main - INFO - Updating wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin (r).
2024-06-07 11:18:23,785 - update - main - INFO - Output dir: /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2024-06-07 11:18:23,785 - update - main - INFO - User settings:
2024-06-07 11:18:23,816 - update - data_catalog - INFO - Reading data catalog artifact_data latest
2024-06-07 11:18:23,816 - update - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.9/data_catalog.yml
2024-06-07 11:18:24,403 - update - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/hydromt.log.
2024-06-07 11:18:24,404 - update - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.5.1.dev0).
2024-06-07 11:18:24,404 - update - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2024-06-07 11:18:24,412 - 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-06-07 11:18:24,413 - update - wflow - INFO - Read grid from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/staticmaps.nc
2024-06-07 11:18:24,464 - update - wflow - INFO - Reading model intbl files.
2024-06-07 11:18:24,464 - update - wflow - INFO - Reading model table files.
2024-06-07 11:18:24,465 - update - wflow - INFO - Reading model staticgeom files.
2024-06-07 11:18:24,572 - update - wflow - INFO - Read forcing from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/inmaps.nc
2024-06-07 11:18:24,590 - update - wflow - INFO - Model read
2024-06-07 11:18:24,590 - update - log - DEBUG - Appending log messages to file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/hydromt.log.
2024-06-07 11:18:24,594 - update - model_api - DEBUG - Setting model config options.
2024-06-07 11:18:24,594 - update - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2024-06-07 11:18:24,594 - update - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2024-06-07 11:18:24,595 - 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-06-07 11:18:24,602 - update - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2024-06-07 11:18:24,607 - update - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:24,611 - update - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:24,616 - update - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:24,621 - update - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.planted_forest_fn: None
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.lulc_vars: {'landuse': None, 'Kext': 'input.vertical.kext', 'PathFrac': 'input.vertical.pathfrac', 'Sl': 'input.vertical.specific_leaf', 'Swood': 'input.vertical.storage_wood', 'USLE_C': 'input.vertical.usleC'}
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.planted_forest_c: 0.0881
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.orchard_name: Orchard
2024-06-07 11:18:24,631 - update - model_api - INFO - setup_lulcmaps.orchard_c: 0.2188
2024-06-07 11:18:24,631 - update - wflow - INFO - Preparing LULC parameter maps.
2024-06-07 11:18:24,634 - update - rasterdataset - INFO - Reading globcover raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/globcover.tif
2024-06-07 11:18:24,651 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-06-07 11:18:24,652 - 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-06-07 11:18:24,825 - update - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2024-06-07 11:18:24,852 - update - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2024-06-07 11:18:24,871 - update - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2024-06-07 11:18:24,890 - update - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2024-06-07 11:18:24,908 - update - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2024-06-07 11:18:24,926 - update - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2024-06-07 11:18:24,953 - update - model_api - INFO - setup_canopymaps.canopy_fn: simard
2024-06-07 11:18:24,953 - update - wflow_sediment - INFO - Preparing canopy height map.
2024-06-07 11:18:24,956 - update - rasterdataset - INFO - Reading simard raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/simard.tif
2024-06-07 11:18:24,969 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-06-07 11:18:25,012 - update - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2024-06-07 11:18:25,012 - update - model_api - INFO - setup_soilmaps.usleK_method: renard
2024-06-07 11:18:25,012 - update - wflow_sediment - INFO - Preparing soil parameter maps.
2024-06-07 11:18:25,016 - update - rasterdataset - INFO - Reading soilgrids raster data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/soilgrids/{variable}.tif
2024-06-07 11:18:25,415 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-06-07 11:18:25,425 - update - rasterdataset - DEBUG - Convert units for 21 variables.
2024-06-07 11:18:25,795 - update - soilgrids - INFO - Interpolate NAN values for PercentClay
2024-06-07 11:18:25,810 - update - soilgrids - INFO - Interpolate NAN values for PercentSilt
2024-06-07 11:18:25,826 - update - soilgrids - INFO - Interpolate NAN values for PercentOC
2024-06-07 11:18:25,850 - update - soilgrids - INFO - Interpolate NAN values for ErosK
2024-06-07 11:18:25,869 - update - soilgrids - INFO - Interpolate NAN values for USLE_K
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.gauges_fn: grdc
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.index_col: None
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.snap_to_river: True
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.mask: None
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.snap_uparea: False
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.max_dist: 10000.0
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.wdw: 3
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.rel_error: 0.05
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.abs_error: 50.0
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.fillna: False
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.derive_subcatch: False
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.basename: None
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.toml_output: csv
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'TSS']
2024-06-07 11:18:25,877 - update - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_riv', 'lateral.river.SSconc']
2024-06-07 11:18:25,878 - update - geodataframe - INFO - Reading grdc csv data from /home/runner/.hydromt_data/artifact_data/v0.0.9/data.tar/grdc.csv
2024-06-07 11:18:25,883 - update - geodataframe - DEBUG - Clip intersects [11.775, 45.808, 12.742, 46.692] (EPSG:4326)
2024-06-07 11:18:25,884 - update - wflow - INFO - 3 grdc gauge locations found within domain
2024-06-07 11:18:27,600 - update - model_api - WARNING - Replacing geom: gauges_grdc
2024-06-07 11:18:27,602 - update - wflow - INFO - Adding ['lateral.river.q_riv', 'lateral.river.SSconc'] to csv section of toml.
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.dtype: float32
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.nodata: -999
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2024-06-07 11:18:27,603 - update - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2024-06-07 11:18:27,614 - update - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2024-06-07 11:18:27,619 - update - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/wflow_sediment.toml
2024-06-07 11:18:27,659 - update - wflow - INFO - Write grid to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/staticmaps.nc
2024-06-07 11:18:27,903 - update - wflow - INFO - Writing model staticgeom to file.
2024-06-07 11:18:28,018 - update - wflow - INFO - Write forcing file
2024-06-07 11:18:28,028 - 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 | 100.55 ms
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.