Tip

For an interactive online version click here: Binder badge

Build a Wflow model from scratch#

This notebook demonstrates how to prepare Wflow model from scratch 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 model is recognized by HydroMT

[1]:
# this should return "wflow, wflow_sediment"
# as well as the generic HydroMT models "grid_model, lumped_model, network_model, (mesh_model)"
!hydromt --models
model plugins:
 - wflow (hydromt_wflow 0.3.0)
 - wflow_sediment (hydromt_wflow 0.3.0)
generic models (hydromt 0.8.1.dev0):
 - 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

  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.ini  -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.ini  -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.

Setup Wflow model base layers#

[3]:
# 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 .ini file under the setup_basemap header
!hydromt build wflow "./wflow_test_base" -r "{'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.70, 45.35, 12.95, 46.70]}" -v -d artifact_data
2023-07-27 10:06:13,551 - build - log - INFO - HydroMT version: 0.8.1.dev0
2023-07-27 10:06:13,551 - build - main - INFO - Building instance of wflow model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_base.
2023-07-27 10:06:13,551 - build - main - INFO - User settings:
2023-07-27 10:06:13,723 - build - data_catalog - INFO - Reading data catalog artifact_data v0.0.8 from archive
2023-07-27 10:06:15,900 - build - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.8/data_catalog.yml
2023-07-27 10:06:15,974 - build - model_api - INFO - Initializing wflow model from hydromt_wflow (v0.3.0).
2023-07-27 10:06:15,974 - build - data_catalog - INFO - Parsing data catalog from /usr/share/miniconda3/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/parameters_data.yml
2023-07-27 10:06:15,987 - build - model_api - INFO - setup_basemaps.region: {'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7]}
2023-07-27 10:06:15,987 - build - model_api - INFO - setup_basemaps.res: 0.008333333333333333
2023-07-27 10:06:15,987 - build - model_api - INFO - setup_basemaps.hydrography_fn: merit_hydro
2023-07-27 10:06:15,987 - build - model_api - INFO - setup_basemaps.basin_index_fn: merit_hydro_index
2023-07-27 10:06:15,987 - build - model_api - INFO - setup_basemaps.upscale_method: ihu
2023-07-27 10:06:15,987 - build - wflow - INFO - Preparing base hydrography basemaps.
2023-07-27 10:06:15,987 - build - data_catalog - INFO - DataCatalog: Getting merit_hydro RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/merit_hydro/{variable}.tif
2023-07-27 10:06:19,999 - build - basin_mask - INFO - subbasin bbox: [11.7750, 45.8042, 12.7450, 46.6900]
2023-07-27 10:06:20,215 - build - basemaps - INFO - Upscale flow direction data: 10x, ihu method.
2023-07-27 10:06:36,292 - build - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_base
2023-07-27 10:06:36,295 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_base/wflow_sbm.toml
2023-07-27 10:06:36,323 - build - wflow - INFO - Write staticmaps to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_base/staticmaps.nc
corrupted size vs. prev_size
Aborted (core dumped)

The example above means the following: run hydromt build with:

  • wflow : i.e. build a Wflow model

  • ./wflow_test_base : 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

  • -vv : give some extra verbosity (2 * v) to display feedback on screen. Now debug messages are provided.

NOTE: As we did not specify a model configuration, only the base maps (topography and hydrography) have been setup using default parameters. To build a complete model we need the use a configuraton ini-file.

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 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 components).

We will load the default wflow build ini file for inspection:

[4]:
fn_ini = "wflow_build.ini"
with open(fn_ini, "r") as f:
    txt = f.read()
print(txt)
[setup_config]                  # options parsed to wflow ini file <section>.<option>
starttime = 2010-01-01T00:00:00
endtime = 2010-03-31T00:00:00
timestepsecs = 86400
input.path_forcing = inmaps-era5-2010.nc

[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]
# river_routing    = local-inertial   # {'kinematic-wave', 'local-inertial'}

# [setup_floodplains] # if 2D floodplains are required
# hydrography_fn   = merit_hydro      # source hydrography data, should correspond to hydrography_fn in setup_basemaps
# floodplain_type = 2d #  # If two-dimensional floodplains are required
# elevtn_map = wflow_dem  # {'wflow_dem', 'dem_subgrid'}

