API reference#

Wflow model class#

Initialize#

WflowModel([root, config_filename, mode, ...])

Read or Write a wflow model.

Setup methods#

WflowModel.setup_config(data)

Set the config dictionary at key(s) with values.

WflowModel.setup_basemaps(region, hydrography_fn)

Build the DEM and flow direction for a Wflow model.

WflowModel.setup_rivers(hydrography_fn[, ...])

Set all river parameter maps.

WflowModel.setup_floodplains(hydrography_fn, ...)

Add floodplain information to the model schematisation.

WflowModel.setup_reservoirs_no_control(...)

Generate maps of reservoir areas, outlets and parameters.

WflowModel.setup_reservoirs_simple_control(...)

Generate maps of controlled reservoir areas, outlets and parameters.

WflowModel.setup_glaciers(glaciers_fn[, ...])

Generate maps of glacier areas, area fraction and volume fraction.

WflowModel.setup_lulcmaps(lulc_fn[, ...])

Derive several wflow maps based on landuse-landcover (LULC) data.

WflowModel.setup_lulcmaps_from_vector(lulc_fn)

Derive several wflow maps based on vector landuse-landcover (LULC) data.

WflowModel.setup_lulcmaps_with_paddy(...[, ...])

Set up landuse maps and parameters including for paddy fields.

WflowModel.setup_laimaps(lai_fn[, lulc_fn, ...])

Set leaf area index (LAI) climatology maps per month [1,2,3,...,12].

WflowModel.setup_laimaps_from_lulc_mapping(...)

Derive cyclic LAI maps from a LULC data source and a LULC-LAI mapping table.

WflowModel.setup_allocation_areas(waterareas_fn)

Create water demand allocation areas.

WflowModel.setup_allocation_surfacewaterfrac(...)

Create the fraction of water allocated from surface water.

WflowModel.setup_domestic_demand(domestic_fn)

Prepare domestic water demand maps from a raster dataset.

WflowModel.setup_domestic_demand_from_population(...)

Prepare domestic water demand maps from statistics per capita.

WflowModel.setup_other_demand(demand_fn[, ...])

Create water demand maps from other sources (e.g. industry, livestock).

WflowModel.setup_irrigation(...[, ...])

Add required information to simulate irrigation water demand from grid.

WflowModel.setup_irrigation_from_vector(...)

Add required information to simulate irrigation water demand from vector.

WflowModel.setup_ksathorfrac(ksat_fn[, ...])

Set KsatHorFrac parameter values from a predetermined map.

WflowModel.setup_ksatver_vegetation([...])

Correct vertical saturated hydraulic conductivity with vegetation properties.

WflowModel.setup_rootzoneclim(run_fn, ...[, ...])

Set the vegetation_root_depth.

WflowModel.setup_soilmaps([soil_fn, ...])

Derive several (layered) soil parameters.

WflowModel.setup_outlets([river_only, ...])

Set the default gauge map based on basin outlets.

WflowModel.setup_gauges(gauges_fn[, ...])

Set a gauge map based on gauges_fn data.

WflowModel.setup_areamap(area_fn, col2raster)

Set area map from vector data to save wflow outputs for specific area.

WflowModel.setup_config_output_timeseries(mapname)

Set the default gauge map based on basin outlets.

WflowModel.setup_precip_forcing(precip_fn[, ...])

Generate gridded precipitation forcing at model resolution.

WflowModel.setup_precip_from_point_timeseries(...)

Generate gridded precipitation from point timeseries (requires wradlib).

WflowModel.setup_temp_pet_forcing(temp_pet_fn)

Generate gridded temperature and reference evapotranspiration forcing.

WflowModel.setup_pet_forcing(pet_fn[, chunksize])

Prepare PET forcing from existig PET data.

WflowModel.setup_constant_pars(**kwargs)

Generate constant parameter maps for all active model cells.

WflowModel.setup_1dmodel_connection(river1d_fn)

