Tip

For an interactive online version click here: Binder badge

Upgrade your model to Wflow.jl version 1#

To ease the process of upgrading your Wflow.jl model to version 1+, HydroMT includes an upgrade function that helps you convert your model very easily: upgrade_to_v1_wflow.

For sbm type of models, the main difference between Wflow version 0.8.1 and less or Wflow version 1.0.0 and more is that the TOML file structure was updated into new sections and standard names are used to link to internal variable names in the code. For example lateral.river.q_av is now *river_water__volume_flow_rate*.

For sediment type of models, apart from the difference in the TOML file, estimation of some of the parameters has been moved outside of the Wflow.jl code and into HydroMT-Wflow. This allows the user to more easily adjust values of these parameters if they have local data or calibrate some parameters more easily.

The upgrade_to_v1_wflow function directly convert the TOML file to v1 format and in the case of wflow_sediment also calls again setup_soilmaps and setup_riverbedsed functions to create the new required parameters.

Let’s see how you can use this function.

Upgrading a Wflow SBM model#

We can call the upgrade_to_v1_wflow function using the update CLI of HydroMT. Here is the configuration file that we will use:

[1]:
fn_config = "wflow_update_v1_sbm.yml"
with open(fn_config, "r") as f:
    txt = f.read()
print(txt)
global:
  config_filename: wflow_sbm_v0x.toml

steps:
  - upgrade_to_v1_wflow:

  - write_grid:
      filename: staticmaps_v1.nc

  - write_config:
      filename: wflow_sbm_v1.toml

In this config, we start by setting the name of the TOML file of the version 0x model (if different than wflow_sbm.toml), call the upgrade_to_v1_wflow method, and then save the updated TOML file into a new wflow_sbm_v1.toml file.

Note that if you use the standard wflow_sbm.toml name and do not mind it being overwritten, the above example can be reduced into only calling upgrade_to_v1_wflow.

Let’s now call HydroMT update to update our old config (in this case we do not need a data catalog):

[2]:
!hydromt update wflow "./data/wflow_upgrade/sbm" -i wflow_update_v1_sbm.yml -v
2025-08-29 03:29:36,707 - hydromt - log - INFO - HydroMT version: 1.2.0.dev0
2025-08-29 03:29:36,707 - hydromt.cli.main - main - INFO - Updating wflow model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sbm (r+).
2025-08-29 03:29:36,707 - hydromt.cli.main - main - INFO - Output dir: /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sbm
2025-08-29 03:29:36,707 - hydromt.cli.main - main - INFO - User settings:
2025-08-29 03:29:36,743 - hydromt.model.root - root - INFO - setting root to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sbm
2025-08-29 03:29:36,743 - hydromt.model.model - model - INFO - Initializing wflow model from hydromt_wflow (v1.0.0.dev0).
2025-08-29 03:29:36,743 - hydromt.data_catalog.data_catalog - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2025-08-29 03:29:36,773 - hydromt.hydromt_wflow.wflow - wflow - INFO - Supported Wflow.jl version v1+
2025-08-29 03:29:36,773 - hydromt.hydromt_wflow.components.config - config - INFO - Reading model config file from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sbm/wflow_sbm_v0x.toml.
2025-08-29 03:29:37,445 - hydromt.model.model - model - INFO - update: upgrade_to_v1_wflow
2025-08-29 03:29:37,445 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config to Wflow v1 format
2025-08-29 03:29:37,445 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config general, time and model sections
2025-08-29 03:29:37,445 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config state section
2025-08-29 03:29:37,446 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config input section
2025-08-29 03:29:37,446 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config output sections
2025-08-29 03:29:37,446 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Reservoirs/lakes found in the grid, converting to Wflow v1 format.
2025-08-29 03:29:37,495 - hydromt.model.model - model - INFO - update: write_grid
2025-08-29 03:29:37,496 - hydromt.model.model - model - INFO - write_grid.filename=staticmaps_v1.nc
2025-08-29 03:29:37,502 - hydromt._io.writers - writers - INFO - writing region data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sbm/staticgeoms/region.geojson
2025-08-29 03:29:37,568 - hydromt.model.model - model - INFO - update: write_config
2025-08-29 03:29:37,568 - hydromt.model.model - model - INFO - write_config.filename=wflow_sbm_v1.toml
2025-08-29 03:29:37,569 - hydromt.model.model - model - INFO - write_config.config_root=None
2025-08-29 03:29:37,569 - hydromt.hydromt_wflow.components.config - config - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sbm/wflow_sbm_v1.toml.

And let’s see the results. Here is what our old TOML file looked like:

[3]:
toml_v0x = "./data/wflow_upgrade/sbm/wflow_sbm_v0x.toml"
with open(toml_v0x, "r") as f:
    txt = f.read()
