hydromt.data_catalog.sources.DataSource#
- pydantic model hydromt.data_catalog.sources.DataSource[source]#
A DataSource is a parsed section of a DataCatalog.
The DataSource, specific for a data type within HydroMT, is responsible for validating the input from the DataCatalog, to ensure the workflow fails as early as possible. A DataSource has information on the driver that the data should be read with, and is responsible for initializing this driver.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- field data_adapter: DataAdapterBase [Required]#
- field driver: BaseDriver [Required]#
- field uri_resolver: URIResolver [Optional]#
- data_type: ClassVar[DataType]#
- field metadata: SourceMetadata [Optional]#
- get_time_range(detect: bool = True, strict: bool = False) TimeRange | None[source]#
Detect the time range of the dataset if applicable.
Override in subclasses if applicable.
- Parameters:
detect (
bool,Optional) – If True and the time range is not set in metadata, attempt to detect it. If False, only use the time range in metadata if it exists.- Returns:
range – Instance containing the start and end of the time dimension. Range is inclusive on both sides. None if not set and detect is False.
- Return type:
TimeRange, optional
- get_bbox(crs: CRS | None = None, detect: bool = True, strict: bool = False) Tuple[float, float, float, float], <function _validate_bbox at 0x7f793cba1d00>], int] | None[source]#
Get the bounding box and crs of the data source if applicable.
This method should be overridden in subclasses if applicable.
- Returns:
bbox – The bounding box of the data source. None if not applicable.
- Return type:
TotalBounds | None
Notes
TotalBounds is a tuple of (bbox, crs), where bbox is a tuple of (minx, miny, maxx, maxy) and crs is the coordinate reference system.
- abstract to_stac_catalog(handle_nodata: NoDataStrategy = NoDataStrategy.IGNORE) Catalog | None[source]#
Convert source into a STAC Catalog representation.
The collection will contain an asset for each of the associated files.
- Parameters:
handle_nodata (
NoDataStrategy, optional) – The error handling strategy. Options are: “raise” to raise an error on failure, “skip” to skip the source on failure, and “coerce” (default) to set default values on failure.- Returns:
The STAC Catalog representation of the source, or None if the dataset was skipped.
- Return type:
StacCatalog, optional