Connect wflow to a 1D model by deriving linked subcatch (and tributaries).

WflowModel.setup_grid_from_raster(raster_fn, ...)

Add data variable(s) from raster_fn to grid object.

WflowModel.setup_cold_states([timestamp])

Prepare cold states for Wflow.

WflowModel.upgrade_to_v1_wflow()

Upgrade the model to wflow v1 format.

High level and I/O methods#

WflowModel.build(*[, write])

Single method to build a model from scratch based on settings in steps.

WflowModel.update(*[, model_out, write, ...])

Single method to update a model based the settings in steps.

WflowModel.read([config_filename, geoms_folder])

Read components from disk.

WflowModel.write([config_filename, ...])

Write the complete model schematization and configuration to file.

WflowModel.read_config([filename])

Read config from <root/filename>.

WflowModel.write_config([filename, config_root])

Write config to <(config_)root/config_fn>.

WflowModel.read_grid(**kwargs)

Read grid model data.

WflowModel.write_grid([filename])

Write grid to wflow static data file.

WflowModel.clip_grid(region[, buffer, ...])

Clip grid to subbasin.

WflowModel.read_geoms([folder])

Read static geometries and adds to geoms.

WflowModel.write_geoms([folder, precision, ...])

Write geoms in GeoJSON format.

WflowModel.read_forcing(**kwargs)

Read forcing.

WflowModel.write_forcing([filename, ...])

Write forcing at <root/dir_input/filename> in model ready format.

WflowModel.clip_forcing()

Return clipped forcing for subbasin.

WflowModel.read_states()

Read states at <root/dir_input/state.path_input>.

WflowModel.write_states([filename])

Write states at <root/dir_input/state.path_input> in model ready format.

WflowModel.clip_states()

Return clippped states for subbasin.

WflowModel.read_outputs()

Read outputs at <root/dir_output>.

WflowModel.read_tables(**kwargs)

Read table files at <root> and parse to dict of dataframes.

WflowModel.write_tables()

Write tables at <root>.

Components#

WflowModel.config

Return the config component.

WflowModel.staticmaps

Return the staticmaps component.

WflowModel.forcing

Return the forcing component.

WflowModel.states

Return the states component.

WflowModel.tables

Return the WflowTablesComponent instance.

WflowModel.geoms

Return the geoms component.

WflowModel.output_grid

Return the WflowOutputGridComponent instance.

WflowModel.output_scalar

Return the WflowOutputScalarComponent instance.

WflowModel.output_csv

Return the WflowOutputCsvComponent instance.

Attributes#

WflowModel.crs

Returns coordinate reference system embedded in region.

WflowModel.root

Model root

WflowModel.flwdir

Return the pyflwdir.FlwdirRaster object parsed from wflow ldd.

WflowModel.basins

Returns a basin(s) geometry as a geopandas.GeoDataFrame.

WflowModel.rivers

Return a river geometry as a geopandas.GeoDataFrame.

Other general methods#

WflowModel.set_config(*args)

Update the config toml at key(s) with values.

WflowModel.get_config(*args[, fallback, ...])

Get a config value at key.

WflowModel.set_forcing(data[, name])

Add data for the forcing component.

WflowModel.set_grid(data[, name])

Add data to grid.

WflowModel.set_tables(df, name)

Add table <pandas.DataFrame> to model.

WflowModel.set_states(data[, name])

Add data to states.

WflowSediment model class#

Initialize#

WflowSedimentModel([root, config_filename, ...])

The wflow sediment model class, a subclass of WflowModel.

Setup components#

WflowSedimentModel.setup_config(data)

Set the config dictionary at key(s) with values.

WflowSedimentModel.setup_basemaps(region, ...)

Build the DEM and flow direction for a Wflow model.

WflowSedimentModel.setup_rivers(hydrography_fn)

Set all river parameter maps.

WflowSedimentModel.setup_natural_reservoirs(...)

Generate maps of natural reservoir areas (lakes) and outlets.

