Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(era5): upgrade to datapi client #71

Merged
merged 18 commits into from
Dec 13, 2024
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
24 changes: 13 additions & 11 deletions openhexa/toolbox/era5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,21 @@ The package contains 3 modules:
To download products from the Climate Data Store, you will need to create an account and generate an API key in ECMWF (see [CDS](https://cds.climate.copernicus.eu/)).

```python
from openhexa.toolbox.era5.cds import Client
from openhexa.toolbox.era5.cds import CDS, build_request, bounds_from_file

cds = Client(key="<cds_api_key>")
cds = CDS(key="<cds_api_key>")

request = cds.build_request(
request = build_request(
variable="2m_temperature",
year=2024,
month=4
month=4,
day=[1, 2, 3],
time=[1, 6, 12, 18]
)

cds.download(
cds.retrieve(
request=request,
dst_file="data/product.grib"
dst_file="data/t2m.grib"
)
```

Expand All @@ -54,15 +56,15 @@ downloaded.
```python
bounds = bounds_from_file(fp=Path("data/districts.parquet"), buffer=0.5)

request = cds.build_request(
request = build_request(
variable="total_precipitation",
year=2023,
month=10,
days=[1, 2, 3, 4, 5],
area=bounds
)

cds.download(
cds.retrieve(
request=request,
dst_file="data/product.grib"
)
Expand All @@ -73,8 +75,8 @@ To download multiple products for a given period, use `Client.download_between()
```python
cds.download_between(
variable="2m_temperature",
start=datetime(2020, 1, 1),
end=datetime(2021, 6, 1),
start=datetime(2020, 1, 1, tzinfo=timezone.utc),
end=datetime(2021, 6, 1, tzinfo=timezone.utc),
dst_dir="data/raw/2m_temperature",
area=bounds
)
Expand All @@ -83,7 +85,7 @@ cds.download_between(
Checking latest available date in the ERA5-Land dataset:

```python
cds = Client("<api_key>")
cds = CDS("<api_key>")

cds.latest
```
Expand Down
Loading
Loading