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_laimaps(lai_fn)

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

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

Return staticmaps.

WflowModel.staticgeoms

Return static 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()

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()

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([geom_fn])

Read static geometries and adds to geoms.

WflowModel.write_geoms([geom_fn])

Write geoms in <root/geom_fn> 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_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()

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()

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([geom_fn])

Read static geometries and adds to geoms.

WflowSedimentModel.write_geoms([geom_fn])

Write geoms in <root/geom_fn> 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.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[, logger, ...])

Return landuse map and related parameter maps.

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