WflowSedimentModel.setup_reservoirs(...[, ...])

Generate maps of reservoir areas and outlets.

WflowSedimentModel.setup_lulcmaps(lulc_fn[, ...])

Derive several wflow maps based on landuse-landcover (LULC) data.

WflowSedimentModel.setup_lulcmaps_from_vector(lulc_fn)

Derive several wflow maps based on vector landuse-landcover (LULC) data.

WflowSedimentModel.setup_laimaps(lai_fn[, ...])

Set leaf area index (LAI) climatology maps per month [1,2,3,...,12].

WflowSedimentModel.setup_laimaps_from_lulc_mapping(...)

Derive cyclic LAI maps from a LULC data source and a LULC-LAI mapping table.

WflowSedimentModel.setup_canopymaps(canopy_fn)

Generate sediments based canopy height maps.

WflowSedimentModel.setup_soilmaps([soil_fn, ...])

Generate sediments based soil parameter maps.

WflowSedimentModel.setup_riverwidth([...])

Set the river width parameter based on power-law relationship with a predictor.

WflowSedimentModel.setup_riverbedsed([...])

Generate sediments based river bed characteristics maps.

WflowSedimentModel.setup_outlets([...])

Set the default gauge map based on basin outlets.

WflowSedimentModel.setup_gauges(gauges_fn[, ...])

Set a gauge map based on gauges_fn data.

WflowSedimentModel.setup_areamap(area_fn, ...)

Set area map from vector data to save wflow outputs for specific area.

WflowSedimentModel.setup_config_output_timeseries(mapname)

Set the default gauge map based on basin outlets.

WflowSedimentModel.setup_constant_pars(**kwargs)

Generate constant parameter maps for all active model cells.

WflowSedimentModel.setup_grid_from_raster(...)

Add data variable(s) from raster_fn to grid object.

WflowSedimentModel.upgrade_to_v1_wflow([...])

Upgrade the model to wflow v1 format.

High level and I/O methods#

WflowSedimentModel.build(*[, write])

Single method to build a model from scratch based on settings in steps.

WflowSedimentModel.update(*[, model_out, ...])

Single method to update a model based the settings in steps.

WflowSedimentModel.read([config_filename, ...])

Read components from disk.

WflowSedimentModel.write([config_filename, ...])

Write the complete model schematization and configuration to file.

WflowSedimentModel.read_config([filename])

Read config from <root/filename>.

WflowSedimentModel.write_config([filename, ...])

Write config to <(config_)root/config_fn>.

WflowSedimentModel.read_grid(**kwargs)

Read grid model data.

WflowSedimentModel.write_grid([filename])

Write grid to wflow static data file.

WflowSedimentModel.clip_grid(region[, ...])

Clip grid to subbasin.

WflowSedimentModel.read_geoms([folder])

Read static geometries and adds to geoms.

WflowSedimentModel.write_geoms([folder, ...])

Write geoms in GeoJSON format.

WflowSedimentModel.read_forcing(**kwargs)

Read forcing.

WflowSedimentModel.write_forcing([filename, ...])

Write forcing at <root/dir_input/filename> in model ready format.

WflowSedimentModel.clip_forcing()

Return clipped forcing for subbasin.

WflowSedimentModel.read_states()

Read states at <root/dir_input/state.path_input>.

WflowSedimentModel.write_states([filename])

Write states at <root/dir_input/state.path_input> in model ready format.

WflowSedimentModel.read_outputs()

Read outputs at <root/dir_output>.

Components#

WflowSedimentModel.config

Return the config component.

WflowSedimentModel.staticmaps

Return the staticmaps component.

WflowSedimentModel.forcing

Return the forcing component.

WflowSedimentModel.states

Return the states component.

WflowSedimentModel.tables

Return the WflowTablesComponent instance.

WflowSedimentModel.geoms

Return the geoms component.

WflowSedimentModel.output_grid

Return the WflowOutputGridComponent instance.

