hydromt.data_catalog.DataCatalog.get_dataset#
- DataCatalog.get_dataset(data_like: str | SourceSpecDict | Path | Dataset | DataArray | DatasetSource, variables: List | None = None, handle_nodata: NoDataStrategy = NoDataStrategy.RAISE, time_range: Annotated[Tuple[datetime, datetime], BeforeValidator(func=_time_range_from_str, json_schema_input_type=PydanticUndefined), AfterValidator(func=_time_range_validate)] | None = None, single_var_as_array: bool = True, provider: str | None = None, version: str | None = None, **kwargs) Dataset [source]#
Return a clipped, sliced and unified Dataset.
To slice the data to the time period of interest, provide the time_range argument. To return only the dataset variables of interest provide the variables argument.
NOTE: Unless single_var_as_array is set to False a single-variable data source will be returned as xarray.DataArray rather than a xarray.Dataset.
- Parameters:
data_like (
Union[ str
,SourceSpecDict
,Path
,xr.Dataset
,xr.DataArray
,DatasetSource ]
) – Data catalog key, path to Dataset file, DatasetSource or Dataset xarray object. The catalog key can be a string or a dictionary with the following keys: {‘name’, ‘provider’, ‘version’}. If a path to a file is provided it will be added to the catalog with its based on the file basename.variables (
Optional[List]
, optional) – Names of Dataset variables to return, or all if None, by default Nonehandle_nodata (
NoDataStrategy
, optional) – How to react when no data is found, by default NoDataStrategy.RAISEtime_range (
Optional[TimeRange]
, optional) – Start and end date of period of interest, or entire period if None, by default Nonesingle_var_as_array (
bool
, optional) – Wether to return a xr.DataArray if the dataset consists of a single variable, by default Trueprovider (
Optional[str]
, optional) – Specifies a data provider, by default Noneversion (
Optional[str]
, optional) – Specifies a data version, by default None**kwargs – Extra keyword arguments passed to the DatasetSource construction
- Returns:
a clipped, sliced and unified Dataset
- Return type:
xr.Dataset
- Raises:
ValueError – If data_like is of an unknown type
NoDataException – If no data is found and handle_nodata is NoDataStrategy.RAISE