API reference#

Wflow model class#

Initialize#

WflowModel(root, mode, config_fn, data_libs)

Wflow model class.

Setup components#

WflowModel.setup_config(**cfdict)

Update config with a dictionary.

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_lakes(lakes_fn[, ...])

Generate maps of lake areas and outlets.

WflowModel.setup_reservoirs(reservoirs_fn[, ...])

Generate maps of reservoir areas and outlets.

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

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

Set KsatHorFrac parameter values from a predetermined map.

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

Set the RootingDepth.

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_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([dtype, nodata])

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.

Attributes#

WflowModel.region

Returns the geometry of the model area of interest.

WflowModel.crs

Returns coordinate reference system embedded in the model grid.

WflowModel.res

Returns the resolution of the model grid.

WflowModel.root

Path to model folder.

WflowModel.config

Model configuration.

WflowModel.grid

Model static gridded data as xarray.Dataset.

WflowModel.geoms

Model geometries.

WflowModel.forcing

Model forcing.

WflowModel.states

Model states.

WflowModel.results

Model results.

WflowModel.tables

Return a dictionary of pandas.DataFrames representing wflow intbl files.

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.

High level methods#

WflowModel.read()

Read the complete model schematization and configuration from file.

WflowModel.write([config_fn, grid_fn, ...])

Write the complete model schematization and configuration to file.

WflowModel.build([region, write, opt])

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

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

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

WflowModel.set_root(root[, mode])

Initialize the model root.

General methods#

WflowModel.setup_config(**cfdict)

Update config with a dictionary.

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

Get a config value at key(s).

WflowModel.set_config(*args)

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

WflowModel.read_config([config_fn])

Parse config from file.

WflowModel.write_config([config_name, ...])

Write config to <root/config_fn>.

WflowModel.set_grid(data[, name])

Add data to grid.

WflowModel.read_grid(**kwargs)

Read wflow static input and add to grid.

WflowModel.write_grid([fn_out])

Write grid to wflow static data file.

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

Clip grid to subbasin.

WflowModel.set_geoms(geom, name)

Add data to the geoms attribute.

WflowModel.read_geoms([geoms_fn])

Read static geometries and adds to geoms.

WflowModel.write_geoms([geoms_fn, precision])

Write geoms in GeoJSON format.

WflowModel.set_forcing(data[, name, ...])

Add data to forcing attribute.

WflowModel.read_forcing()

Read forcing.

WflowModel.write_forcing([fn_out, freq_out, ...])

Write forcing at fn_out in model ready format.

WflowModel.clip_forcing([crs])

Return clippped forcing for subbasin.

WflowModel.set_states(data[, name, ...])

Add data to states attribute.

WflowModel.read_states()

Read states at <root/instate/> and parse to dict of xr.DataArray.

WflowModel.write_states([fn_out])

Write states at <root/instate/> in model ready format.

WflowModel.clip_states([crs])

Return clippped states for subbasin.

WflowModel.set_results(data[, name, ...])

Add data to results attribute.

WflowModel.read_results()

Read results at <root/?/> and parse to dict of xr.DataArray/xr.Dataset.

WflowModel.set_tables(df, name)

Add table <pandas.DataFrame> to model.

WflowModel.read_tables(**kwargs)

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

WflowModel.write_tables()

Write tables at <root>.

WflowModel.set_flwdir([ftype])

Parse pyflwdir.FlwdirRaster object parsed from the wflow ldd.

WflowSediment model class#

Initialize#

WflowSedimentModel(root, mode, config_fn, ...)

The wflow sediment model class, a subclass of WflowModel.

Setup components#

WflowSedimentModel.setup_config(**cfdict)

Update config with a dictionary.

WflowSedimentModel.setup_basemaps(region, ...)

Build the DEM and flow direction for a Wflow model.

WflowSedimentModel.setup_rivers(*args, **kwargs)

Copy the functionality of WflowModel.

