Skip to content

Commit f97896b

Browse files
authored
code: Fix cdsapi syntax for ERA5 (#454)
1 parent e2d98c6 commit f97896b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

RELEASE_NOTES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Upcoming Release
2828
* Fix `atlite.Cutout()` to be able to handle the `bounds` argument to be a `DataFrame` in accordance to the docstring (https://github.com/PyPSA/atlite/pull/445).
2929
* Raise a `FileNotFoundError` if the `temp_dir` explicitly specified for cutout preparation does not exist instead of failing with an obfuscated error message (https://github.com/PyPSA/atlite/pull/445).
3030
* Addressed `rasterio` DeprecationWarning on `crs.is_valid`.
31+
* Fix calls to `cdsapi` for ERA5 to be compliant with current API syntax (https://github.com/PyPSA/atlite/pull/414 and https://github.com/PyPSA/atlite/pull/454).
3132

3233
`v0.4.1 <https://github.com/PyPSA/atlite/releases/tag/v0.4.1>`__ (12th May 2025)
3334
=======================================================================================

atlite/datasets/era5.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ def retrieval_times(coords, static=False, monthly_requests=False):
290290
time = coords["time"].to_index()
291291
if static:
292292
return {
293-
"year": str(time[0].year),
294-
"month": str(time[0].month),
295-
"day": str(time[0].day),
293+
"year": [time[0].strftime("%Y")],
294+
"month": [time[0].strftime("%m")],
295+
"day": [time[0].strftime("%d")],
296296
"time": time[0].strftime("%H:00"),
297297
}
298298

@@ -303,18 +303,18 @@ def retrieval_times(coords, static=False, monthly_requests=False):
303303
if monthly_requests:
304304
for month in t.month.unique():
305305
query = {
306-
"year": str(year),
307-
"month": str(month),
308-
"day": list(t[t.month == month].day.unique()),
309-
"time": [f"{h:02d}:00" for h in t[t.month == month].hour.unique()],
306+
"year": [str(year)],
307+
"month": [t[t.month == month][0].strftime("%m")],
308+
"day": list(t[t.month == month].strftime("%d").unique()),
309+
"time": list(t[t.month == month].strftime("%H:00").unique()),
310310
}
311311
times.append(query)
312312
else:
313313
query = {
314-
"year": str(year),
315-
"month": list(t.month.unique()),
316-
"day": list(t.day.unique()),
317-
"time": [f"{h:02d}:00" for h in t.hour.unique()],
314+
"year": [str(year)],
315+
"month": list(t.strftime("%m").unique()),
316+
"day": list(t.strftime("%d").unique()),
317+
"time": list(t.strftime("%H:00").unique()),
318318
}
319319
times.append(query)
320320
return times

0 commit comments

Comments
 (0)