Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This Open Source project is build by B-Open - https://www.bopen.eu
xarray-ecmwf is a Python library and [Xarray](https://docs.xarray.dev) backend with the following functionalities:

- opens an ECMWF style request as a Xarray Dataset connected to the remote services
- the [Climate Data Store](https://cds.climate.copernicus.eu) via [cdsapi](https://github.com/ecmwf/cdsapi): ERA5, Seasonal forecasts
- the [Athospheric Data Store](https://ads.atmosphere.copernicus.eu) via cdsapi
- the [Climate Data Store](https://cds.climate.copernicus.eu) via [ecmwf-datastores-client](https://github.com/ecmwf/ecmwf-datastores-client): ERA5, Seasonal forecasts
- the [Atmospheric Data Store](https://ads.atmosphere.copernicus.eu) via ecmwf-datastores-client
- the [ECMWF Open data](https://www.ecmwf.int/en/forecasts/datasets/open-data) via [ecmwf-opendata](https://github.com/ecmwf/ecmwf-opendata): High resolution forecasts, ensemble forecast
- allows lazy loading the data and well integrated with [Dask](https://www.dask.org) and [Dask.distributed](https://distributed.dask.org)
- allows chunking the input request according to a configurable splitting strategy. Allowed strategies:
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ dependencies:
- pytest
- pytest-cov
# DO NOT EDIT ABOVE THIS LINE, ADD DEPENDENCIES BELOW
- cdsapi
- ecmwf-api-client
- ecmwf-datastores-client
- ecmwf-opendata
- pandas-stubs
- pip
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ channels:
# DO NOT EDIT ABOVE THIS LINE, ADD DEPENDENCIES BELOW AS SHOWN IN THE EXAMPLE
dependencies:
- attrs
- cdsapi
- cfgrib
- ecmwf-datastores-client
- ecmwf-opendata
- pip
- xarray
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering"
]
dependencies = ["cdsapi", "cfgrib", "ecmwf-opendata", "polytope-client", "xarray"]
description = "Xarray backend to access data via the cdsapi package"
dependencies = ["cfgrib", "ecmwf-datastores-client", "ecmwf-opendata", "polytope-client", "xarray"]
description = "Xarray backend to access ECMWF datastores"
dynamic = ["version"]
license = {file = "LICENSE"}
name = "xarray-ecmwf"
Expand All @@ -32,7 +32,6 @@ strict = true
[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
"cdsapi",
"cf2cdm",
"ecmwf",
"ecmwf.opendata",
Expand Down
8 changes: 4 additions & 4 deletions xarray_ecmwf/client_cdsapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any

import attrs
import cdsapi
import ecmwf.datastores
import numpy as np
import xarray as xr

Expand All @@ -16,13 +16,13 @@

@attrs.define
class CdsapiRequestClient:
client_kwargs: dict[str, Any] = {"quiet": True, "retry_max": 1}
client_kwargs: dict[str, Any] = {"maximum_tries": 1}

def submit_and_wait_on_result(self, request: dict[str, Any]) -> Any:
request = request.copy()
dataset = request.pop("dataset")
client = cdsapi.Client(**self.client_kwargs)
return client.retrieve(dataset, request | {"format": "grib"})
client = ecmwf.datastores.Client(**self.client_kwargs)
return client.submit_and_wait_on_results(dataset, request | {"format": "grib"})

def get_filename(self, result: Any) -> str:
return result.location.split("/")[-1] # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions xarray_ecmwf/engine_ecmwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def retrieve_once(
if not os.path.isdir(self.cache_folder):
os.makedirs(self.cache_folder, exist_ok=True)

with xr.backends.locks.get_write_lock(f"{HOSTNAME}-grib"): # type: ignore
with xr.backends.locks.get_write_lock(f"{HOSTNAME}-grib"):
if not os.path.exists(path):
robust_save_to_file(self.request_client.download, (result,), path)
ds = self.open_dataset(path)
Expand Down Expand Up @@ -142,7 +142,7 @@ def cached_empty_dataset(self, request: dict[str, Any]) -> Iterator[xr.Dataset]:
if not os.path.exists(path):
with self.retrieve(request) as read_ds:
# check again as the retrieve may be long
with xr.backends.locks.get_write_lock(f"{HOSTNAME}-zarr"): # type: ignore
with xr.backends.locks.get_write_lock(f"{HOSTNAME}-zarr"):
if not os.path.exists(path):
# NOTE: be sure that read_ds is chunked so compute=False only
# writes the metadata. Some open_dataset
Expand Down
Loading