hydromt_wflow.WflowBaseModel#
- class WflowBaseModel(root: str | None = None, config_filename: str | None = None, mode: str = 'w', data_libs: list[str] | str | None = None, **catalog_keys)[source]#
Base Class for all Wflow Model implementations.
DO NOT USE THIS CLASS DIRECTLY. ONLY USE SUBCLASSES OF THIS CLASS.
It provides common functionality (IO, components and workflows). Any specific implementation details for either sediment of sbm should be handled in the derived classes.
- Parameters:
root (str, optional) – Model root, by default None (current working directory)
config_filename (str, optional) – A path relative to the root where the configuration file will be read and written if user does not provide a path themselves. By default “wflow.toml”
mode ({'r','r+','w'}, optional) – read/append/write mode, by default “w”
data_libs (list[str] | str, optional) – List of data catalog configuration files, by default None
**catalog_keys – Additional keyword arguments to be passed down to the DataCatalog.
- __init__(root: str | None = None, config_filename: str | None = None, mode: str = 'w', data_libs: list[str] | str | None = None, **catalog_keys)[source]#
Initialize a model.
- Parameters:
root (str, Path, optional) – Model root, by default the current working directory:
Path.cwd()components (Dict[str, Any], optional) –
Dictionary of components to add to the model, by default None Every entry in this dictionary contains the name of the component as key, and the component object as value, or a dictionary with options passed to the component initializers. If a component is a dictionary, the key ‘type’ should be provided with the name of the component type.
{ "grid": { "type": "GridComponent", "filename": "path/to/grid.nc" } }
mode ({'r','r+','w'}, optional) – read/append/write mode, by default “w”
data_libs (List[str], optional) – List of data catalog configuration files, by default None
region_component (str, optional) – The name of the region component in the components dictionary. If None, the model will can automatically determine the region component if there is only one SpatialModelComponent. Otherwise it will raise an error. If there are no SpatialModelComponent it will raise a warning that region functionality will not work.
**catalog_keys – Additional keyword arguments to be passed down to the DataCatalog.
Methods
__init__([root, config_filename, mode, ...])Initialize a model.
add_component(name, component)Add a component to the model.
build(*[, write])Single method to build a model from scratch based on settings in steps.
clip(region[, inverse_clip, clip_forcing, ...])Clip model to region.
close()Close all components by closing their open files.
from_dict(model_dict)Construct a model with the components and other init arguments in the yaml file located at path.
from_yml(path)Construct a model with the components and other init arguments in the yaml file located at path.
get_component(name)Get a component from the model.
read([config_filename, geoms_folder])Read components from disk.
read_outputs()Read outputs at <root/dir_output>.
set_flwdir([ftype])Parse pyflwdir.FlwdirRaster object parsed from the wflow ldd.
set_states(data[, name])Add data to states.
setup_areamap(area_fn, col2raster[, nodata, ...])Set area map from vector data to save wflow outputs for specific area.
setup_basemaps(region, hydrography_fn[, ...])Build the DEM and flow direction for a Wflow model.
setup_config(data)Set the config dictionary at key(s) with values.
setup_config_output_timeseries(mapname[, ...])Set the default gauge map based on basin outlets.
setup_constant_pars(**kwargs)Generate constant parameter maps for all active model cells.
setup_gauges(gauges_fn[, index_col, ...])Set a gauge map based on
gauges_fndata.setup_grid_from_raster(raster_fn, ...[, ...])Add data variable(s) from
raster_fnto grid object.setup_lulcmaps(lulc_fn, *[, ...])Derive several wflow maps based on landuse-landcover (LULC) data.
setup_lulcmaps_from_vector(lulc_fn, *[, ...])Derive several wflow maps based on vector landuse-landcover (LULC) data.
setup_outlets([river_only, toml_output, ...])Set the default gauge map based on basin outlets.
setup_rivers(hydrography_fn[, ...])Set all river parameter maps.
setup_riverwidth([predictor, fill, fit, ...])Set the river width parameter based on power-law relationship with a predictor.
test_equal(other)Test if two models are equal, based on their components.
update(*[, model_out, write, steps, ...])Single method to update a model based the settings in steps.
write([config_filename, grid_filename, ...])Write the complete model schematization and configuration to file.
write_data_catalog([root, data_lib_path, ...])Write the data catalog to data_lib_path.
Attributes
Returns a basin(s) geometry as a geopandas.GeoDataFrame.
basins_highresReturns a high resolution basin(s) geometry.
configReturn the config component.
Returns coordinate reference system embedded in region.
Return the pyflwdir.FlwdirRaster object parsed from wflow ldd.
forcingReturn the forcing component.
geomsReturn the geoms component.
nameoutput_csvReturn the WflowOutputCsvComponent instance.
output_gridReturn the WflowOutputGridComponent instance.
output_scalarReturn the WflowOutputScalarComponent instance.
regionReturn the model's region component.
Return a river geometry as a geopandas.GeoDataFrame.
statesReturn the states component.
staticmapsReturn the staticmaps component.
tablesReturn the WflowTablesComponent instance.
data_catalogDataCatalog for data access
Model root