print(txt)
casename = "wflow_sbm"
calendar = "proleptic_gregorian"
starttime = "2010-02-02T00:00:00"
endtime = "2010-02-10T00:00:00"
time_units = "days since 1900-01-01 00:00:00"
timestepsecs = 86400
dir_output = "run_default"


[state]
path_input = "instate/instates.nc"
path_output = "outstate/outstates.nc"

[input]
path_forcing = "inmaps.nc"
path_static = "staticmaps_v0x.nc"
gauges = "wflow_gauges"
ldd = "wflow_ldd"
river_location = "wflow_river"
subcatchment = "wflow_subcatch"
forcing = [ "vertical.precipitation", "vertical.temperature", "vertical.potential_evaporation",]
cyclic = [ "vertical.leaf_area_index",]
gauges_grdc = "wflow_gauges_grdc"

[model]
type = "sbm"
masswasting = true
snow = true
reinit = true
reservoirs = true
lakes = true
glacier = true
land_routing = "kinematic-wave"
river_routing = "kinematic-wave"
kin_wave_iteration = true
kw_river_tstep = 900
kw_land_tstep = 3600
thicknesslayers = [ 100, 300, 800,]

[state.vertical]
satwaterdepth = "satwaterdepth"
snow = "snow"
tsoil = "tsoil"
ustorelayerdepth = "ustorelayerdepth"
snowwater = "snowwater"
canopystorage = "canopystorage"
glacierstore = "glacierstore"

[input.vertical]
alpha_h1 = "alpha_h1"
altitude = "wflow_dem"
c = "c"
cf_soil = "cf_soil"
cfmax = "Cfmax"
e_r = "EoverR"
f = "f"
infiltcappath = "InfiltCapPath"
infiltcapsoil = "InfiltCapSoil"
kext = "Kext"
kv_0 = "KsatVer"
leaf_area_index = "LAI"
m = "M_"
maxleakage = "MaxLeakage"
pathfrac = "PathFrac"
potential_evaporation = "pet"
precipitation = "precip"
rootdistpar = "rootdistpar"
rootingdepth = "RootingDepth"
soilminthickness = "SoilMinThickness"
soilthickness = "SoilThickness"
specific_leaf = "Sl"
storage_wood = "Swood"
temperature = "temp"
tt = "TT"
tti = "TTI"
ttm = "TTM"
water_holding_capacity = "WHC"
waterfrac = "WaterFrac"
theta_s = "thetaS"
theta_r = "thetaR"
glacierstore = "wflow_glacierstore"
glacierfrac = "wflow_glacierfrac"
g_cfmax = "G_Cfmax"
g_ttm = "G_TTM"
g_sifrac = "G_SIfrac"

[state.lateral.river]
q = "q_river"
h = "h_river"
h_av = "h_av_river"

[state.lateral.subsurface]
ssf = "ssf"

[state.lateral.land]
q = "q_land"
h = "h_land"
h_av = "h_av_land"

[input.lateral.river]
length = "wflow_riverlength"
n = "N_River"
slope = "RiverSlope"
width = "wflow_riverwidth"
bankfull_depth = "RiverDepth"

[input.lateral.subsurface]
ksathorfrac = "KsatHorFrac"

[input.lateral.land]
n = "N"
slope = "Slope"

[state.lateral.river.reservoir]
volume = "volume_reservoir"

[state.lateral.river.lake]
waterlevel = "waterlevel_lake"

[input.lateral.river.reservoir]
area = "ResSimpleArea"
areas = "wflow_reservoirareas"
demand = "ResDemand"
locs = "wflow_reservoirlocs"
maxrelease = "ResMaxRelease"
maxvolume = "ResMaxVolume"
targetfullfrac = "ResTargetFullFrac"
targetminfrac = "ResTargetMinFrac"

[input.lateral.river.lake]
area = "LakeArea"
areas = "wflow_lakeareas"
b = "Lake_b"
e = "Lake_e"
locs = "wflow_lakelocs"
outflowfunc = "LakeOutflowFunc"
storfunc = "LakeStorFunc"
threshold = "LakeThreshold"
linkedlakelocs = "LinkedLakeLocs"
waterlevel = "LakeAvgLevel"

[output]
path = "output.nc"

[output.lateral.river]
q_av = "q_river"

[output.lateral.land]
h = "h_land"

[netcdf]
path = "output_scalar.nc"

[[netcdf.variable]]
name = "Q"
map = "gauges"
parameter = "lateral.river.q"

[[netcdf.variable]]
name = "temp_coord"
location = "temp_bycoord"
coordinate.x = 11.9594
coordinate.y = 45.8925
parameter = "vertical.temperature"

[csv]
path = "output.csv"

[[csv.column]]
header = "Q-max"
parameter = "lateral.river.q_av"
reducer = "maximum"

[[csv.column]]
header = "res-volume"
index = 1
parameter = "lateral.river.reservoir.volume"

[[csv.column]]
header = "temp_bycoord"
coordinate.x = 11.95
coordinate.y = 45.9
parameter = "vertical.temperature"

