hydromt_delwaq.components.DelwaqForcingComponent#
Summary of Methods and Attributes#
Component class |
Methods |
Attributes |
|---|---|---|
|
|
- class hydromt_delwaq.components.DelwaqForcingComponent(model: Model, *, filename: str = 'dynamicdata/{name}.dat', region_component: str | None = None)[source]#
Bases:
GridComponentDelwaq forcing component.
This class is used for setting, creating, writing, and reading the Delwaq forcing. The forcing 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 DelwaqForcingComponent.
- Parameters:
model (Model) – HydroMT model instance
filename (str, optional) – Default path relative to the root where the forcing file(s) will be read and written. By default “dynamicdata/{name}.dat”.
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(filename: str = 'dynamicdata/{name}.dat')[source]#
Read netcdf copy of the forcing if exists at <root/filename>.
- Parameters:
filename (str, optional) – filename relative to model root and should contain a {name} placeholder, by default ‘dynamicdata/{name}.dat’
- write(filename: str = 'dynamicdata/{name}.dat', write_nc: bool = False)[source]#
Write forcing at <root/filename> in binary format.
Can also write a NetCDF copy if write_nc is True. The output files are:
flow.dat binary: water fluxes [m3/s]
volume.dat binary: water volumes [m3]
sediment.dat binary: sediment particles from land erosion [g/timestep]
climate.dat binary: climate fluxes for climate_vars
- test_equal(other: ModelComponent) tuple[bool, dict[str, str]][source]#
Test if two forcing 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.