Add alternative source for ERA5 data to eliminate queueing#507
Add alternative source for ERA5 data to eliminate queueing#507mrmorawski wants to merge 64 commits into
Conversation
…mpare against existing era5 cutout
…erpolation if grids are aligned, grid interpolation sanitise only if interpolatingfor consistency with cds
…und 0 longitude index
for more information, see https://pre-commit.ci
…e, reverse subset order, better retry config
|
@mrmorawski, let me know when I should give this another review regarding the latest changes. |
|
Thanks for checking in @fneum !
I've been profiling and optimising memory usage, I think I mostly have it figured out. I will give you a heads up soon, most likely this week.
…-------- Original Message --------
On Monday, 06/01/26 at 11:52 Fabian Neumann ***@***.***> wrote:
fneum left a comment [(PyPSA/atlite#507)](#507 (comment))
***@***.***(https://github.com/mrmorawski), let me know when I should give this another review regarding the latest changes.
—
Reply to this email directly, [view it on GitHub](#507?email_source=notifications&email_token=A5UF4ZWP5LS66KN3BA4I3ET45VG37A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJZGE2DIOBUHA22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4591448485), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/A5UF4ZVYPOWEG4I7O6DN5XD45VG37AVCNFSM6AAAAACYZ3YY7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DKOJRGQ2DQNBYGU).
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for [iOS](https://github.com/notifications/mobile/ios/A5UF4ZQPI2UZQ3YG4E4FGDD45VG37A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJZGE2DIOBUHA22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y) and [Android](https://github.com/notifications/mobile/android/A5UF4ZWCQKL4YIZQMLRHD6L45VG37A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJZGE2DIOBUHA22M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI). Download it today!
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
… scheduler to download large cutouts
…mpting to reach it at the same time with same creds
Profiling memory usageI did a lot of memory profiling for
I think I have identified a key bottleneck - system
Memory usage conclusions
Other issues (support for Python 3.10)I also fixed issues flagged by the CI, now the tests pass (see here except on Python 3.10. Python 3.10 doesn't work because we need Zarr-3, and 3.10 only supports Zarr-2. I couldy hack around this, but I think we should either:
Would dropping 3.10 be OK with you @fneum ? It'll reach end-of-life in October 2026 anyway |
|
I updated the branch to pass the new And one thing that I forgot to mention above - this branch introduces a new secret to the test CI ( |
|
Yes, dropping Python 3.10 is fine (we did this in PyPSA already). I'll add the earth data hub API key now. |
|
Awesome. I see there are still some issues with the CI tests (they pass, but ERA5 and ERA5EDH are being skipped in tests for this PR). I will debug those next week.
Is there anything else you need to be able to merge this @fneum?
|
maurerle
left a comment
There was a problem hiding this comment.
did take a look on this as well (just code though, did not try it). Sounds like a good alternative! :)
The history of this PR should be squashed or cleaned up though.
|
|
||
| if TYPE_CHECKING: | ||
| from typing import TypedDict | ||
| from typing import NotRequired, TypedDict |
There was a problem hiding this comment.
I don't have anything against dropping 3.10 support, but I guess that 3.10 would work without this change?
Either remove typing_extensions from pyproject.toml as well, or leave this change as before (and remove python 3.10 in a separate PR)
There was a problem hiding this comment.
this PR needs Python 3.11+ to work because era5-edh relies on Zarr v3's ObjectStore, which is not available for Python 3.10 AFAIK. I could create a separate PR for 3.10->3.11 if you'd like that, but for now I just removed typing_extensions from dependencies. Does this resolve your comment?
…ver/credential issue
Co-authored-by: Florian Maurer <fmaurer@disroot.org>
|
thanks for the review @maurerle ! I checked out the CI, and the reason that EDH tests were being skipped is that CI on PRs doesn't have access to secrets. CDS tests are not skipped, but only on Ubuntu, because there are the nightly built cached cutouts for those. Regarding commit history, I totally agree it should be cleaned up, but I thought you'd just squash merge it @maurerle @fneum? If you'd prefer that I squash this branch, I'd be happy to do that of course |
|
We just squash at the end. |
…out in CI, add a warning in the CI test job 9x runners simultaneously hammer EDH with the same API keys, which results in 403s. for now dealt with via long timeouts, final fix would be a two-step test process, separate creds, or some other form of rate limiting
|
Then I think it's ready for merge - CI runs all tests and passes on my fork. The last remaining issue is the Python version bump - would you prefer a separate PR for that, or can we do it here? |
maurerle
left a comment
There was a problem hiding this comment.
I think it is fine here.
I do not have commit rights, but I'd approve.



Closes #495
Changes proposed in this Pull Request
Currently the ERA5 dataset is downloaded from CDS. This requires authentication and users often get stuck in a processing queue for hours.
This PR adds support for downloading ERA5 from a mirror hosted at NCAR via OPeNDAP. This mirror requires no authentication and there is no queue.
The modification is implemented as a new dataset module called
era5-ncar, which exposes the same API as the currentera5.pymodule. All the user needs to do is change one line when creating the cutout. Code remains fully backwards-compatible.Comparison of
era5vsera5-ncarThe NCAR mirror is stored as NetCDF files at the default 0.25/0.25 deg. resolution used by CDS. This has implications for performance and accuracy.
Performance
Tested on a Germany-sized cutout, 6 months of data, downloaded at the default grid size (CDS files served from CDS server cache, no queuing):
As you can see, we need to download slightly more data from NCAR and do more local processing, but the extra time is typically offset by the CDS queue time (over an hour when this cutout was first requested). Coarser/larger cutouts will benefit CDS, while smaller cutouts will have an even larger speedup on NCAR.
Accuracy
Results on the default grid (and its multiples) are very close, within float32 precision. Results on other grids are slightly off, as we cannot reproduce the exact interpolation logic used by CDS. Details of the interpolation errors are explained in the example notebook
examples/comparing_era5_sources_cds_vs_ncar.ipynbWhen to use which source
I included the following line in the documentation:
Communication with UCAR
I asked UCAR, who administer this dataset for NCAR, whether they were OK with the OPeNDAP access. The response was positive. If we experience rate limiting on the server side, we may need to limit the number of simultaneous connections further (I capped it at 8).
LLM use disclosure
I used LLMs to:
I manually wrote all the documentation and most of the docstrings. I hand-checked every line of code in this PR.
Remaining tests
I'd appreciate if someone could test the module on their machine on a large download. I've been test-running it for a week on my own setup, and it was stable (not a single failed download). However, there may still be hidden networking bugs.
Other ERA5 sources
I investigated other sources for ERA5. This is, to my knowledge, the only one fulfills the following criteria:
atliteThe ARCO datasets stored by Google, Microsoft and Amazon seem to be chunked along the time dimension only, so one always has to download a whole world's worth of data.
Earthmover stores era5 on s3 in Zarr, chunked in yearly, 12x12 spatial chunks, but they only do surface variables.
Checklist
doc.Newly introduced dependencies are added toI added dependencies toenvironment.yaml,environment_docs.yamlandsetup.py(if applicable).pyproject.toml, I don't see anenvironment.yamldoc/release_notes.rstof the upcoming release is included.