[[csv.column]]
header = "temp_byindex"
index.x = 11
index.y = 6
parameter = "vertical.temperature"

[[csv.column]]
header = "Q"
map = "gauges_grdc"
parameter = "lateral.river.q_av"

[[csv.column]]
header = "P"
map = "subcatchment"
parameter = "vertical.precipitation"
reducer = "mean"

And here is the same TOML in version 1 format:

[4]:
toml_v1 = "./data/wflow_upgrade/sbm/wflow_sbm_v1.toml"
with open(toml_v1, "r") as f:
    txt = f.read()
print(txt)
dir_output = "run_default"

[time]
calendar = "proleptic_gregorian"
starttime = "2010-02-02T00:00:00"
endtime = "2010-02-10T00:00:00"
time_units = "days since 1900-01-01 00:00:00"
timestepsecs = 86400

[model]
type = "sbm"
snow_gravitional_transport__flag = true
snow__flag = true
cold_start__flag = true
reservoir__flag = true
glacier__flag = true
land_routing = "kinematic-wave"
river_routing = "kinematic-wave"
kinematic_wave__adaptive_time_step_flag = true
river_kinematic_wave__time_step = 900
land_kinematic_wave__time_step = 3600
soil_layer__thickness = [
    100,
    300,
    800,
]

[state]
path_input = "instate/instates.nc"
path_output = "outstate/outstates.nc"

[state.variables]
vegetation_canopy_water__depth = "canopystorage"
soil_water_sat-zone__depth = "satwaterdepth"
soil_layer_water_unsat-zone__depth = "ustorelayerdepth"
soil_surface__temperature = "tsoil"
"snowpack~dry__leq-depth" = "snow"
"snowpack~liquid__depth" = "snowwater"
glacier_ice__leq-depth = "glacierstore"
land_surface_water__instantaneous_volume_flow_rate = "q_land"
land_surface_water__instantaneous_depth = "h_land"
subsurface_water__volume_flow_rate = "ssf"
river_water__instantaneous_volume_flow_rate = "q_river"
river_water__instantaneous_depth = "h_river"
reservoir_water_surface__instantaneous_elevation = "reservoir_instantaneous_water_level"

[input]
path_forcing = "inmaps.nc"
path_static = "staticmaps_v1.nc"
gauges = "wflow_gauges"
basin__local_drain_direction = "wflow_ldd"
river_location__mask = "wflow_river"
subbasin_location__count = "wflow_subcatch"
gauges_grdc = "wflow_gauges_grdc"
reservoir_area__count = "reservoir_area_id"
reservoir_location__count = "reservoir_outlet_id"
"reservoir~lower_location__count" = "reservoir_lower_id"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "precip"
atmosphere_air__temperature = "temp"
land_surface_water__potential_evaporation_volume_flux = "pet"

[input.cyclic]
vegetation__leaf-area_index = "LAI"

[input.static]
snowpack__degree-day_coefficient = "Cfmax"
atmosphere_air__snowfall_temperature_threshold = "TT"
atmosphere_air__snowfall_temperature_interval = "TTI"
snowpack__melting_temperature_threshold = "TTM"
snowpack__liquid_water_holding_capacity = "WHC"
glacier_surface__area_fraction = "wflow_glacierfrac"
glacier_ice__initial_leq-depth = "wflow_glacierstore"
glacier_ice__melting_temperature_threshold = "G_TTM"
glacier_ice__degree-day_coefficient = "G_Cfmax"
"glacier_firn_accumulation__snowpack~dry_leq-depth_fraction" = "G_SIfrac"
vegetation_canopy_water__mean_evaporation-to-mean_precipitation_ratio = "EoverR"
vegetation_canopy__light-extinction_coefficient = "Kext"
vegetation_root__depth = "RootingDepth"
vegetation__specific-leaf_storage = "Sl"
vegetation_wood_water__storage_capacity = "Swood"
"vegetation_root__feddes_critial_pressure_head_h~1_reduction_coefficient" = "alpha_h1"
soil_layer_water__brooks-corey_exponent = "c"
soil_surface_water__infiltration_reduction_parameter = "cf_soil"
soil_surface_water__vertical_saturated_hydraulic_conductivity = "KsatVer"
subsurface_water__horizontal-to-vertical_saturated_hydraulic_conductivity_ratio = "KsatHorFrac"
soil_water__vertical_saturated_hydraulic_conductivity_scale_parameter = "f"
"soil~compacted_surface_water__infiltration_capacity" = "InfiltCapPath"
soil_water__residual_volume_fraction = "thetaR"
soil_water__saturated_volume_fraction = "thetaS"
soil_water_sat-zone_bottom__max_leakage_volume_flux = "MaxLeakage"
"soil~compacted__area_fraction" = "PathFrac"
"soil_root~wet__sigmoid_function_shape_parameter" = "rootdistpar"
soil__thickness = "SoilThickness"
"land~water-covered__area_fraction" = "WaterFrac"
land_surface_water_flow__manning_n_parameter = "N"
land_surface__slope = "Slope"
river_bank_water__depth = "RiverDepth"
river__length = "wflow_riverlength"
river_water_flow__manning_n_parameter = "N_River"
river__slope = "RiverSlope"
river__width = "wflow_riverwidth"
reservoir_water_surface__initial_elevation = "reservoir_initial_depth"
reservoir_water_flow_threshold-level__elevation = "reservoir_outflow_threshold"
reservoir_water__rating_curve_coefficient = "reservoir_b"
reservoir_water__rating_curve_exponent = "reservoir_e"
reservoir_water__rating_curve_type_count = "reservoir_rating_curve"
reservoir_water__storage_curve_type_count = "reservoir_storage_curve"
reservoir_surface__area = "reservoir_area"
"reservoir_water_demand~required~downstream__volume_flow_rate" = "reservoir_demand"
reservoir_water_release-below-spillway__max_volume_flow_rate = "reservoir_max_release"
reservoir_water__max_volume = "reservoir_max_volume"
"reservoir_water~full-target__volume_fraction" = "reservoir_target_full_fraction"
"reservoir_water~min-target__volume_fraction" = "reservoir_target_min_fraction"