# [setup_floodplains] # if 1D floodplains are required
# hydrography_fn   = merit_hydro      # source hydrography data, should correspond to hydrography_fn in setup_basemaps
# floodplain_type = 1d    # If one-dimensional floodplains are required
# flood_depths     = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0] # flood depths at which a volume is derived


[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        = 10.0          # minimum reservoir area to consider [km2]

[setup_glaciers]
glaciers_fn     = rgi           # source for glaciers based on Randolph Glacier Inventory {rgi}
min_area        = 1.0           # minimum glacier area to consider [km2]

[setup_lulcmaps]
lulc_fn         = globcover     # source for lulc maps: {globcover, vito, corine}

[setup_laimaps]
lai_fn          = modis_lai     # source for LAI: {modis_lai}

[setup_soilmaps]
soil_fn         = soilgrids     # source for soilmaps: {soilgrids}
ptf_ksatver     = brakensiek    # pedotransfer function to calculate hydraulic conductivity: {brakensiek, cosby}

[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_precip_forcing]
precip_fn       = era5          # source for precipitation.
precip_clim_fn  = None          # source for high resolution climatology to correct precipitation.

[setup_temp_pet_forcing]
temp_pet_fn     = era5          # source for temperature and potential evapotranspiration.
press_correction= True          # if True temperature is corrected with elevation lapse rate.
temp_correction = True          # if True pressure is corrected with elevation lapse rate.
dem_forcing_fn  = era5_orography # source of elevation grid corresponding to temp_pet_fn. Used for lapse rate correction.
pet_method      = debruin       # method to compute PET: {debruin, makkink}
skip_pet        = False         # if True, only temperature is prepared.

[setup_constant_pars]
KsatHorFrac=100
Cfmax = 3.75653
cf_soil = 0.038
EoverR = 0.11
InfiltCapPath = 5
InfiltCapSoil = 600
MaxLeakage = 0
rootdistpar = -500
TT = 0
TTI = 2
TTM = 0
WHC = 0.1
G_Cfmax = 5.3
G_SIfrac = 0.002
G_TT = 1.3

Data for model setup#

The <...>_fn arguments correspond to a data source from the DataCatalog which is based on a yml-file with references to the data paths/urls and how the data should be read. This file can be provided to hydromt using -d <path_to_yml_file>.

By default, the pre-defined artifact_data catalog containing some example data for the Piave basin will be downloaded to ~/.hydromt_data/ which is also used for this example. An overview of the available example data is provided here This example data is a based on the data which is available from the Deltares p-drive. If you have acces to this drive, a pre-configured catalog file can be loaded using the -d deltares_data pre-defined catalog.

More background how to write a data catalog yml file can be found in the HydroMT core docs

Setup complete Wflow model#

[5]:
# NOTE: copy this line (without !) to your shell for more direct feedback
!hydromt build wflow "./wflow_test_full" -r "{'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.70, 45.35, 12.95, 46.70]}" -i wflow_build.ini -d artifact_data -vv
2023-07-27 10:06:55,831 - build - log - DEBUG - Writing log messages to new file /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full/hydromt.log.
2023-07-27 10:06:55,831 - build - log - INFO - HydroMT version: 0.8.1.dev0
2023-07-27 10:06:55,831 - build - main - INFO - Building instance of wflow model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full.
2023-07-27 10:06:55,831 - build - main - INFO - User settings:
2023-07-27 10:06:55,901 - build - data_catalog - INFO - Reading data catalog artifact_data v0.0.8 from archive
2023-07-27 10:06:55,902 - build - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt_data/artifact_data/v0.0.8/data_catalog.yml
2023-07-27 10:06:55,979 - build - model_api - INFO - Initializing wflow model from hydromt_wflow (v0.3.0).
2023-07-27 10:06:55,979 - build - data_catalog - INFO - Parsing data catalog from /usr/share/miniconda3/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/parameters_data.yml
2023-07-27 10:06:55,993 - build - model_api - DEBUG - Setting model config options.
2023-07-27 10:06:55,995 - build - model_api - DEBUG - Default config read from /usr/share/miniconda3/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/wflow/wflow_sbm.toml
2023-07-27 10:06:55,995 - build - model_api - INFO - setup_basemaps.region: {'subbasin': [12.2051, 45.8331], 'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7]}
2023-07-27 10:06:55,995 - build - model_api - INFO - setup_basemaps.res: 0.00833
2023-07-27 10:06:55,995 - build - model_api - INFO - setup_basemaps.hydrography_fn: merit_hydro
2023-07-27 10:06:55,995 - build - model_api - INFO - setup_basemaps.basin_index_fn: merit_hydro_index
2023-07-27 10:06:55,995 - build - model_api - INFO - setup_basemaps.upscale_method: ihu
2023-07-27 10:06:55,995 - build - wflow - INFO - Preparing base hydrography basemaps.
2023-07-27 10:06:55,995 - build - data_catalog - INFO - DataCatalog: Getting merit_hydro RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/merit_hydro/{variable}.tif
2023-07-27 10:06:56,127 - build - basin_mask - DEBUG - Parsed region (kind=subbasin): {'strord': 4, 'bounds': [11.7, 45.35, 12.95, 46.7], 'xy': [12.2051, 45.8331]}
2023-07-27 10:06:59,963 - build - basin_mask - INFO - subbasin bbox: [11.7750, 45.8042, 12.7450, 46.6900]
2023-07-27 10:07:00,052 - build - wflow - DEBUG - Adding basins vector to staticgeoms.
2023-07-27 10:07:00,053 - build - basemaps - DEBUG - Mask in dataset assumed to represent subbasins.
2023-07-27 10:07:00,054 - build - basemaps - DEBUG - (Sub)basin at original resolution has 664756 cells.
2023-07-27 10:07:00,138 - build - basemaps - DEBUG - Burn subbasin outlet in upstream area data.
2023-07-27 10:07:00,182 - build - basemaps - INFO - Upscale flow direction data: 10x, ihu method.
2023-07-27 10:07:15,988 - build - basemaps - DEBUG - Derive stream order.
2023-07-27 10:07:16,193 - build - basemaps - DEBUG - Map shape: (106, 116); active cells: 6637.
2023-07-27 10:07:16,193 - build - basemaps - DEBUG - Outlet coordinates (1/1): (12.20750,45.83583).
2023-07-27 10:07:16,291 - build - wflow - DEBUG - Adding region vector to staticgeoms.
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.hydrography_fn: merit_hydro
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.river_geom_fn: rivers_lin2019_v1
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.river_upa: 30
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.rivdph_method: powlaw
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.slope_len: 2000
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.min_rivlen_ratio: 0.0
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.min_rivdph: 1
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.min_rivwth: 30
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.smooth_len: 5000
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.rivman_mapping_fn: roughness_river_mapping_default
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.elevtn_map: wflow_dem
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.river_routing: kinematic-wave
2023-07-27 10:07:16,297 - build - model_api - INFO - setup_rivers.connectivity: 8
2023-07-27 10:07:16,297 - build - wflow - INFO - Preparing river maps.
2023-07-27 10:07:16,298 - build - data_catalog - INFO - DataCatalog: Getting merit_hydro RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/merit_hydro/{variable}.tif
2023-07-27 10:07:16,416 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2023-07-27 10:07:16,431 - build - river - DEBUG - Set river mask (min uparea: 30 km2) and prepare flow dirs.
2023-07-27 10:07:16,575 - build - river - DEBUG - Derive river length.
2023-07-27 10:07:23,149 - build - river - DEBUG - Derive river slope.
2023-07-27 10:07:23,833 - build - river - DEBUG - Derive rivwth from hydrography dataset.
2023-07-27 10:07:23,842 - build - data_catalog - INFO - DataCatalog: Getting roughness_river_mapping_default DataFrame csv data from /usr/share/miniconda3/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/wflow/N_river_mapping.csv
2023-07-27 10:07:23,843 - build - dataframe - INFO - DataFrame: Read csv data.
2023-07-27 10:07:23,850 - build - landuse - INFO - Deriving N_River using average resampling (nodata=-999.0).
2023-07-27 10:07:23,861 - build - data_catalog - INFO - DataCatalog: Getting rivers_lin2019_v1 GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/rivers_lin2019_v1.gpkg
2023-07-27 10:07:23,862 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.778, 45.807, 12.745, 46.690].
2023-07-27 10:07:24,122 - build - river - DEBUG - Derive ['rivwth', 'qbankfull'] from shapefile.
2023-07-27 10:07:24,203 - build - river - DEBUG - Valid for 381/655 river cells (max dist: 392 m).
2023-07-27 10:07:27,592 - build - wflow - DEBUG - Adding rivers vector to staticgeoms.
2023-07-27 10:07:28,398 - build - model_api - INFO - setup_reservoirs.reservoirs_fn: hydro_reservoirs
2023-07-27 10:07:28,398 - build - model_api - INFO - setup_reservoirs.timeseries_fn: gww
2023-07-27 10:07:28,398 - build - model_api - INFO - setup_reservoirs.min_area: 1.0
2023-07-27 10:07:28,398 - build - wflow - INFO - Preparing reservoir maps.
2023-07-27 10:07:28,398 - build - data_catalog - INFO - DataCatalog: Getting hydro_reservoirs GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/hydro_reservoirs.gpkg
2023-07-27 10:07:28,401 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2023-07-27 10:07:28,432 - build - geodataframe - DEBUG - GeoDataFrame: Convert units for 5 columns.
2023-07-27 10:07:28,437 - build - wflow - WARNING - No reservoirs of sufficient size found within region! Skipping reservoir procedures!
2023-07-27 10:07:28,437 - build - model_api - INFO - setup_lakes.lakes_fn: hydro_lakes
2023-07-27 10:07:28,437 - build - model_api - INFO - setup_lakes.rating_curve_fns: None
2023-07-27 10:07:28,437 - build - model_api - INFO - setup_lakes.min_area: 10.0
2023-07-27 10:07:28,437 - build - model_api - INFO - setup_lakes.add_maxstorage: False
2023-07-27 10:07:28,437 - build - wflow - INFO - Preparing lake maps.
2023-07-27 10:07:28,438 - build - data_catalog - INFO - DataCatalog: Getting hydro_lakes GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/hydro_lakes.gpkg
2023-07-27 10:07:28,440 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2023-07-27 10:07:28,464 - build - geodataframe - DEBUG - GeoDataFrame: Convert units for 1 columns.
2023-07-27 10:07:28,467 - build - wflow - WARNING - No lakes of sufficient size found within region! Skipping lake procedures!
2023-07-27 10:07:28,467 - build - model_api - INFO - setup_glaciers.glaciers_fn: rgi
2023-07-27 10:07:28,467 - build - model_api - INFO - setup_glaciers.min_area: 1.0
2023-07-27 10:07:28,468 - build - wflow - INFO - Preparing glacier maps.
2023-07-27 10:07:28,468 - build - data_catalog - INFO - DataCatalog: Getting rgi GeoDataFrame vector data from /home/runner/.hydromt_data/artifact_data/v0.0.8/rgi.gpkg
2023-07-27 10:07:28,470 - build - geodataframe - INFO - GeoDataFrame: Read vector data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2023-07-27 10:07:28,503 - build - wflow - INFO - 1 glaciers of sufficient size found within region.
2023-07-27 10:07:28,518 - build - glaciers - DEBUG - Creating vector grid for calculating glacier fraction and storage per grid cell
2023-07-27 10:07:28,784 - build - glaciers - DEBUG - Setting glacierfrac and store values per glacier.
2023-07-27 10:07:30,353 - build - model_api - INFO - setup_lulcmaps.lulc_fn: globcover
2023-07-27 10:07:30,353 - build - model_api - INFO - setup_lulcmaps.lulc_mapping_fn: None
2023-07-27 10:07:30,353 - build - model_api - INFO - setup_lulcmaps.lulc_vars: ['landuse', 'Kext', 'N', 'PathFrac', 'RootingDepth', 'Sl', 'Swood', 'WaterFrac']
2023-07-27 10:07:30,353 - build - wflow - INFO - Preparing LULC parameter maps.
2023-07-27 10:07:30,354 - build - data_catalog - INFO - DataCatalog: Getting globcover RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/globcover.tif
2023-07-27 10:07:30,371 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2023-07-27 10:07:30,373 - build - data_catalog - INFO - DataCatalog: Getting globcover_mapping_default DataFrame csv data from /usr/share/miniconda3/envs/hydromt-wflow/lib/python3.9/site-packages/hydromt_wflow/data/lulc/globcover_mapping.csv
2023-07-27 10:07:30,373 - build - dataframe - INFO - DataFrame: Read csv data.
2023-07-27 10:07:30,381 - build - landuse - INFO - Deriving landuse using nearest resampling (nodata=230).
2023-07-27 10:07:30,440 - build - landuse - INFO - Deriving Kext using average resampling (nodata=-999.0).
2023-07-27 10:07:30,491 - build - landuse - INFO - Deriving N using average resampling (nodata=-999.0).
2023-07-27 10:07:30,541 - build - landuse - INFO - Deriving PathFrac using average resampling (nodata=-999.0).
2023-07-27 10:07:30,592 - build - landuse - INFO - Deriving RootingDepth using average resampling (nodata=-999.0).
2023-07-27 10:07:30,644 - build - landuse - INFO - Deriving Sl using average resampling (nodata=-999.0).
2023-07-27 10:07:30,695 - build - landuse - INFO - Deriving Swood using average resampling (nodata=-999.0).
2023-07-27 10:07:30,746 - build - landuse - INFO - Deriving WaterFrac using average resampling (nodata=-999.0).
2023-07-27 10:07:30,804 - build - model_api - INFO - setup_laimaps.lai_fn: modis_lai
2023-07-27 10:07:30,804 - build - wflow - INFO - Preparing LAI maps.
2023-07-27 10:07:30,805 - build - data_catalog - INFO - DataCatalog: Getting modis_lai RasterDataset netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.8/modis_lai.nc
2023-07-27 10:07:30,876 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2023-07-27 10:07:30,878 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 1 variables.
2023-07-27 10:07:30,884 - build - landuse - INFO - Deriving LAI using average resampling (nodata=nan).
2023-07-27 10:07:30,947 - build - model_api - INFO - setup_soilmaps.soil_fn: soilgrids
2023-07-27 10:07:30,947 - build - model_api - INFO - setup_soilmaps.ptf_ksatver: brakensiek
2023-07-27 10:07:30,947 - build - wflow - INFO - Preparing soil parameter maps.
2023-07-27 10:07:30,948 - build - data_catalog - INFO - DataCatalog: Getting soilgrids RasterDataset raster data from /home/runner/.hydromt_data/artifact_data/v0.0.8/soilgrids/{variable}.tif
2023-07-27 10:07:31,505 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2023-07-27 10:07:31,516 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 21 variables.
2023-07-27 10:07:31,822 - build - soilgrids - INFO - calculate and resample thetaS
2023-07-27 10:07:31,991 - build - soilgrids - INFO - calculate and resample thetaR
2023-07-27 10:07:32,199 - build - soilgrids - INFO - calculate and resample KsatVer
2023-07-27 10:07:32,247 - build - soilgrids - INFO - calculate and resample pore size distribution index
2023-07-27 10:07:32,337 - build - soilgrids - INFO - fit z - log(KsatVer) with numpy linalg regression (y = b*x) -> M_
2023-07-27 10:07:32,852 - build - soilgrids - INFO - fit zi - Ksat with curve_fit (scipy.optimize) -> M
2023-07-27 10:07:36,781 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for thetaS
2023-07-27 10:07:36,939 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for thetaR
2023-07-27 10:07:37,055 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for SoilThickness
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:37,080 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for SoilMinThickness
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:37,100 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for c
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:37,292 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer
2023-07-27 10:07:37,343 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_0.0cm
2023-07-27 10:07:37,393 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_5.0cm
2023-07-27 10:07:37,443 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_15.0cm
2023-07-27 10:07:37,493 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_30.0cm
2023-07-27 10:07:37,544 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_60.0cm
2023-07-27 10:07:37,595 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_100.0cm
2023-07-27 10:07:37,648 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for KsatVer_200.0cm
2023-07-27 10:07:37,699 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for M_original_
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:37,873 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for M_
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:38,038 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for f_
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:38,223 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for M_original
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:38,389 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for M
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:38,554 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for f
No numerical nodata value found, skipping set_nodata
2023-07-27 10:07:38,728 - build - soilgrids - DEBUG - Interpolate nodata (NaN) values for wflow_soil
2023-07-27 10:07:38,849 - build - model_api - INFO - setup_outlets.river_only: True
2023-07-27 10:07:38,849 - build - model_api - INFO - setup_outlets.toml_output: csv
2023-07-27 10:07:38,849 - build - model_api - INFO - setup_outlets.gauge_toml_header: ['Q']
2023-07-27 10:07:38,849 - build - model_api - INFO - setup_outlets.gauge_toml_param: ['lateral.river.q_av']
2023-07-27 10:07:38,849 - build - wflow - INFO - Gauges locations set based on river outlets.
2023-07-27 10:07:38,855 - build - wflow - INFO - Gauges map based on catchment river outlets added.
2023-07-27 10:07:38,855 - build - wflow - INFO - Adding ['lateral.river.q_av'] to csv section of toml.
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.gauges_fn: grdc
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.index_col: None
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.snap_to_river: True
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.mask: None
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.snap_uparea: False
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.max_dist: 10000.0
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.wdw: 3
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.rel_error: 0.05
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.derive_subcatch: False
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.basename: None
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.toml_output: csv
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.gauge_toml_header: ['Q', 'P']
2023-07-27 10:07:38,856 - build - model_api - INFO - setup_gauges.gauge_toml_param: ['lateral.river.q_av', 'vertical.precipitation']
2023-07-27 10:07:38,856 - build - data_catalog - INFO - DataCatalog: Getting grdc GeoDataFrame csv data from /home/runner/.hydromt_data/artifact_data/v0.0.8/grdc.csv
2023-07-27 10:07:38,859 - build - geodataframe - INFO - GeoDataFrame: Read csv data and clip to geom (epsg:4326) [11.775, 45.804, 12.745, 46.690].
2023-07-27 10:07:38,873 - build - wflow - INFO - 3 grdc gauge locations found within domain
2023-07-27 10:07:39,322 - build - wflow - INFO - Adding ['lateral.river.q_av', 'vertical.precipitation'] to csv section of toml.
2023-07-27 10:07:39,323 - build - model_api - INFO - setup_precip_forcing.precip_fn: era5
2023-07-27 10:07:39,323 - build - model_api - INFO - setup_precip_forcing.precip_clim_fn: None
2023-07-27 10:07:39,323 - build - model_api - INFO - setup_precip_forcing.chunksize: None
2023-07-27 10:07:39,323 - build - data_catalog - INFO - DataCatalog: Getting era5 RasterDataset netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.8/era5.nc
2023-07-27 10:07:39,339 - build - rasterdataset - DEBUG - RasterDataset: Shifting time labels with 86400 sec.
2023-07-27 10:07:39,341 - build - rasterdataset - DEBUG - RasterDataset: Slicing time dim ('2010-01-01T00:00:00', '2010-03-31T00:00:00')
2023-07-27 10:07:39,348 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2023-07-27 10:07:39,349 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 1 variables.
2023-07-27 10:07:39,427 - build - model_api - INFO - setup_temp_pet_forcing.temp_pet_fn: era5
2023-07-27 10:07:39,427 - build - model_api - INFO - setup_temp_pet_forcing.pet_method: debruin
2023-07-27 10:07:39,427 - build - model_api - INFO - setup_temp_pet_forcing.press_correction: True
2023-07-27 10:07:39,427 - build - model_api - INFO - setup_temp_pet_forcing.temp_correction: True
2023-07-27 10:07:39,427 - build - model_api - INFO - setup_temp_pet_forcing.wind_correction: True
2023-07-27 10:07:39,427 - build - model_api - INFO - setup_temp_pet_forcing.wind_altitude: 10
2023-07-27 10:07:39,428 - build - model_api - INFO - setup_temp_pet_forcing.reproj_method: nearest_index
2023-07-27 10:07:39,428 - build - model_api - INFO - setup_temp_pet_forcing.dem_forcing_fn: era5_orography
2023-07-27 10:07:39,428 - build - model_api - INFO - setup_temp_pet_forcing.skip_pet: False
2023-07-27 10:07:39,428 - build - model_api - INFO - setup_temp_pet_forcing.chunksize: None
2023-07-27 10:07:39,428 - build - data_catalog - INFO - DataCatalog: Getting era5 RasterDataset netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.8/era5.nc
2023-07-27 10:07:39,441 - build - rasterdataset - DEBUG - RasterDataset: Shifting time labels with 86400 sec.
2023-07-27 10:07:39,442 - build - rasterdataset - DEBUG - RasterDataset: Slicing time dim ('2010-01-01T00:00:00', '2010-03-31T00:00:00')
2023-07-27 10:07:39,450 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.778, 45.807, 12.745, 46.690] (epsg:4326))
2023-07-27 10:07:39,452 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 4 variables.
2023-07-27 10:07:39,478 - build - data_catalog - INFO - DataCatalog: Getting era5_orography RasterDataset netcdf data from /home/runner/.hydromt_data/artifact_data/v0.0.8/era5_orography.nc
2023-07-27 10:07:39,492 - build - rasterdataset - DEBUG - RasterDataset: Clip with bbox - [11.625, 45.625, 12.875, 46.875] (epsg:4326))
2023-07-27 10:07:39,493 - build - rasterdataset - DEBUG - RasterDataset: Convert units for 1 variables.
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.dtype: float32
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.nodata: -999
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.KsatHorFrac: 100
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.Cfmax: 3.75653
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.cf_soil: 0.038
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.EoverR: 0.11
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.InfiltCapPath: 5
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.InfiltCapSoil: 600
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.MaxLeakage: 0
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.rootdistpar: -500
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.TT: 0
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.TTI: 2
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.TTM: 0
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.WHC: 0.1
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.G_Cfmax: 5.3
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.G_SIfrac: 0.002
2023-07-27 10:07:39,747 - build - model_api - INFO - setup_constant_pars.G_TT: 1.3
2023-07-27 10:07:39,781 - build - wflow - INFO - Write model data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full
2023-07-27 10:07:39,795 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full/wflow_sbm.toml
2023-07-27 10:07:39,882 - build - wflow - INFO - Write staticmaps to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full/staticmaps.nc
2023-07-27 10:07:40,169 - build - wflow - INFO - Writing model staticgeom to file.
2023-07-27 10:07:40,308 - build - wflow - INFO - Write forcing file
2023-07-27 10:07:40,315 - build - wflow - WARNING - Not all dates found in precip_fn changing starttime to 2010-02-02 00:00:00 and endtime to 2010-02-15 00:00:00 in the toml.
2023-07-27 10:07:40,315 - build - model_api - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full/wflow_sbm.toml
2023-07-27 10:07:40,329 - build - wflow - INFO - Process forcing; saving to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/wflow_test_full/inmaps-era5-2010.nc
[########################################] | 100% Completed | 102.20 ms
malloc(): mismatching next->prev_size (unsorted)
Aborted (core dumped)

With this example we build a complete Wflow model including forcing. Compared to the previous hydromt build we have added: * -i wflow_build.ini : setup configuration file including all components to build and their arguments

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 model. In addition several geometry (.geojson) files are saved in the staticgeoms folder. Finally, the setup process is logged in the hydromt.log file.

[6]:
import os

root = "wflow_test_full"
for path, _, files in os.walk(root):
    print(path)
    for name in files:
        if name.endswith(".xml"):
            continue
        print(f" - {name}")
wflow_test_full
 - hydromt_data.yml
 - hydromt.log
 - staticmaps.nc
 - inmaps-era5-2010.nc
 - wflow_sbm.toml
wflow_test_full/run_default
wflow_test_full/instate
wflow_test_full/staticgeoms
 - gauges_grdc.geojson
 - basins.geojson
 - gauges.geojson
 - rivers.geojson
 - region.geojson
 - glaciers.geojson

Visualize and/or inspect model schematization#

  • 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.