Tip

For an interactive online version click here: Binder badge

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-04-23 07:05:43,744 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/hydromt.log.
2024-04-23 07:05:43,744 - build - log - INFO - HydroMT version: 0.9.5.dev0
2024-04-23 07:05:43,744 - build - main - INFO - Building instance of wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment.
2024-04-23 07:05:43,744 - build - main - INFO - User settings:
2024-04-23 07:05:44,062 - build - wflow - WARNING - Adding a predefined data catalog as key-word argument is deprecated, add the catalog as 'deltares_data=False' to the data_libs list instead.
2024-04-23 07:05:44,084 - build - data_catalog - INFO - Reading data catalog archive artifact_data v0.0.8
2024-04-23 07:05:44,084 - build - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.8/data_catalog.yml
2024-04-23 07:05:44,128 - build - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.5.1.dev0).
2024-04-23 07:05:44,128 - build - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2024-04-23 07:05:44,135 - build - model_api - DEBUG - Setting model config options.
2024-04-23 07:05:44,136 - build - model_api - DEBUG - Default config read from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow_sediment/wflow_sediment.toml
2024-04-23 07:05:44,137 - build - model_api - INFO - setup_basemaps.region: {'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7]}
2024-04-23 07:05:44,137 - build - model_api - INFO - setup_basemaps.hydrography_fn: merit_hydro
2024-04-23 07:05:44,137 - build - model_api - INFO - setup_basemaps.basin_index_fn: merit_hydro_index
2024-04-23 07:05:44,137 - build - model_api - INFO - setup_basemaps.res: 0.00833
2024-04-23 07:05:44,137 - build - model_api - INFO - setup_basemaps.upscale_method: ihu
2024-04-23 07:05:44,137 - build - wflow - INFO - Preparing base hydrography basemaps.
2024-04-23 07:05:44,138 - build - rasterdataset - INFO - Reading merit_hydro raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/merit_hydro/{variable}.tif
2024-04-23 07:05:44,250 - 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-04-23 07:05:47,819 - build - basin_mask - INFO - subbasin bbox: [11.7750, 45.8042, 12.7450, 46.6900]
2024-04-23 07:05:47,878 - build - wflow - DEBUG - Adding basins vector to geoms.
2024-04-23 07:05:47,879 - build - basemaps - DEBUG - Mask in dataset assumed to represent subbasins.
2024-04-23 07:05:47,879 - build - basemaps - DEBUG - (Sub)basin at original resolution has 664756 cells.
2024-04-23 07:05:47,939 - build - basemaps - DEBUG - Burn subbasin outlet in upstream area data.
2024-04-23 07:05:47,967 - build - basemaps - INFO - Upscale flow direction data: 10x, ihu method.
2024-04-23 07:06:02,565 - build - basemaps - DEBUG - Derive stream order.
2024-04-23 07:06:02,728 - build - basemaps - DEBUG - Map shape: (106, 116); active cells: 6637.
2024-04-23 07:06:02,728 - build - basemaps - DEBUG - Outlet coordinates (1/1): (12.20750,45.83583).
2024-04-23 07:06:02,872 - build - wflow - DEBUG - Adding region vector to geoms.
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.args: ()
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.hydrography_fn: merit_hydro
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.river_geom_fn: rivers_lin2019_v1
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.river_upa: 30
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.rivdph_method: powlaw
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.min_rivdph: 1
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.min_rivwth: 30
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.slope_len: 2000
2024-04-23 07:06:02,878 - build - model_api - INFO - setup_rivers.smooth_len: 5000
2024-04-23 07:06:02,878 - build - wflow - INFO - Preparing river maps.
2024-04-23 07:06:02,879 - build - rasterdataset - INFO - Reading merit_hydro raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/merit_hydro/{variable}.tif
2024-04-23 07:06:02,969 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-04-23 07:06:02,976 - build - river - DEBUG - Set river mask (min uparea: 30 km2) and prepare flow dirs.
2024-04-23 07:06:03,076 - build - river - DEBUG - Derive river length.
2024-04-23 07:06:08,043 - build - river - DEBUG - Derive river slope.
2024-04-23 07:06:08,837 - build - river - DEBUG - Derive rivwth from hydrography dataset.
2024-04-23 07:06:08,845 - 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-04-23 07:06:08,851 - build - landuse - INFO - Deriving N_River using average resampling (nodata=-999.0).
2024-04-23 07:06:08,857 - build - geodataframe - INFO - Reading rivers_lin2019_v1 vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/rivers_lin2019_v1.gpkg
2024-04-23 07:06:08,881 - build - geodataframe - DEBUG - Clip intersects [11.778, 45.807, 12.745, 46.690] (EPSG:4326)
2024-04-23 07:06:09,084 - build - river - DEBUG - Derive ['rivwth', 'qbankfull'] from shapefile.
2024-04-23 07:06:09,146 - build - river - DEBUG - Valid for 381/655 river cells (max dist: 392 m).
2024-04-23 07:06:13,211 - build - wflow - DEBUG - Adding rivers vector to geoms.
2024-04-23 07:06:14,028 - build - model_api - INFO - setup_reservoirs.reservoirs_fn: hydro_reservoirs
2024-04-23 07:06:14,028 - build - model_api - INFO - setup_reservoirs.timeseries_fn: gww
2024-04-23 07:06:14,028 - build - model_api - INFO - setup_reservoirs.min_area: 1.0
2024-04-23 07:06:14,028 - build - wflow - INFO - Preparing reservoir maps.
2024-04-23 07:06:14,029 - build - geodataframe - INFO - Reading hydro_reservoirs vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/hydro_reservoirs.gpkg
2024-04-23 07:06:14,050 - build - geodataframe - DEBUG - Clip contains [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-04-23 07:06:14,052 - build - geodataframe - DEBUG - Convert units for 5 columns.
2024-04-23 07:06:14,054 - build - wflow - WARNING - No reservoirs of sufficient size found within region! Skipping reservoir procedures!
2024-04-23 07:06:14,054 - build - wflow - INFO - Skipping method, as no data has been found
2024-04-23 07:06:14,054 - build - model_api - INFO - setup_lakes.lakes_fn: hydro_lakes
2024-04-23 07:06:14,054 - build - model_api - INFO - setup_lakes.min_area: 1.0
2024-04-23 07:06:14,054 - build - wflow - INFO - Preparing lake maps.
2024-04-23 07:06:14,054 - build - geodataframe - INFO - Reading hydro_lakes vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/hydro_lakes.gpkg
2024-04-23 07:06:14,070 - build - geodataframe - DEBUG - Clip contains [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-04-23 07:06:14,071 - build - geodataframe - DEBUG - Convert units for 1 columns.
2024-04-23 07:06:14,072 - build - wflow - INFO - 1 lake(s) of sufficient size found within region.
2024-04-23 07:06:14,076 - build - waterbodies - DEBUG - Setting lake outlet map based maximum upstream area.
2024-04-23 07:06:14,086 - build - wflow - INFO - No rating curve data provided. Using default storage/outflow function parameters.
2024-04-23 07:06:14,127 - build - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2024-04-23 07:06:14,128 - build - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2024-04-23 07:06:14,128 - 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-04-23 07:06:14,134 - build - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2024-04-23 07:06:14,139 - build - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:14,144 - build - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:14,150 - build - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:14,155 - build - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:14,164 - build - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2024-04-23 07:06:14,164 - build - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2024-04-23 07:06:14,164 - build - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Cov_River', 'Kext', 'N', 'PathFrac', 'Sl', 'Swood', 'USLE_C', 'WaterFrac']
2024-04-23 07:06:14,164 - build - wflow - INFO - Preparing LULC parameter maps.
2024-04-23 07:06:14,164 - build - rasterdataset - INFO - Reading globcover raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/globcover.tif
2024-04-23 07:06:14,180 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-04-23 07:06:14,181 - 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-04-23 07:06:14,189 - build - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2024-04-23 07:06:14,208 - build - landuse - INFO - Deriving Cov_River using average resampling (nodata=-999.0).
2024-04-23 07:06:14,227 - build - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2024-04-23 07:06:14,248 - build - landuse - INFO - Deriving N using average resampling (nodata=-999.0).
2024-04-23 07:06:14,267 - build - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2024-04-23 07:06:14,286 - build - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2024-04-23 07:06:14,306 - build - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2024-04-23 07:06:14,326 - build - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2024-04-23 07:06:14,347 - build - landuse - INFO - Deriving WaterFrac using average resampling (nodata=-999.0).
2024-04-23 07:06:14,373 - build - model_api - INFO - setup_laimaps.lai_fn: modis_lai
2024-04-23 07:06:14,373 - build - wflow - INFO - Preparing LAI maps.
2024-04-23 07:06:14,373 - build - rasterdataset - INFO - Reading modis_lai netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.8/modis_lai.nc
2024-04-23 07:06:14,405 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-04-23 07:06:14,406 - build - rasterdataset - DEBUG - Convert units for 1 variables.
2024-04-23 07:06:14,411 - build - landuse - INFO - Deriving LAI using average resampling (nodata=nan).
2024-04-23 07:06:14,480 - build - model_api - INFO - setup_canopymaps.canopy_fn: simard
2024-04-23 07:06:14,480 - build - wflow_sediment - INFO - Preparing canopy height map.
2024-04-23 07:06:14,480 - build - rasterdataset - INFO - Reading simard raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/simard.tif
2024-04-23 07:06:14,494 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-04-23 07:06:14,531 - build - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2024-04-23 07:06:14,531 - build - model_api - INFO - setup_soilmaps.usleK_method: renard
2024-04-23 07:06:14,531 - build - wflow_sediment - INFO - Preparing soil parameter maps.
2024-04-23 07:06:14,532 - build - rasterdataset - INFO - Reading soilgrids raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/soilgrids/{variable}.tif
2024-04-23 07:06:14,928 - build - rasterdataset - DEBUG - Clip to [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2024-04-23 07:06:14,938 - build - rasterdataset - DEBUG - Convert units for 21 variables.
2024-04-23 07:06:15,276 - build - soilgrids - INFO - Interpolate NAN values for PercentClay
2024-04-23 07:06:15,293 - build - soilgrids - INFO - Interpolate NAN values for PercentSilt
2024-04-23 07:06:15,310 - build - soilgrids - INFO - Interpolate NAN values for PercentOC
2024-04-23 07:06:15,335 - build - soilgrids - INFO - Interpolate NAN values for ErosK
2024-04-23 07:06:15,357 - build - soilgrids - INFO - Interpolate NAN values for USLE_K
2024-04-23 07:06:15,362 - build - model_api - INFO - setup_outlets.river_only: True
2024-04-23 07:06:15,362 - build - model_api - INFO - setup_outlets.toml_output: csv
2024-04-23 07:06:15,362 - build - model_api - INFO - setup_outlets.gauge_toml_header: ['TSS']
2024-04-23 07:06:15,362 - build - model_api - INFO - setup_outlets.gauge_toml_param: ['lateral.river.SSconc']
2024-04-23 07:06:15,362 - build - wflow - INFO - Gauges locations set based on river outlets.
2024-04-23 07:06:15,369 - build - wflow - INFO - Gauges map based on catchment river outlets added.
2024-04-23 07:06:15,369 - build - wflow - INFO - Adding ['lateral.river.SSconc'] to csv section of toml.
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.gauges_fn: grdc
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.source_gdf: None
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.snap_to_river: True
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.mask: None
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.derive_subcatch: False
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.basename: None
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.toml_output: csv
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'TSS']
2024-04-23 07:06:15,369 - build - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_riv', 'lateral.river.SSconc']
2024-04-23 07:06:15,370 - build - geodataframe - INFO - Reading grdc csv data from /home/runner/.hydromt_data/artifact_data/v0.0.8/grdc.csv
2024-04-23 07:06:15,375 - build - geodataframe - DEBUG - Clip intersects [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-04-23 07:06:15,376 - build - wflow - INFO - 3 grdc gauge locations found within domain
2024-04-23 07:06:15,741 - build - wflow - INFO - Adding ['lateral.river.q_riv', 'lateral.river.SSconc'] to csv section of toml.
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.dtype: float32
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.nodata: -999
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2024-04-23 07:06:15,741 - build - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2024-04-23 07:06:15,751 - build - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment
2024-04-23 07:06:15,758 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/wflow_sediment.toml
2024-04-23 07:06:15,779 - build - wflow - INFO - Write grid to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/staticmaps.nc
2024-04-23 07:06:15,969 - 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
 - staticmaps.nc
 - hydromt_data.yml
 - wflow_sediment.toml
 - hydromt.log
wflow_test_sediment/run_default
wflow_test_sediment/staticgeoms
 - gauges_grdc.geojson
 - gauges.geojson
 - rivers.geojson
 - region.geojson
 - basins.geojson
 - lakes.geojson
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-04-23 07:06:18,493 - 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-04-23 07:06:18,493 - update - log - INFO - HydroMT version: 0.9.5.dev0
2024-04-23 07:06:18,493 - update - main - INFO - Updating wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin (r).
2024-04-23 07:06:18,494 - update - main - INFO - Output dir: /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2024-04-23 07:06:18,494 - update - main - INFO - User settings:
2024-04-23 07:06:18,813 - update - wflow - WARNING - Adding a predefined data catalog as key-word argument is deprecated, add the catalog as 'deltares_data=False' to the data_libs list instead.
2024-04-23 07:06:18,835 - update - data_catalog - INFO - Reading data catalog archive artifact_data v0.0.8
2024-04-23 07:06:18,835 - update - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.8/data_catalog.yml
2024-04-23 07:06:18,878 - update - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/hydromt.log.
2024-04-23 07:06:18,878 - update - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.5.1.dev0).
2024-04-23 07:06:18,878 - update - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2024-04-23 07:06:18,885 - 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-04-23 07:06:18,885 - update - wflow - INFO - Read grid from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/staticmaps.nc
2024-04-23 07:06:18,938 - update - wflow - INFO - Reading model intbl files.
2024-04-23 07:06:18,938 - update - wflow - INFO - Reading model table files.
2024-04-23 07:06:18,938 - update - wflow - INFO - Reading model staticgeom files.
2024-04-23 07:06:19,044 - update - wflow - INFO - Read forcing from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/inmaps.nc
2024-04-23 07:06:19,062 - update - wflow - INFO - Model read
2024-04-23 07:06:19,062 - update - log - DEBUG - Appending log messages to file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/hydromt.log.
2024-04-23 07:06:19,066 - update - model_api - DEBUG - Setting model config options.
2024-04-23 07:06:19,066 - update - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2024-04-23 07:06:19,066 - update - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2024-04-23 07:06:19,067 - 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-04-23 07:06:19,074 - update - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2024-04-23 07:06:19,079 - update - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:19,084 - update - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:19,088 - update - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:19,093 - update - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2024-04-23 07:06:19,103 - update - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2024-04-23 07:06:19,103 - update - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2024-04-23 07:06:19,104 - update - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Cov_River', 'Kext', 'N', 'PathFrac', 'Sl', 'Swood', 'USLE_C', 'WaterFrac']
2024-04-23 07:06:19,104 - update - wflow - INFO - Preparing LULC parameter maps.
2024-04-23 07:06:19,107 - update - rasterdataset - INFO - Reading globcover raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/globcover.tif
2024-04-23 07:06:19,125 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-04-23 07:06:19,125 - 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-04-23 07:06:19,241 - update - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2024-04-23 07:06:19,268 - update - landuse - INFO - Deriving Cov_River using average resampling (nodata=-999.0).
2024-04-23 07:06:19,286 - update - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2024-04-23 07:06:19,306 - update - landuse - INFO - Deriving N using average resampling (nodata=-999.0).
2024-04-23 07:06:19,325 - update - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2024-04-23 07:06:19,343 - update - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2024-04-23 07:06:19,361 - update - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2024-04-23 07:06:19,381 - update - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2024-04-23 07:06:19,400 - update - landuse - INFO - Deriving WaterFrac using average resampling (nodata=-999.0).
2024-04-23 07:06:19,430 - update - model_api - INFO - setup_canopymaps.canopy_fn: simard
2024-04-23 07:06:19,430 - update - wflow_sediment - INFO - Preparing canopy height map.
2024-04-23 07:06:19,434 - update - rasterdataset - INFO - Reading simard raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/simard.tif
2024-04-23 07:06:19,448 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-04-23 07:06:19,485 - update - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2024-04-23 07:06:19,485 - update - model_api - INFO - setup_soilmaps.usleK_method: renard
2024-04-23 07:06:19,485 - update - wflow_sediment - INFO - Preparing soil parameter maps.
2024-04-23 07:06:19,489 - update - rasterdataset - INFO - Reading soilgrids raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/soilgrids/{variable}.tif
2024-04-23 07:06:19,889 - update - rasterdataset - DEBUG - Clip to [11.775, 45.808, 12.742, 46.692] (epsg:4326))
2024-04-23 07:06:19,898 - update - rasterdataset - DEBUG - Convert units for 21 variables.
2024-04-23 07:06:20,342 - update - soilgrids - INFO - Interpolate NAN values for PercentClay
2024-04-23 07:06:20,358 - update - soilgrids - INFO - Interpolate NAN values for PercentSilt
2024-04-23 07:06:20,382 - update - soilgrids - INFO - Interpolate NAN values for PercentOC
2024-04-23 07:06:20,404 - update - soilgrids - INFO - Interpolate NAN values for ErosK
2024-04-23 07:06:20,424 - update - soilgrids - INFO - Interpolate NAN values for USLE_K
2024-04-23 07:06:20,431 - update - model_api - INFO - setup_gauges.gauges_fn: grdc
2024-04-23 07:06:20,431 - update - model_api - INFO - setup_gauges.source_gdf: None
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.snap_to_river: True
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.mask: None
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.derive_subcatch: False
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.basename: None
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.toml_output: csv
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'TSS']
2024-04-23 07:06:20,432 - update - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_riv', 'lateral.river.SSconc']
2024-04-23 07:06:20,432 - update - geodataframe - INFO - Reading grdc csv data from /home/runner/.hydromt_data/artifact_data/v0.0.8/grdc.csv
2024-04-23 07:06:20,438 - update - geodataframe - DEBUG - Clip intersects [11.775, 45.804, 12.745, 46.690] (EPSG:4326)
2024-04-23 07:06:20,439 - update - wflow - INFO - 3 grdc gauge locations found within domain
2024-04-23 07:06:22,080 - update - model_api - WARNING - Replacing geom: gauges_grdc
2024-04-23 07:06:22,082 - update - wflow - INFO - Adding ['lateral.river.q_riv', 'lateral.river.SSconc'] to csv section of toml.
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.dtype: float32
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.nodata: -999
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2024-04-23 07:06:22,083 - update - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2024-04-23 07:06:22,094 - update - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2024-04-23 07:06:22,099 - 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-04-23 07:06:22,140 - update - wflow - INFO - Write grid to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/staticmaps.nc
2024-04-23 07:06:22,383 - update - wflow - INFO - Writing model staticgeom to file.
2024-04-23 07:06:22,476 - update - wflow - INFO - Write forcing file
2024-04-23 07:06:22,486 - 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.79 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.