[output.netcdf_grid]
path = "output.nc"
compressionlevel = 1

[output.netcdf_grid.variables]
river_water__volume_flow_rate = "q_river"
land_surface_water__instantaneous_depth = "h_land"

[output.netcdf_scalar]
path = "output_scalar.nc"

[[output.netcdf_scalar.variable]]
name = "Q"
map = "gauges"
parameter = "river_water__instantaneous_volume_flow_rate"

[[output.netcdf_scalar.variable]]
name = "temp_coord"
location = "temp_bycoord"
parameter = "atmosphere_air__temperature"

[output.netcdf_scalar.variable.coordinate]
x = 11.9594
y = 45.8925

[output.csv]
path = "output.csv"

[[output.csv.column]]
header = "Q-max"
parameter = "river_water__volume_flow_rate"
reducer = "maximum"

[[output.csv.column]]
header = "res-volume"
index = 1
parameter = "reservoir_water__instantaneous_volume"

[[output.csv.column]]
header = "temp_bycoord"
parameter = "atmosphere_air__temperature"

[output.csv.column.coordinate]
x = 11.95
y = 45.9

[[output.csv.column]]
header = "temp_byindex"
parameter = "atmosphere_air__temperature"

[output.csv.column.index]
x = 11
y = 6

[[output.csv.column]]
header = "Q"
map = "gauges_grdc"
parameter = "river_water__volume_flow_rate"

[[output.csv.column]]
header = "P"
map = "subbasin_location__count"
parameter = "atmosphere_water__precipitation_volume_flux"
reducer = "mean"

The lakes and reservoirs have been merged into one structure and the new staticmaps file has been generated. Here are all the available variables:

[5]:
import xarray as xr

staticmaps = xr.open_dataset("./data/wflow_upgrade/sbm/staticmaps_v1.nc")
print(list(staticmaps.data_vars.keys()))
['x_out', 'y_out', 'idx_out', 'wflow_ldd', 'wflow_subcatch', 'wflow_uparea', 'subare', 'dem_subgrid', 'wflow_streamorder', 'wflow_dem', 'Slope', 'wflow_river', 'wflow_riverlength', 'RiverSlope', 'N_River', 'wflow_riverwidth', 'RiverDepth', 'LakeAvgOut', 'wflow_glacierareas', 'wflow_glacierstore', 'wflow_glacierfrac', 'wflow_landuse', 'Kext', 'N', 'PathFrac', 'RootingDepth', 'Sl', 'Swood', 'WaterFrac', 'kc', 'alpha_h1', 'h1', 'h2', 'h3_high', 'h3_low', 'h4', 'LAI', 'thetaS', 'thetaR', 'SoilThickness', 'SoilMinThickness', 'c', 'KsatVer', 'KsatVer_0.0cm', 'KsatVer_5.0cm', 'KsatVer_15.0cm', 'KsatVer_30.0cm', 'KsatVer_60.0cm', 'KsatVer_100.0cm', 'KsatVer_200.0cm', 'M_original_', 'M_', 'f_', 'M_original', 'M', 'f', 'wflow_soil', 'wflow_gauges', 'wflow_gauges_grdc', 'KsatHorFrac', 'Cfmax', 'cf_soil', 'EoverR', 'InfiltCapPath', 'InfiltCapSoil', 'MaxLeakage', 'rootdistpar', 'TT', 'TTI', 'TTM', 'WHC', 'G_Cfmax', 'G_SIfrac', 'G_TT', 'reservoir_b', 'reservoir_e', 'reservoir_outflow_threshold', 'reservoir_lower_id', 'reservoir_area_id', 'reservoir_outlet_id', 'reservoir_area', 'reservoir_initial_depth', 'reservoir_rating_curve', 'reservoir_storage_curve', 'reservoir_max_volume', 'reservoir_target_min_fraction', 'reservoir_target_full_fraction', 'reservoir_demand', 'reservoir_max_release']

