-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add function for accessing ERA5 #2573
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
base: main
Are you sure you want to change the base?
Conversation
Discussion on available parameter though the ERA5 time series API can be found here. |
Right now you can't pass pvlib variable names as strings: This doesn't work: variables = 'ghi'
data, meta = pvlib.iotools.get_era5(
latitude, longitude, start, end, variables, api_key, timeout=60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a phenomenal contribution 🥳
I do suggest renaming the module to "era5" instead of "ecmwf" as I foresee we might add other datasets such as the IFS forecasts, where it would be preferred to have the code in different files.
start = pd.to_datetime(start).strftime("%Y-%m-%d") | ||
end = pd.to_datetime(end).strftime("%Y-%m-%d") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be localized to UTC first?
'reducing the request size.' | ||
) | ||
|
||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could consider reducing this to 0.5
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
def same(x): | ||
return x | ||
|
||
|
||
def k_to_c(temp_k): | ||
return temp_k - 273.15 | ||
|
||
|
||
def j_to_w(j): | ||
return j / 3600 | ||
|
||
|
||
def m_to_cm(m): | ||
return m / 100 | ||
|
||
|
||
UNITS = { | ||
'u100': same, | ||
'v100': same, | ||
'u10': same, | ||
'v10': same, | ||
'd2m': k_to_c, | ||
't2m': k_to_c, | ||
'msl': same, | ||
'sst': k_to_c, | ||
'skt': k_to_c, | ||
'sp': same, | ||
'ssrd': j_to_w, | ||
'strd': j_to_w, | ||
'tp': m_to_cm, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefix all of this with _
to discourage others from using it, even within pvlib.
docs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.As described in #2420, the ECMWF CDS now provides a simple and fast API for retrieving timeseries ERA5 data. No need for any new dependencies (not even
cdsapi
), although the nature of the API requires a sequence of requests, and one poll-and-wait step, to complete.