hydromt_delwaq.components.DelwaqHydromapsComponent#
Summary of Methods and Attributes#
Component class |
Methods |
Attributes |
|---|---|---|
|
|
- class hydromt_delwaq.components.DelwaqHydromapsComponent(model: Model, *, filename: str = 'hydromodel/{name}.tif', region_component: str | None = None)[source]#
Bases:
GridComponentDelwaq hydromaps component.
Inherits from the HydroMT-core GridComponent model-component. It is used to store metadata from the gridded hydrological or hydraulic model Delwaq is linked to. Contains for example the segment ID, mask of active cells…
Initialize a DelwaqHydromapsComponent.
- Parameters:
model (Model) – HydroMT model instance
filename (str) – The path to use for reading and writing of component data by default. By default “hydromodel/{name}.tif”.
region_component (str, optional) – The name of the region component to use as reference for this component’s region. If None, the region will be set to the grid extent.
- read(**kwargs)[source]#
Read hydromaps at <root/hydromodel> and parse to xarray.
Keywords arguments are passed to the underlying hydromt.readers.open_mfraster function.
- test_equal(other: ModelComponent) tuple[bool, dict[str, str]][source]#
Test if two hydromaps 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.
- set(data: DataArray | Dataset | ndarray, name: str | None = None, mask: str | DataArray | None = None, force_sn: bool = False)#
Add data to grid.
All layers of grid must have identical spatial coordinates.
- Parameters:
data (xarray.DataArray or xarray.Dataset) – new map layer to add to grid
name (str, optional) – Name of new map layer, this is used to overwrite the name of a DataArray and ignored if data is a Dataset
mask (xr.DataArray, optional) – Name of the mask layer in the grid (self) or data, or directly the mask layer to use. Should be a DataArray where .raster.nodata is used to define the mask. If None or not present as a layer, no masking is applied.
force_sn (bool, optional, default=False) – If True, the y-axis is oriented such that increasing y values go from South to North. If False, incoming data is used as is.
- 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.