Upgrading a Wflow Sediment model#

We can call the upgrade_to_v1_wflow function using the update CLI of HydroMT. Here is the configuration file that we will use:

[6]:
fn_config = "wflow_update_v1_sediment.yml"
with open(fn_config, "r") as f:
    txt = f.read()
print(txt)
global:
  config_filename: wflow_sediment_v0x.toml

steps:
  - upgrade_to_v1_wflow:
      soil_fn: soilgrids

  - write_grid:
      filename: staticmaps_v1.nc

  - write_config:
      filename: wflow_sediment_v1.toml

In this config, we start by setting the name of the TOML file of the version 0x model (if different than wflow_sediment.toml), call the upgrade_to_v1_wflow method, and then save the updated TOML file into a new wflow_sbm_v1.toml file and the updated staticmaps file with the additional parameters in staticmaps_v1.toml.

Note that if you use the standard wflow_sediment.toml name and do not mind it or the staticmaps file being overwritten, the above example can be reduced into only calling upgrade_to_v1_wflow.

Let’s now call HydroMT update to update our old config (in this case we do need a data catalog as we will update some of the soil parameters):

[7]:
!hydromt update wflow_sediment "./data/wflow_upgrade/sediment" -i wflow_update_v1_sediment.yml -d artifact_data -v
2025-08-29 03:29:42,763 - hydromt - log - INFO - HydroMT version: 1.2.0.dev0
2025-08-29 03:29:42,763 - hydromt.cli.main - main - INFO - Updating wflow_sediment model at /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sediment (r+).
2025-08-29 03:29:42,763 - hydromt.cli.main - main - INFO - Output dir: /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sediment
2025-08-29 03:29:42,763 - hydromt.cli.main - main - INFO - User settings:
2025-08-29 03:29:42,959 - hydromt.data_catalog.data_catalog - data_catalog - INFO - Reading data catalog artifact_data latest
2025-08-29 03:29:42,959 - hydromt.data_catalog.data_catalog - data_catalog - INFO - Parsing data catalog from /home/runner/.hydromt/artifact_data/v1.0.0/data_catalog.yml
2025-08-29 03:29:43,599 - hydromt.model.root - root - INFO - setting root to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sediment
2025-08-29 03:29:43,599 - hydromt.model.model - model - INFO - Initializing wflow_sediment model from hydromt_wflow (v1.0.0.dev0).
2025-08-29 03:29:43,599 - hydromt.data_catalog.data_catalog - data_catalog - INFO - Parsing data catalog from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/parameters_data.yml
2025-08-29 03:29:43,612 - hydromt.hydromt_wflow.wflow - wflow - INFO - Supported Wflow.jl version v1+
2025-08-29 03:29:43,612 - hydromt.hydromt_wflow.components.config - config - INFO - Reading model config file from /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sediment/wflow_sediment_v0x.toml.
2025-08-29 03:29:44,223 - hydromt.model.model - model - INFO - update: upgrade_to_v1_wflow
2025-08-29 03:29:44,223 - hydromt.model.model - model - INFO - upgrade_to_v1_wflow.soil_fn=soilgrids
2025-08-29 03:29:44,223 - hydromt.model.model - model - INFO - upgrade_to_v1_wflow.usle_k_method=renard
2025-08-29 03:29:44,223 - hydromt.model.model - model - INFO - upgrade_to_v1_wflow.strord_name=wflow_streamorder
2025-08-29 03:29:44,223 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config to Wflow v1 format
2025-08-29 03:29:44,223 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config general, time and model sections
2025-08-29 03:29:44,223 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config state section
2025-08-29 03:29:44,223 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config input section
2025-08-29 03:29:44,223 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Converting config output sections
2025-08-29 03:29:44,224 - hydromt.hydromt_wflow.wflow_sediment - wflow_sediment - INFO - Preparing soil parameter maps.
2025-08-29 03:29:45,188 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for erosion_soil_detachability
2025-08-29 03:29:45,209 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for usle_k
2025-08-29 03:29:45,242 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for soil_sediment_d50
2025-08-29 03:29:45,285 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for land_govers_c
2025-08-29 03:29:45,327 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for land_govers_n
2025-08-29 03:29:45,343 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for soil_clay_fraction
2025-08-29 03:29:45,358 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for soil_silt_fraction
2025-08-29 03:29:45,375 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for soil_sagg_fraction
2025-08-29 03:29:45,396 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for soil_sand_fraction
2025-08-29 03:29:45,436 - hydromt.gis.raster - raster - WARNING - No numerical nodata value found, skipping set_nodata
2025-08-29 03:29:45,438 - hydromt.hydromt_wflow.workflows.soilgrids - soilgrids - INFO - Interpolate NAN values for soil_lagg_fraction
2025-08-29 03:29:45,451 - hydromt.hydromt_wflow.wflow_sediment - wflow_sediment - INFO - Preparing riverbedsed parameter maps.
2025-08-29 03:29:45,451 - hydromt.data_catalog.drivers.dataframe.pandas_driver - pandas_driver - INFO - Reading using pandas driver from /home/runner/work/hydromt_wflow/hydromt_wflow/hydromt_wflow/data/wflow_sediment/riverbedsed_mapping.csv
2025-08-29 03:29:45,459 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_bed_sediment_d50 using average resampling (nodata=-999.0).
2025-08-29 03:29:45,463 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_bed_clay_fraction using average resampling (nodata=-999.0).
2025-08-29 03:29:45,467 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_bed_silt_fraction using average resampling (nodata=-999.0).
2025-08-29 03:29:45,471 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_bed_sand_fraction using average resampling (nodata=-999.0).
2025-08-29 03:29:45,475 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_bed_gravel_fraction using average resampling (nodata=-999.0).
2025-08-29 03:29:45,480 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_kodatie_a using average resampling (nodata=nan).
2025-08-29 03:29:45,484 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_kodatie_b using average resampling (nodata=nan).
2025-08-29 03:29:45,488 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_kodatie_c using average resampling (nodata=nan).
2025-08-29 03:29:45,492 - hydromt.hydromt_wflow.workflows.landuse - landuse - INFO - Deriving river_kodatie_d using average resampling (nodata=nan).
2025-08-29 03:29:45,507 - hydromt.hydromt_wflow.version_upgrade - version_upgrade - INFO - Reservoirs/lakes found in the grid, converting to Wflow v1 format.
2025-08-29 03:29:45,525 - hydromt.model.model - model - INFO - update: write_grid
2025-08-29 03:29:45,525 - hydromt.model.model - model - INFO - write_grid.filename=staticmaps_v1.nc
2025-08-29 03:29:45,530 - hydromt._io.writers - writers - INFO - writing region data to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sediment/staticgeoms/region.geojson
2025-08-29 03:29:45,587 - hydromt.model.model - model - INFO - update: write_config
2025-08-29 03:29:45,587 - hydromt.model.model - model - INFO - write_config.filename=wflow_sediment_v1.toml
2025-08-29 03:29:45,587 - hydromt.model.model - model - INFO - write_config.config_root=None
2025-08-29 03:29:45,587 - hydromt.hydromt_wflow.components.config - config - INFO - Writing model config to /home/runner/work/hydromt_wflow/hydromt_wflow/docs/_examples/data/wflow_upgrade/sediment/wflow_sediment_v1.toml.