WflowSedimentModel.output_scalar

Return the WflowOutputScalarComponent instance.

WflowSedimentModel.output_csv

Return the WflowOutputCsvComponent instance.

Attributes#

WflowSedimentModel.crs

Returns coordinate reference system embedded in region.

WflowSedimentModel.root

Model root

WflowSedimentModel.flwdir

Return the pyflwdir.FlwdirRaster object parsed from wflow ldd.

WflowSedimentModel.basins

Returns a basin(s) geometry as a geopandas.GeoDataFrame.

WflowSedimentModel.rivers

Return a river geometry as a geopandas.GeoDataFrame.

Other general methods#

WflowSedimentModel.set_config(*args)

Update the config toml at key(s) with values.

WflowSedimentModel.get_config(*args[, ...])

Get a config value at key.

WflowSedimentModel.set_forcing(data[, name])

Add data for the forcing component.

WflowSedimentModel.set_grid(data[, name])

Add data to grid.

WflowSedimentModel.set_states(data[, name])

Add data to states.

WflowModel components#

WflowConfigComponent#

components.WflowConfigComponent(model, *[, ...])

Manage the wflow TOML configuration file for model simulations/settings.

components.WflowConfigComponent.data

Model config values.

components.WflowConfigComponent.get_value(key)

Get config options.

components.WflowConfigComponent.remove(*args)

Remove a config key and return its value.

WflowStaticmapsComponent#

components.WflowStaticmapsComponent(model, *)

Wflow staticmaps component.

components.WflowStaticmapsComponent.data

Model static gridded data as xarray.Dataset.

components.WflowStaticmapsComponent.drop_vars(names)

Drop variables from the grid.

WflowForcingComponent#

components.WflowForcingComponent(model, *[, ...])

Wflow forcing component.

components.WflowForcingComponent.data

Model static gridded data as xarray.Dataset.

WflowGeomsComponent#

components.WflowGeomsComponent(model, *[, ...])

Wflow Geoms Component to manage spatial geometries.

components.WflowGeomsComponent.data

Model geometries.

components.WflowGeomsComponent.get(name)

Get geometry by name.

WflowStatesComponent#

components.WflowStatesComponent(model, *[, ...])

ModelComponent class for Wflow states.

components.WflowStatesComponent.data

Model static gridded data as xarray.Dataset.

WflowTablesComponent#

components.WflowTablesComponent(model[, ...])

Wflow specific tables component.

components.WflowTablesComponent.data

Model tables.

WflowOutputGridComponent#

components.WflowOutputGridComponent(model, *)

ModelComponent class for Wflow netcdf_grid output.

components.WflowOutputGridComponent.data

Model static gridded data as xarray.Dataset.

components.WflowOutputGridComponent.read()

Read netcdf_grid model output at root/dir_output/filename.

WflowOutputScalarComponent#

components.WflowOutputScalarComponent(model, *)

ModelComponent class for Wflow netcdf_scalar output.

components.WflowOutputScalarComponent.data

Model netcdf_scalar output data as xarray.Dataset.

components.WflowOutputScalarComponent.read()

Read netcdf_scalar model output at root/dir_output/filename.

WflowOutputCsvComponent#

components.WflowOutputCsvComponent(model, *)

ModelComponent class for Wflow csv output.

components.WflowOutputCsvComponent.data

Model data in the form of xarray objects.

components.WflowOutputCsvComponent.read()

Read csv model output at root/dir_output/filename.

Wflow workflows#

workflows.allocation_areas(ds_like, ...[, ...])

Create water allocation area.

workflows.surfacewaterfrac_used(gwfrac_raw, ...)

Create surface water fraction map.

workflows.domestic(ds, ds_like[, popu, ...])

Create domestic water demand maps.

workflows.domestic_from_population(popu, ...)

Create domestic water demand maps from statitics per capita.

workflows.other_demand(ds, ds_like[, ds_method])

Create non-irrigation water demand maps.

