hydromt_delwaq.components.DelwaqStaticdataComponent#
Summary of Methods and Attributes#
Component class |
Methods |
Attributes |
|---|---|---|
|
|
- class hydromt_delwaq.components.DelwaqStaticdataComponent(model: Model, *, filename: str = 'staticdata/{name}.dat', region_filename: str = 'geoms/region.geojson')[source]#
Bases:
GridComponentDelwaq staticdata component.
Inherits from the HydroMT-core GridComponent model-component. It is used for setting, creating, writing, and reading static and cyclic data for a Delwaq model on a regular grid. The 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.Initialize a DelwaqStaticdataComponent.
- Parameters:
- read(filename: str = 'staticdata/{name}.dat', **kwargs)[source]#
Read staticdata at <root/fn> and parse to xarray.
For now, this function only allows to read the netcdf copy of the grid.
- Parameters:
filename (str, optional) – filename relative to model root and should contain a {name} placeholder, by default ‘staticdata/{name}.dat’. For the netcdf file, the placeholder will be replaced by the name staticdata.
- write(filename: str = 'staticdata/{name}.dat')[source]#
Write grid at <root/fn> in NetCDF and binary format.
- Parameters:
fn (str, optional) – filename relative to model root and should contain a {name} placeholder, by default ‘staticdata/{name}.dat’. For the netcdf file, the placeholder will be replaced by the name staticdata.
- write_monitoring(monpoints, monareas)[source]#
Write monitoring files and config in ASCII format.
- Input:
monpoints - xr.DataArray of monitoring points location
monareas - xr.DataArray of monitoring areas location
- test_equal(other: ModelComponent) tuple[bool, dict[str, str]][source]#
Test if two staticdata 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.