And let’s see the results. Here is what our old TOML file looked like:

[8]:
toml_v0x = "./data/wflow_upgrade/sediment/wflow_sediment_v0x.toml"
with open(toml_v0x, "r") as f:
    txt = f.read()
print(txt)
casename = "wflow_sediment"
calendar = "proleptic_gregorian"
starttime = "2010-02-01T00:00:00"
endtime = "2010-02-10T00:00:00"
time_units = "days since 1900-01-01 00:00:00"
timestepsecs = 86400
dir_output = "run_default"

[state]
path_input = "instate/instates.nc"
path_output = "outstate/outstates.nc"

[input]
path_forcing = "inmaps.nc"
path_static = "staticmaps_v0x.nc"
ldd = "wflow_ldd"
river_location = "wflow_river"
subcatchment = "wflow_subcatch"
forcing = [ "vertical.h_land", "vertical.interception", "vertical.precipitation", "vertical.q_land", "lateral.river.h_riv", "lateral.river.q_riv",]
cyclic = [ "vertical.leaf_area_index",]
gauges = "wflow_gauges"
gauges_grdc = "wflow_gauges_grdc"

[model]
type = "sediment"
reinit = true
runrivermodel = true
doreservoir = true
dolake = true
rainerosmethod = "answers"
landtransportmethod = "yalinpart"
rivtransportmethod = "bagnold"

[output]
path = "output.nc"

[csv]
path = "output.csv"
[[csv.column]]
header = "TSS"
map = "gauges"
parameter = "lateral.river.SSconc"

[[csv.column]]
header = "Q"
map = "gauges_grdc"
parameter = "lateral.river.q_riv"

[[csv.column]]
header = "TSS"
map = "gauges_grdc"
parameter = "lateral.river.SSconc"