WflowSedimentModel.setup_lakes([lakes_fn, ...])

Generate maps of lake areas and outlets.

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

Generate maps of lake areas and outlets.

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

Derive several wflow maps based on 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([...])

Generate constant parameter maps for all active model cells.

WflowSedimentModel.setup_grid_from_raster(...)

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

Attributes#

WflowSedimentModel.region

Returns the geometry of the model area of interest.

WflowSedimentModel.crs

Returns coordinate reference system embedded in the model grid.

WflowSedimentModel.res

Returns the resolution of the model grid.

WflowSedimentModel.root

Path to model folder.

WflowSedimentModel.config

Model configuration.

WflowSedimentModel.grid

Model static gridded data as xarray.Dataset.

WflowSedimentModel.geoms

Model geometries.

WflowSedimentModel.forcing

Model forcing.

WflowSedimentModel.states

Model states.

WflowSedimentModel.results

Model results.

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.

High level methods#

WflowSedimentModel.read()

Read the complete model schematization and configuration from file.

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

Write the complete model schematization and configuration to file.

WflowSedimentModel.build([region, write, opt])

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

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

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

WflowSedimentModel.set_root(root[, mode])

Initialize the model root.

General methods#

WflowSedimentModel.setup_config(**cfdict)

Update config with a dictionary.

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

Get a config value at key(s).

WflowSedimentModel.set_config(*args)

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

WflowSedimentModel.read_config([config_fn])

Parse config from file.

WflowSedimentModel.write_config([...])

Write config to <root/config_fn>.

WflowSedimentModel.set_grid(data[, name])

Add data to grid.

WflowSedimentModel.read_grid(**kwargs)

Read wflow static input and add to grid.

WflowSedimentModel.write_grid([fn_out])

Write grid to wflow static data file.

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

Clip grid to subbasin.

WflowSedimentModel.set_geoms(geom, name)

Add data to the geoms attribute.

WflowSedimentModel.read_geoms([geoms_fn])

Read static geometries and adds to geoms.

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

Write geoms in GeoJSON format.

WflowSedimentModel.set_forcing(data[, name, ...])

Add data to forcing attribute.

WflowSedimentModel.read_forcing()

Read forcing.

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

Write forcing at fn_out in model ready format.

WflowSedimentModel.clip_forcing([crs])

Return clippped forcing for subbasin.

WflowSedimentModel.set_states(data[, name, ...])

Add data to states attribute.

WflowSedimentModel.read_states()

Read states at <root/instate/> and parse to dict of xr.DataArray.

WflowSedimentModel.write_states([fn_out])

Write states at <root/instate/> in model ready format.

WflowSedimentModel.set_results(data[, name, ...])

Add data to results attribute.

WflowSedimentModel.read_results()

Read results at <root/?/> and parse to dict of xr.DataArray/xr.Dataset.

WflowSedimentModel.set_flwdir([ftype])

Parse pyflwdir.FlwdirRaster object parsed from the wflow ldd.

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.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.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.landuse(da, ds_like, df[, params, ...])

Return landuse map and related parameter maps.

workflows.lai(da, ds_like[, logger])

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.ksathorfrac(da, ds_like, ...)

Create KsatHorfrac map.

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 c and kvfrac soil properties for paddy fields.

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

Return waterbody (reservoir/lake) maps (see list below).

workflows.reservoirattrs(gdf[, ...])

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

workflows.lakeattrs(ds, gdf[, rating_dict, ...])

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

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#

read_csv_results(fn, config, maps)

Read wflow results csv timeseries and parse to dictionnary.

pcrm.read_staticmaps_pcr(root[, crs, obj])

Read pcraster staticmaps at <root/staticmaps> and parse to xarray.

pcrm.write_staticmaps_pcr(staticmaps, root)

Write staticmaps at <root/staticmaps> in PCRaster maps format.

Utility methods#

utils.get_grid_from_config(*args[, config, ...])

Get actual grid values from config including scale and offset.