ogd_api¶
Open Government Data API helpers.
Functions
|
Download forecast asset and its static coordinate files from OGD. |
|
Get asset URLs from OGD. |
|
Get collection asset URL from OGD. |
|
Get data from OGD. |
Classes
|
|
|
Define filters for the STAC Search API. |
- class meteodatalab.ogd_api.Collection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- ICON_CH1 = 'ogd-forecasting-icon-ch1'¶
Collection of icon-ch1-eps model outputs
- ICON_CH2 = 'ogd-forecasting-icon-ch2'¶
Collection of icon-ch2-eps model outputs
- class meteodatalab.ogd_api.Request(collection: Collection, variable: str, reference_datetime: str, perturbed: bool, horizon: timedelta | list[timedelta])[source]¶
Define filters for the STAC Search API.
- Parameters:
collection (Collection) – Name of the STAC collection.
variable (str) – Name of the variable following the DWD convention.
reference_datetime (str) – Forecast reference datetime in ISO 8601 format. Alias: ref_time
perturbed (bool) – If true, retrieve ensemble forecast members. Otherwise, retrieve deterministic (control) forecast.
horizon (datetime.timedelta or list[datetime.timedelta]) – Lead time of the requested data. Can be supplied as string in ISO 8601 format. Alias: lead_time
- meteodatalab.ogd_api.download_from_ogd(request: Request, target: Path) None [source]¶
Download forecast asset and its static coordinate files from OGD.
The request attributes define filters for the STAC search API according to the forecast extension.
In addition to the main asset, this function downloads static files with horizontal and vertical coordinates, as the forecast item does not include the horizontal or vertical coordinates.
- Parameters:
request (Request) – Asset search filters, must select a single asset.
target (Path) – Target path where to save the asset, must be a directory.
- Raises:
ValueError – when the request does not select exactly one asset.
RuntimeError – if the checksum verification fails.
- meteodatalab.ogd_api.get_asset_urls(request: Request) list[str] [source]¶
Get asset URLs from OGD.
The request attributes define filters for the STAC search API according to the forecast extension. Forecasts reference datetimes for which not all requested lead times are present are excluded from the result.
- Parameters:
request (Request) – Asset search filters
- Raises:
ValueError – when no datetime can be found in the asset URL for ‘latest’ requests.
- Returns:
URLs of the selected assets.
- Return type:
list[str]
- meteodatalab.ogd_api.get_collection_asset_url(collection_id: str, asset_id: str) str [source]¶
Get collection asset URL from OGD.
Query the STAC collection assets and return the URL for the given asset ID.
- Parameters:
collection_id (str) – Full STAC collection ID
asset_id (str) – The ID of the static asset to retrieve.
- Returns:
The pre-signed URL of the requested static asset.
- Return type:
str
- Raises:
KeyError – If the asset is not found in the collection.
- meteodatalab.ogd_api.get_from_ogd(request: Request) DataArray [source]¶
Get data from OGD.
The request attributes define filters for the STAC search API according to the forecast extension. It is recommended to enable caching through earthkit-data. A warning message is emitted if the cache is disabled.
- Parameters:
request (Request) – Asset search filters, must select a single asset.
- Raises:
ValueError – when the request does not select exactly one asset.
- Returns:
A data array of the selected asset including GRIB metadata and coordinates.
- Return type:
xarray.DataArray