[input.vertical]
altitude = "wflow_dem"
canopyheight = "CanopyHeight"
erosk = "ErosK"
erosspl = "eros_spl_EUROSEM"
erosov = "eros_ov"
h_land = "lwl"
interception = "int"
kext = "Kext"
leaf_area_index = "LAI"
pathfrac = "PathFrac"
precipitation = "prec"
q_land = "lro"
slope = "Slope"
specific_leaf = "Sl"
storage_wood = "Swood"
usleC = "USLE_C"
usleK = "USLE_K"
pclay = "PercentClay"
psilt = "PercentSilt"
rivcell = "wflow_river"
resareas = "wflow_reservoirareas"
lakeareas = "wflow_lakeareas"

[output.vertical]
soilloss = "soilloss"

[state.lateral.river]
clayload = "clayload"
siltload = "siltload"
sandload = "sandload"
saggload = "saggload"
laggload = "laggload"
gravload = "gravload"
claystore = "claystore"
siltstore = "siltstore"
sandstore = "sandstore"
saggstore = "saggstore"
laggstore = "laggstore"
gravstore = "gravstore"
outclay = "outclay"
outsilt = "outsilt"
outsand = "outsand"
outsagg = "outsagg"
outlagg = "outlagg"
outgrav = "outgrav"

[input.lateral.land]
slope = "Slope"

[input.lateral.river]
h_riv = "rwl"
q_riv = "rro"
cbagnold = "c_Bagnold"
d50 = "D50_River"
d50engelund = "D50_River"
ebagnold = "exp_Bagnold"
fclayriv = "ClayF_River"
fsiltriv = "SiltF_River"
fsandriv = "SandF_River"
fgravriv = "GravelF_River"
length = "wflow_riverlength"
slope = "RiverSlope"
width = "wflow_riverwidth"
resarea = "ResSimpleArea"
restrapeff = "ResTrapEff"
resareas = "wflow_reservoirareas"
reslocs = "wflow_reservoirlocs"
lakearea = "LakeArea"
lakeareas = "wflow_lakeareas"
lakelocs = "wflow_lakelocs"
bankfull_depth = "RiverDepth"

[output.lateral.river]
SSconc = "SSconc"

And here is the same TOML in version 1 format:

[9]:
toml_v1 = "./data/wflow_upgrade/sediment/wflow_sediment_v1.toml"
with open(toml_v1, "r") as f:
    txt = f.read()
print(txt)
dir_output = "run_default"

[time]
calendar = "proleptic_gregorian"
starttime = "2010-02-01T00:00:00"
endtime = "2010-02-10T00:00:00"
time_units = "days since 1900-01-01 00:00:00"
timestepsecs = 86400

[model]
type = "sediment"
cold_start__flag = true
run_river_model__flag = true
reservoir__flag = true
rainfall_erosion = "answers"
land_transport = "yalinpart"
river_transport = "bagnold"

[state]
path_input = "instate/instates.nc"
path_output = "outstate/outstates.nc"

[state.variables]
river_water_clay__mass = "clayload"
river_bed_clay__mass = "claystore"
river_water_clay__mass_flow_rate = "outclay"
river_water_gravel__mass = "gravload"
river_bed_gravel__mass = "gravstore"
river_water_gravel__mass_flow_rate = "outgrav"
"river_water_aggregates~large__mass" = "laggload"
"river_bed_aggregates~large__mass" = "laggstore"
"river_water_aggregates~large__mass_flow_rate" = "outlagg"
"river_water_aggregates~small__mass" = "saggload"
"river_bed_aggregates~small__mass" = "saggstore"
"river_water_aggregates~small__mass_flow_rate" = "outsagg"
river_water_sand__mass = "sandload"
river_bed_sand__mass = "sandstore"
river_water_sand__mass_flow_rate = "outsand"
river_water_silt__mass = "siltload"
river_bed_silt__mass = "siltstore"
river_water_silt__mass_flow_rate = "outsilt"

[input]
path_forcing = "inmaps.nc"
path_static = "staticmaps_v1.nc"
basin__local_drain_direction = "wflow_ldd"
river_location__mask = "wflow_river"
subbasin_location__count = "wflow_subcatch"
gauges = "wflow_gauges"
gauges_grdc = "wflow_gauges_grdc"
reservoir_area__count = "reservoir_area_id"
reservoir_location__count = "reservoir_outlet_id"

[input.forcing]
atmosphere_water__precipitation_volume_flux = "prec"
vegetation_canopy_water__interception_volume_flux = "int"
land_surface_water__depth = "lwl"
land_surface_water__volume_flow_rate = "lro"
river_water__depth = "rwl"
river_water__volume_flow_rate = "rro"

[input.cyclic]

