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.2.1)
- wflow_sediment (hydromt_wflow 0.2.1)
generic models (hydromt 0.6.1.dev):
- grid_model
- lumped_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 REGION
Build models from scratch.
Example usage:
--------------
To build a wflow model for a subbasin using and point coordinates snapped to cells with stream order >= 4
hydromt build wflow /path/to/model_root "{'subbasin': [-7.24, 62.09], 'strord': 4}" -i /path/to/wflow_config.ini -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 "{'bbox': [4.6891,52.9750,4.9576,53.1994]}" -i /path/to/sfincs_config.ini -d /path/to/data_catalog.yml -v
Options:
-r, --res FLOAT Model resolution in model src.
--build-base / --build-all Deprecated!
--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.
-d, --data TEXT Path to local yaml data catalog file OR name of
predefined data catalog.
--dd, --deltares-data Shortcut to add the "deltares_data" catalog
-q, --quiet Decrease verbosity.
-v, --verbose Increase verbosity.
--help Show this message and exit.
Model setup configuration#
The ini-file 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_ini_file>
. We have prepared several example ini-files which are available in the model repository examples folder and from the docs
(building a model).
Each header as shown between [...]
(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 ini file for inspection:
[3]:
fn_ini = "wflow_sediment_build.ini"
with open(fn_ini, "r") as f:
txt = f.read()
print(txt)
[global]
data_libs = [] # add optional paths to data yml files
[setup_config] # options parsed to wflow ini 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'
[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 based on GRAND: {hydro_reservoirs}
min_area = 1.0 # minimum lake area to consider [km2]
priority_jrc = True # if True then JRC data from hydroengine is used to calculate some reservoir attributes instead of the GRanD and HydroLAKES db.
[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]
bedsed_mapping_fn = None # path to a mapping csv file from streamorder to river bed particles characteristics
[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_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
!hydromt build wflow_sediment "./wflow_test_sediment" "{'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.70, 45.35, 12.95, 46.70]}" -r 0.00833 -i wflow_sediment_build.ini -d artifact_data -vv
2022-11-22 03:11:07,239 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/hydromt.log.
2022-11-22 03:11:07,239 - build - log - INFO - HydroMT version: 0.6.1.dev
2022-11-22 03:11:07,239 - build - main - INFO - Building instance of wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment.
2022-11-22 03:11:07,239 - build - main - INFO - User settings:
2022-11-22 03:11:07,290 - build - data_catalog - INFO - Reading data catalog artifact_data v0.0.6 from archive
2022-11-22 03:11:07,290 - build - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.6/data_catalog.yml
2022-11-22 03:11:07,359 - build - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.2.1).
2022-11-22 03:11:07,359 - build - model_api - DEBUG - Setting model config options.
2022-11-22 03:11:07,361 - build - model_api - DEBUG - Default config read from /usr/share/miniconda/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/wflow_sediment/wflow_sediment.toml
2022-11-22 03:11:07,361 - build - model_api - INFO - setup_basemaps.region: {'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7]}
2022-11-22 03:11:07,361 - build - model_api - INFO - setup_basemaps.res: 0.00833
2022-11-22 03:11:07,361 - build - model_api - INFO - setup_basemaps.hydrography_fn: merit_hydro
2022-11-22 03:11:07,362 - build - model_api - INFO - setup_basemaps.basin_index_fn: merit_hydro_index
2022-11-22 03:11:07,362 - build - model_api - INFO - setup_basemaps.upscale_method: ihu
2022-11-22 03:11:07,362 - build - wflow - INFO - Preparing base hydrography basemaps.
2022-11-22 03:11:07,362 - build - data_catalog - INFO - DataCatalog: Getting merit_hydro RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/merit_hydro/{variable}.tif
2022-11-22 03:11:07,483 - build - basin_mask - DEBUG - Parsed region (kind=subbasin): {'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7], 'xy': [12.2051, 45.8331]}
2022-11-22 03:11:11,351 - build - basin_mask - INFO - subbasin bbox: [11.7750, 45.8042, 12.7450, 46.6900]
2022-11-22 03:11:11,421 - build - wflow - DEBUG - Adding basins vector to staticgeoms.
2022-11-22 03:11:11,421 - build - basemaps - DEBUG - Mask in dataset assumed to represent subbasins.
2022-11-22 03:11:11,422 - build - basemaps - DEBUG - (Sub)basin at original resolution has 664756 cells.
2022-11-22 03:11:11,562 - build - basemaps - DEBUG - Burn subbasin outlet in upstream area data.
2022-11-22 03:11:11,605 - build - basemaps - INFO - Upscale flow direction data: 10x, ihu method.
2022-11-22 03:11:26,997 - build - basemaps - DEBUG - Derive stream order.
2022-11-22 03:11:27,174 - build - basemaps - DEBUG - Map shape: (106, 116); active cells: 6637.
2022-11-22 03:11:27,174 - build - basemaps - DEBUG - Outlet coordinates (1/1): (12.20750,45.83583).
2022-11-22 03:11:27,252 - build - wflow - DEBUG - Adding region vector to staticgeoms.
2022-11-22 03:11:27,256 - build - model_api - INFO - setup_rivers.hydrography_fn: merit_hydro
2022-11-22 03:11:27,256 - build - model_api - INFO - setup_rivers.river_geom_fn: rivers_lin2019_v1
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.river_upa: 30
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.rivdph_method: powlaw
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.slope_len: 2000
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.min_rivlen_ratio: 0.0
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.min_rivdph: 1
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.min_rivwth: 30
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.smooth_len: 5000
2022-11-22 03:11:27,257 - build - model_api - INFO - setup_rivers.rivman_mapping_fn: /usr/share/miniconda/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/wflow/N_river_mapping.csv
2022-11-22 03:11:27,257 - build - wflow - INFO - Preparing river maps.
2022-11-22 03:11:27,257 - build - data_catalog - INFO - DataCatalog: Getting merit_hydro RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/merit_hydro/{variable}.tif
2022-11-22 03:11:27,373 - build - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.778, 45.807, 12.745, 46.690]
2022-11-22 03:11:27,389 - build - river - DEBUG - Set river mask (min uparea: 30 km2) and prepare flow dirs.
2022-11-22 03:11:27,589 - build - river - DEBUG - Derive river length.
2022-11-22 03:11:33,854 - build - river - DEBUG - Derive river slope.
2022-11-22 03:11:34,626 - build - river - DEBUG - Derive rivwth from hydrography dataset.
2022-11-22 03:11:34,662 - build - landuse - INFO - Deriving N_River using average resampling (nodata=-999.0).
2022-11-22 03:11:34,675 - build - data_catalog - INFO - DataCatalog: Getting rivers_lin2019_v1 GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.6/rivers_lin2019_v1.gpkg
2022-11-22 03:11:34,676 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.778, 45.807, 12.745, 46.690].
2022-11-22 03:11:34,931 - build - river - DEBUG - Derive ['rivwth', 'qbankfull'] from shapefile.
2022-11-22 03:11:35,032 - build - river - DEBUG - Valid for 381/655 river cells (max dist: 392 m).
2022-11-22 03:11:37,222 - build - wflow - DEBUG - Adding rivers vector to staticgeoms.
2022-11-22 03:11:38,149 - build - model_api - INFO - setup_reservoirs.reservoirs_fn: hydro_reservoirs
2022-11-22 03:11:38,150 - build - model_api - INFO - setup_reservoirs.min_area: 1.0
2022-11-22 03:11:38,150 - build - model_api - INFO - setup_reservoirs.priority_jrc: True
2022-11-22 03:11:38,150 - build - wflow - INFO - Preparing reservoir maps.
2022-11-22 03:11:38,150 - build - data_catalog - INFO - DataCatalog: Getting hydro_reservoirs GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.6/hydro_reservoirs.gpkg
2022-11-22 03:11:38,153 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2022-11-22 03:11:38,183 - build - geodataframe - DEBUG - GeoDataFrame: Convert units for 5 columns.
2022-11-22 03:11:38,187 - build - wflow - WARNING - No reservoirs of sufficient size found within region! Skipping reservoir procedures!
2022-11-22 03:11:38,187 - build - model_api - INFO - setup_lakes.lakes_fn: hydro_lakes
2022-11-22 03:11:38,187 - build - model_api - INFO - setup_lakes.min_area: 1.0
2022-11-22 03:11:38,187 - build - wflow - INFO - Preparing lake maps.
2022-11-22 03:11:38,187 - build - data_catalog - INFO - DataCatalog: Getting hydro_lakes GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.6/hydro_lakes.gpkg
2022-11-22 03:11:38,190 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2022-11-22 03:11:38,215 - build - geodataframe - DEBUG - GeoDataFrame: Convert units for 1 columns.
2022-11-22 03:11:38,217 - build - wflow - INFO - 1 lake(s) of sufficient size found within region.
2022-11-22 03:11:38,225 - build - waterbodies - DEBUG - Setting lake outlet map based maximum upstream area.
2022-11-22 03:11:38,299 - build - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2022-11-22 03:11:38,299 - build - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2022-11-22 03:11:38,309 - build - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2022-11-22 03:11:38,321 - build - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:38,332 - build - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:38,344 - build - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:38,356 - build - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:38,373 - build - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2022-11-22 03:11:38,373 - build - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2022-11-22 03:11:38,373 - build - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Cov_River', 'Kext', 'N', 'PathFrac', 'Sl', 'Swood', 'USLE_C', 'WaterFrac']
2022-11-22 03:11:38,373 - build - wflow - INFO - Preparing LULC parameter maps.
2022-11-22 03:11:38,374 - build - data_catalog - INFO - DataCatalog: Getting globcover RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/globcover.tif
2022-11-22 03:11:38,393 - build - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.778, 45.807, 12.745, 46.690]
2022-11-22 03:11:38,413 - build - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2022-11-22 03:11:38,451 - build - landuse - INFO - Deriving Cov_River using average resampling (nodata=-999.0).
2022-11-22 03:11:38,488 - build - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2022-11-22 03:11:38,525 - build - landuse - INFO - Deriving N using average resampling (nodata=-999.0).
2022-11-22 03:11:38,562 - build - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2022-11-22 03:11:38,598 - build - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2022-11-22 03:11:38,636 - build - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2022-11-22 03:11:38,673 - build - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2022-11-22 03:11:38,709 - build - landuse - INFO - Deriving WaterFrac using average resampling (nodata=-999.0).
2022-11-22 03:11:38,757 - build - model_api - INFO - setup_laimaps.lai_fn: modis_lai
2022-11-22 03:11:38,757 - build - wflow - INFO - Preparing LAI maps.
2022-11-22 03:11:38,758 - build - data_catalog - INFO - DataCatalog: Getting modis_lai RasterDataset netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.6/modis_lai.nc
2022-11-22 03:11:38,772 - build - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.778, 45.807, 12.745, 46.690]
2022-11-22 03:11:38,785 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 1 variables.
2022-11-22 03:11:38,793 - build - landuse - INFO - Deriving LAI using average resampling (nodata=nan).
2022-11-22 03:11:38,846 - build - model_api - INFO - setup_canopymaps.canopy_fn: simard
2022-11-22 03:11:38,846 - build - wflow_sediment - INFO - Preparing canopy height map.
2022-11-22 03:11:38,847 - build - data_catalog - INFO - DataCatalog: Getting simard RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/simard.tif
2022-11-22 03:11:38,865 - build - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.778, 45.807, 12.745, 46.690]
2022-11-22 03:11:38,912 - build - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2022-11-22 03:11:38,912 - build - model_api - INFO - setup_soilmaps.usleK_method: renard
2022-11-22 03:11:38,913 - build - wflow_sediment - INFO - Preparing soil parameter maps.
2022-11-22 03:11:38,913 - build - data_catalog - INFO - DataCatalog: Getting soilgrids RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/soilgrids/{variable}.tif
2022-11-22 03:11:39,440 - build - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.778, 45.807, 12.745, 46.690]
2022-11-22 03:11:39,463 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 21 variables.
2022-11-22 03:11:39,963 - build - soilgrids - INFO - Interpolate NAN values for PercentClay
2022-11-22 03:11:39,982 - build - soilgrids - INFO - Interpolate NAN values for PercentSilt
2022-11-22 03:11:40,001 - build - soilgrids - INFO - Interpolate NAN values for PercentOC
2022-11-22 03:11:40,027 - build - soilgrids - INFO - Interpolate NAN values for ErosK
2022-11-22 03:11:40,052 - build - soilgrids - INFO - Interpolate NAN values for USLE_K
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.gauges_fn: grdc
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.source_gdf: None
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.snap_to_river: True
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.mask: None
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.derive_subcatch: False
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.derive_outlet: True
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.basename: None
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.update_toml: True
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.gauge_toml_header: None
2022-11-22 03:11:40,061 - build - model_api - INFO - setup_gauges.gauge_toml_param: None
2022-11-22 03:11:40,061 - build - wflow - INFO - Gauges locations set based on river outlets.
2022-11-22 03:11:40,069 - build - wflow - INFO - Gauges map based on catchment river outlets added.
2022-11-22 03:11:40,069 - build - data_catalog - INFO - DataCatalog: Getting grdc GeoDataFrame csv data from /home/runner/.hydromt_data/artifact_data/v0.0.6/grdc.csv
2022-11-22 03:11:40,072 - build - geodataframe - INFO - GeoDataFrame: Read csv data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2022-11-22 03:11:40,089 - build - wflow - INFO - 3 grdc gauge locations found within domain
2022-11-22 03:11:40,526 - build - wflow - INFO - Gauges map from grdc added.
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.dtype: float32
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.nodata: -999
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2022-11-22 03:11:40,526 - build - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2022-11-22 03:11:40,543 - build - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment
2022-11-22 03:11:40,552 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/wflow_sediment.toml
2022-11-22 03:11:40,606 - build - wflow - INFO - Write staticmaps to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_sediment/staticmaps.nc
2022-11-22 03:11:41,068 - 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"{'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-r 0.0083333
: build the model at a 30 arc sec (~1km) resolution-i wflow_sediment_build.ini
: 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 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_data.yml
- wflow_sediment.toml
- hydromt.log
- staticmaps.nc
wflow_test_sediment/run_default
wflow_test_sediment/instate
wflow_test_sediment/staticgeoms
- region.geojson
- lakes.geojson
- rivers.geojson
- basins.geojson
- gauges.geojson
- gauges_grdc.geojson
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.ini:
[6]:
fn_ini = "wflow_extend_sediment.ini"
with open(fn_ini, "r") as f:
txt = f.read()
print(txt)
[global]
data_libs = [] # add optional paths to data yml files
[setup_config]
# 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 = None # path to a mapping csv file from streamorder to river bed particles characteristics
[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.ini -d artifact_data -vv
2022-11-22 03:11:43,684 - update - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/hydromt.log.
2022-11-22 03:11:43,684 - update - log - INFO - HydroMT version: 0.6.1.dev
2022-11-22 03:11:43,684 - update - main - INFO - Updating wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin (r).
2022-11-22 03:11:43,684 - update - main - INFO - Output dir: /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2022-11-22 03:11:43,684 - update - main - INFO - User settings:
2022-11-22 03:11:43,735 - update - data_catalog - INFO - Reading data catalog artifact_data v0.0.6 from archive
2022-11-22 03:11:43,735 - update - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.6/data_catalog.yml
2022-11-22 03:11:43,804 - update - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/hydromt.log.
2022-11-22 03:11:43,804 - update - model_api - INFO - Initializing wflow_sediment model from hydromt_wflow (v0.2.1).
2022-11-22 03:11:43,804 - update - wflow - INFO - Read staticmaps from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/staticmaps.nc
2022-11-22 03:11:43,864 - update - wflow - INFO - Reading model intbl files.
2022-11-22 03:11:43,864 - update - wflow - INFO - Reading model staticgeom files.
2022-11-22 03:11:43,953 - update - wflow - INFO - Read forcing from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_piave_subbasin/inmaps.nc
2022-11-22 03:11:43,962 - update - wflow - INFO - Model read
2022-11-22 03:11:43,962 - update - log - DEBUG - Appending log messages to file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/hydromt.log.
2022-11-22 03:11:43,993 - update - model_api - INFO - setup_riverbedsed.bedsed_mapping_fn: None
2022-11-22 03:11:43,994 - update - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2022-11-22 03:11:44,005 - update - landuse - INFO - Deriving D50_River using average resampling (nodata=-999.0).
2022-11-22 03:11:44,017 - update - landuse - INFO - Deriving ClayF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:44,030 - update - landuse - INFO - Deriving SiltF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:44,042 - update - landuse - INFO - Deriving SandF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:44,054 - update - landuse - INFO - Deriving GravelF_River using average resampling (nodata=-999.0).
2022-11-22 03:11:44,077 - update - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2022-11-22 03:11:44,077 - update - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2022-11-22 03:11:44,077 - update - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Cov_River', 'Kext', 'N', 'PathFrac', 'Sl', 'Swood', 'USLE_C', 'WaterFrac']
2022-11-22 03:11:44,077 - update - wflow - INFO - Preparing LULC parameter maps.
2022-11-22 03:11:44,082 - update - data_catalog - INFO - DataCatalog: Getting globcover RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/globcover.tif
2022-11-22 03:11:44,101 - update - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.775, 45.808, 12.742, 46.692]
2022-11-22 03:11:44,123 - update - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2022-11-22 03:11:44,161 - update - landuse - INFO - Deriving Cov_River using average resampling (nodata=-999.0).
2022-11-22 03:11:44,199 - update - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2022-11-22 03:11:44,236 - update - landuse - INFO - Deriving N using average resampling (nodata=-999.0).
2022-11-22 03:11:44,272 - update - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2022-11-22 03:11:44,308 - update - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2022-11-22 03:11:44,345 - update - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2022-11-22 03:11:44,381 - update - landuse - INFO - Deriving USLE_C using average resampling (nodata=-999.0).
2022-11-22 03:11:44,417 - update - landuse - INFO - Deriving WaterFrac using average resampling (nodata=-999.0).
2022-11-22 03:11:44,454 - update - model_api - WARNING - Replacing staticmap: wflow_landuse
2022-11-22 03:11:44,459 - update - model_api - WARNING - Replacing staticmap: Kext
2022-11-22 03:11:44,461 - update - model_api - WARNING - Replacing staticmap: N
2022-11-22 03:11:44,464 - update - model_api - WARNING - Replacing staticmap: PathFrac
2022-11-22 03:11:44,466 - update - model_api - WARNING - Replacing staticmap: Sl
2022-11-22 03:11:44,468 - update - model_api - WARNING - Replacing staticmap: Swood
2022-11-22 03:11:44,473 - update - model_api - WARNING - Replacing staticmap: WaterFrac
2022-11-22 03:11:44,475 - update - model_api - INFO - setup_canopymaps.canopy_fn: simard
2022-11-22 03:11:44,475 - update - wflow_sediment - INFO - Preparing canopy height map.
2022-11-22 03:11:44,480 - update - data_catalog - INFO - DataCatalog: Getting simard RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/simard.tif
2022-11-22 03:11:44,498 - update - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.775, 45.808, 12.742, 46.692]
2022-11-22 03:11:44,551 - update - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2022-11-22 03:11:44,551 - update - model_api - INFO - setup_soilmaps.usleK_method: renard
2022-11-22 03:11:44,551 - update - wflow_sediment - INFO - Preparing soil parameter maps.
2022-11-22 03:11:44,555 - update - data_catalog - INFO - DataCatalog: Getting soilgrids RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.6/soilgrids/{variable}.tif
2022-11-22 03:11:45,081 - update - rasterdataset - DEBUG - RasterDataset: Clip with geom - [11.775, 45.808, 12.742, 46.692]
2022-11-22 03:11:45,104 - update - rasterdataset - DEBUG - RasterDataset: Convert units for 21 variables.
2022-11-22 03:11:45,602 - update - soilgrids - INFO - Interpolate NAN values for PercentClay
2022-11-22 03:11:45,622 - update - soilgrids - INFO - Interpolate NAN values for PercentSilt
2022-11-22 03:11:45,641 - update - soilgrids - INFO - Interpolate NAN values for PercentOC
2022-11-22 03:11:45,667 - update - soilgrids - INFO - Interpolate NAN values for ErosK
2022-11-22 03:11:45,691 - update - soilgrids - INFO - Interpolate NAN values for USLE_K
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.gauges_fn: grdc
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.source_gdf: None
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.snap_to_river: True
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.mask: None
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.derive_subcatch: False
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.derive_outlet: True
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.basename: None
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.update_toml: True
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.gauge_toml_header: None
2022-11-22 03:11:45,705 - update - model_api - INFO - setup_gauges.gauge_toml_param: None
2022-11-22 03:11:45,705 - update - wflow - INFO - Gauges locations set based on river outlets.
2022-11-22 03:11:46,722 - update - model_api - WARNING - Replacing staticmap: wflow_gauges
2022-11-22 03:11:46,728 - update - model_api - WARNING - Replacing geom: gauges
2022-11-22 03:11:46,728 - update - wflow - INFO - Gauges map based on catchment river outlets added.
2022-11-22 03:11:46,729 - update - data_catalog - INFO - DataCatalog: Getting grdc GeoDataFrame csv data from /home/runner/.hydromt_data/artifact_data/v0.0.6/grdc.csv
2022-11-22 03:11:46,732 - update - geodataframe - INFO - GeoDataFrame: Read csv data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2022-11-22 03:11:46,748 - update - wflow - INFO - 3 grdc gauge locations found within domain
2022-11-22 03:11:47,708 - update - model_api - WARNING - Replacing staticmap: wflow_gauges_grdc
2022-11-22 03:11:47,720 - update - model_api - WARNING - Replacing geom: gauges_grdc
2022-11-22 03:11:47,722 - update - model_api - DEBUG - Default config read from /usr/share/miniconda/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/wflow_sediment/wflow_sediment.toml
2022-11-22 03:11:47,723 - update - wflow - INFO - Gauges map from grdc added.
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.dtype: float32
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.nodata: -999
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.c_Bagnold: 1.75e-05
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.eros_expo: 1.5
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.eros_ov: 0.9
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.eros_spl_EUROSEM: 2.0
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.exp_Bagnold: 1.4
2022-11-22 03:11:47,723 - update - model_api - INFO - setup_constant_pars.ResTrapEff: 1.0
2022-11-22 03:11:47,744 - update - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment
2022-11-22 03:11:47,749 - update - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/wflow_sediment.toml
2022-11-22 03:11:47,903 - update - wflow - INFO - Write staticmaps to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/staticmaps.nc
2022-11-22 03:11:48,525 - update - wflow - INFO - Writing model staticgeom to file.
2022-11-22 03:11:48,782 - update - wflow - INFO - Write forcing file
2022-11-22 03:11:48,797 - update - wflow - WARNING - Not all dates found in precip_fn changing starttime to 2010-02-02 00:00:00 and endtime to 2010-02-10 00:00:00 in the toml.
2022-11-22 03:11:48,797 - update - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/wflow_sediment.toml
2022-11-22 03:11:48,810 - update - wflow - INFO - Process forcing; saving to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_extend_sediment/inmaps.nc
[########################################] | 100% Completed | 101.62 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.ini
: 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.