hydromt_wflow.components.WflowStatesComponent#
Summary of Methods and Attributes#
Component class |
Methods |
Attributes |
|---|---|---|
|
|
- class WflowStatesComponent(model: Model, *, filename: str = 'instate/instates.nc', region_component: str | None = None, region_filename: str | None = 'staticgeoms/states_region.geojson')[source]#
Bases:
GridComponentModelComponent class for Wflow states.
This class is used for setting, creating, writing, and reading the Wflow states. The states component data stored in the
dataproperty of this class is of the hydromt.gis.raster.RasterDataset type which is an extension of xarray.Dataset for regular grid.- set(data: Dataset | DataArray, name: str | None = None)[source]#
Set the states data.
- Parameters:
data (xr.Dataset or xr.DataArray) – The states data to set/add.
name (str, optional) – Name of new data layer, this is used to overwrite the name of a DataArray and ignored if data is a Dataset.
- drop_vars(names: list[str], errors: str = 'raise')[source]#
Drop variables from the states.
This method is a wrapper around the xarray.Dataset.drop_vars method.
- Parameters:
names (list of str) – List of variable names to drop from the states.
errors (str, optional {raise, ignore}) – How to handle errors. If ‘raise’, raises a ValueError error if any of the variable passed are not in the dataset. If ‘ignore’, any given names that are in the dataset are dropped and no error is raised.
- clip(reservoir_name: str = 'reservoir_area_id', reservoir_states: list[str] = [])[source]#
Clip the states component to the region of the region component.
If no region component is set, the states component is clipped to its own extent.
- Parameters:
- read()[source]#
Read states at <root/dir_input/state.path_input>.
Checks the path of the file in the config toml using both
state.path_inputanddir_input. If not found uses the default pathinstate/instates.ncin the root folder.- Parameters:
filename (str or Path, optional) – A path relative to the root where the states file will be read from. By default ‘instate/instates.nc’.
- write(filename: str | None = None)[source]#
Write states at <root/dir_input/state.path_input> in model ready format.
Checks the path of the file in the config toml using both
state.path_inputanddir_input. If not found uses the default pathinstate/instates.ncin the root folder. If filename is provided, it will be used and configstate.path_inputwill be updated accordingly.- Parameters:
filename (str or Path, optional) – Name of the states file, relative to model root and
dir_inputif any. By default None to use the name as defined in the model config file.
- test_equal(other: ModelComponent) tuple[bool, dict[str, str]][source]#
Test if two staticmaps components are equal.
Checks the model component type as well as the data variables and their values.
- property bounds: Tuple[float, float, float, float] | None#
Returns the bounding box of the model grid.
- property data_catalog: DataCatalog#
Return the data catalog of the model this component is associated with.
- finish_write()#
Finish the write functionality after cleanup was called for all components in the model.
All DeferredFileClose objects can overwrite any lazy loaded files now.
- static get_mask_layer(mask: str | DataArray | None, *args) DataArray | None#
Get the proper mask layer based on itself or a layer in a Dataset.
- property model: Model#
Return the model object this component is associated with.
- property region: GeoDataFrame | None#
Provide access to the underlying GeoDataFrame data of the model region.
- property root: ModelRoot#
Return the root of the model this component is associated with.
- write_region(filename: str | None = None, *, to_wgs84: bool = False, to_file_kwargs: dict[str, Any] | None = None) None#
Write the model region to file.
The region is an auxiliary file that is often not required by the model, but can be useful for getting data from the data catalog. Plugin implementors may choose to write this file on write for a specific component.
- Parameters:
filename (str, optional) – The filename to write the region to. If None, the filename provided at initialization is used.
to_wgs84 (bool) – If True, the region is reprojected to WGS84 before writing.
to_file_kwargs (dict, optional) – Additional keyword arguments passed to the geopandas.GeoDataFrame.to_file function.