[input.static]
land_surface__slope = "Slope"
river__length = "wflow_riverlength"
river__slope = "RiverSlope"
river__width = "wflow_riverwidth"
reservoir_surface__area = "reservoir_area"
"reservoir_water_sediment~bedload__trapping_efficiency" = "reservoir_trapping_efficiency"
vegetation_canopy__height = "CanopyHeight"
"soil~compacted__area_fraction" = "PathFrac"
soil_erosion__rainfall_soil_detachability_factor = "erosion_soil_detachability"
soil_erosion__eurosem_exponent = "eros_spl_EUROSEM"
soil_erosion__usle_k_factor = "erosion_usle_k"
soil_erosion__usle_c_factor = "USLE_C"
soil_erosion__answers_overland_flow_factor = "eros_ov"
river_water_sediment__bagnold_transport_capacity_coefficient = "c_Bagnold"
river_water_sediment__bagnold_transport_capacity_exponent = "exp_Bagnold"
river_bottom-and-bank_sediment__median_diameter = "river_bed_sediment_d50"
river_bottom-and-bank_clay__mass_fraction = "river_bed_clay_fraction"
river_bottom-and-bank_silt__mass_fraction = "river_bed_silt_fraction"
river_bottom-and-bank_sand__mass_fraction = "river_bed_sand_fraction"
land_surface_sediment__median_diameter = "soil_sediment_d50"
land_surface_water_sediment__govers_transport_capacity_coefficient = "land_govers_c"
land_surface_water_sediment__govers_transport_capacity_exponent = "land_govers_n"
soil_clay__mass_fraction = "soil_clay_fraction"
soil_silt__mass_fraction = "soil_silt_fraction"
"soil_aggregates~small__mass_fraction" = "soil_sagg_fraction"
soil_sand__mass_fraction = "soil_sand_fraction"
"soil_aggregates~large__mass_fraction" = "soil_lagg_fraction"
river_bottom-and-bank_gravel__mass_fraction = "river_bed_gravel_fraction"
river_water_sediment__kodatie_transport_capacity_a-coefficient = "river_kodatie_a"
river_water_sediment__kodatie_transport_capacity_b-coefficient = "river_kodatie_b"
river_water_sediment__kodatie_transport_capacity_c-coefficient = "river_kodatie_c"
river_water_sediment__kodatie_transport_capacity_d-coefficient = "river_kodatie_d"

[output.netcdf_grid]
path = "output.nc"
compressionlevel = 1

[output.netcdf_grid.variables]
soil_erosion__mass_flow_rate = "soilloss"
"river_water_sediment~suspended__mass_concentration" = "SSconc"

[output.csv]
path = "output.csv"

[[output.csv.column]]
header = "TSS"
map = "gauges"
parameter = "river_water_sediment~suspended__mass_concentration"

[[output.csv.column]]
header = "Q"
map = "gauges_grdc"
parameter = "river_water__volume_flow_rate"

[[output.csv.column]]
header = "TSS"
map = "gauges_grdc"
parameter = "river_water_sediment~suspended__mass_concentration"

You can also note that the new staticmaps file was generated. Here are all the available variables:

[10]:
import xarray as xr

staticmaps = xr.open_dataset("./data/wflow_upgrade/sediment/staticmaps_v1.nc")
print(list(staticmaps.data_vars.keys()))
['x_out', 'y_out', 'idx_out', 'wflow_ldd', 'wflow_subcatch', 'wflow_uparea', 'subare', 'dem_subgrid', 'wflow_streamorder', 'wflow_dem', 'Slope', 'wflow_river', 'wflow_riverlength', 'RiverSlope', 'N_River', 'wflow_riverwidth', 'RiverDepth', 'ResMaxVolume', 'ResDemand', 'ResMaxRelease', 'ResTargetFullFrac', 'ResTargetMinFrac', 'LakeAvgLevel', 'LakeAvgOut', 'Lake_b', 'Lake_e', 'LakeStorFunc', 'LakeOutflowFunc', 'LakeThreshold', 'LinkedLakeLocs', 'D50_River', 'ClayF_River', 'SiltF_River', 'SandF_River', 'GravelF_River', 'wflow_landuse', 'Kext', 'PathFrac', 'Sl', 'Swood', 'USLE_C', 'LAI', 'CanopyHeight', 'PercentClay', 'PercentSilt', 'PercentOC', 'ErosK', 'USLE_K', 'wflow_gauges', 'wflow_gauges_grdc', 'c_Bagnold', 'eros_expo', 'eros_ov', 'eros_spl_EUROSEM', 'exp_Bagnold', 'erosion_soil_detachability', 'erosion_usle_k', 'soil_sediment_d50', 'land_govers_c', 'land_govers_n', 'soil_clay_fraction', 'soil_silt_fraction', 'soil_sagg_fraction', 'soil_sand_fraction', 'soil_lagg_fraction', 'river_bed_sediment_d50', 'river_bed_clay_fraction', 'river_bed_silt_fraction', 'river_bed_sand_fraction', 'river_bed_gravel_fraction', 'river_kodatie_a', 'river_kodatie_b', 'river_kodatie_c', 'river_kodatie_d', 'reservoir_area_id', 'reservoir_outlet_id', 'reservoir_area', 'reservoir_trapping_efficiency']