workflows.irrigation(da_irrigation, ds_like, ...)

Prepare irrigation maps for paddy and non paddy.

workflows.irrigation_from_vector(...[, ...])

Prepare irrigation maps for paddy and non paddy from geodataframe.

workflows.hydrography(ds, res[, xy, ...])

Return hydrography maps (see list below) and FlwdirRaster object.

workflows.topography(ds, ds_like[, ...])

Return topography maps (see list below) at model resolution.

workflows.river(ds[, ds_model, river_upa, ...])

Return river maps.

workflows.river_bathymetry(ds_model, gdf_riv)

Get river width and bankfull discharge.

workflows.pet(pet, ds_like[, freq, ...])

Resample and reproject PET to the grid of ds_like.

workflows.spatial_interpolation(forcing, ...)

Interpolate spatial forcing data from station observations to a regular grid.

workflows.landuse(da, ds_like, df[, params])

Return landuse map and related parameter maps.

workflows.landuse_from_vector(gdf, ds_like, df)

Derive several wflow maps based on vector landuse-landcover (LULC) data.

workflows.lai(da, ds_like)

Return climatology of Leaf Area Index (LAI).

workflows.create_lulc_lai_mapping_table(...)

Derive LAI values per landuse class.

workflows.lai_from_lulc_mapping(da, ds_like, df)

Derive LAI values from a landuse map and a mapping table.

workflows.add_paddy_to_landuse(landuse, ...)

Burn paddy fields into landuse map and update mapping table.

workflows.add_planted_forest_to_landuse(...)

Update USLE C map with planted forest and orchard data.

workflows.ksatver_vegetation(ds_like, sndppt)

Calculate saturated hydraulic conductivity based on soil and vegetation [mm/d].

workflows.soilgrids(ds, ds_like[, ...])

Return soil parameter maps at model resolution.

workflows.soilgrids_sediment(ds, ds_like[, ...])

Return soil parameter maps for sediment modelling at model resolution.

workflows.soilgrids_brooks_corey(ds, ds_like)

Determine Brooks Corey coefficient per wflow soil layer depth.

workflows.update_soil_with_paddy(ds, ...[, ...])

Update soil_brooks_corey_c and soil_ksat_vertical_factor for paddy fields.

workflows.reservoir_id_maps(gdf, ds_like[, ...])

Return reservoir location maps (see list below).

workflows.reservoir_simple_control_parameters(...)

Return reservoir attributes (see list below) needed for modelling.

workflows.reservoir_parameters(ds, gdf[, ...])

Return (uncontrolled) reservoir attributes (see list below) needed for modelling.

workflows.merge_reservoirs(ds, ds_like[, ...])

Merge reservoir layers in ds to layers in ds_like.

workflows.merge_reservoirs_sediment(ds, ds_like)

Merge reservoir layers in ds to layers in ds_like for wflow sediment.

workflows.create_reservoirs_geoms(ds_res[, ...])

Create a GeoDataFrame of reservoir geometries for the sediment model.

workflows.create_reservoirs_geoms_sediment(ds_res)

Create a GeoDataFrame of reservoir geometries for the sediment model.

workflows.glaciermaps(gdf, ds_like[, ...])

Return glacier maps (see list below) at model resolution.

workflows.glacierattrs(gdf[, TT, Cfmax, ...])

Return glacier intbls (see list below).

workflows.rootzoneclim(dsrun, ds_obs, ...[, ...])

Estimates the root zone storage parameter.

workflows.wflow_1dmodel_connection(gdf_riv, ...)

Connect wflow to a 1D model by deriving linked subcatchs (and tributaries).

workflows.prepare_cold_states(ds_like, config)

Prepare cold states for Wflow.

Wflow low-level methods#

Input/Output methods#

utils.read_csv_output(fn, config, maps)

Read wflow output csv timeseries and parse to dictionary.

Utility methods#

utils.get_grid_from_config(var_name[, ...])

Get actual grid values from config including scale and offset.