-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
BUG: forecast and reanalysis models - update ECMWF weather model variables dictionary #736
Conversation
…o pr/WilliamArmst/735
I'm not sure why #735 is in this PR, I thought I updated everything but ig I don't know git as well as I thought I did. |
@WilliamArmst PR looks great. Thanks for helping us again today. I am afraid the code corrections you have made will make the code stop working for old data, that's why we see the tests failing in the CI. I think we should make a fallback capture of these variables: first try to get "time", if not possible, use "time" instead, if not possible again, then just give up. This PR should solves #718 PR. Copernicus Data Store has introduced a breaking change in their files but we - unfortunately - did not receive any heads up as final users. |
Ah ok, I'll see if I can do that. |
@WilliamArmst there are multiple ways we could solve this problem. Some options I thought:
def get_first_matching_key_value(dictionary, keys: list[str]):
"""Given a dictionary and a list of candidate keys, return the first key and
value that are in the dictionary.
"""
for key in keys:
if key in dictionary:
return key, dictionary[key]
raise KeyError(f"None of the keys {keys} are in the dictionary.") Anyways, I'm open to other suggestions too. Btw it would be really nice if you could add a light (less than a few Megabytes) and new .nc file so we could create a new testing case or this new file structure. Tests on CI must be working before we merge. Let me know if you need any other help! |
I have no clue how these tests work, but just from loading the file with all of the correct position and time parameters at |
Thx for the fast response, I'm trying to debug it locally right now. What is the size of your file, do you mind sharing it with us so we can create a new test case to ensure code works for both new and old .nc data? If it is more than 10 Mb, nevermind. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #736 +/- ##
===========================================
+ Coverage 75.96% 75.97% +0.01%
===========================================
Files 95 95
Lines 11022 11027 +5
===========================================
+ Hits 8373 8378 +5
Misses 2649 2649 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Tests are passing both locally and on CI, including slow tests. Before merging, I would just add a new Great work, @WilliamArmst !!! |
The file I've been using: data_stream-oper.zip (19.21 MB). 2024, March & April, 18th - 24th, 11:00 & 12:00. For FAR in California and Tripoli Gerlach in Black Rock Desert New file that should be able to be used with |
Thank you! let me try to add a new test using your file, just a sec. |
Well, I tried with the
|
|
…iple environment files
Actually, it worked as a charm. |
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.
Great work, nice fix!
Thx for all of your help with this one and #735, really appreciate it. |
Pull request type
Bugfix
Checklist
black rocketpy/ tests/
) has passed locallypytest tests -m slow --runslow
) have passed locallyCHANGELOG.md
has been updated (if relevant)Current behavior
"time": "time"
and"level": "level"
were throwing key errors when trying to read those values from the dictionary.New behavior
Behaves as expected
Breaking change
Additional information
You can verify this by running the following script with any ECMWF weather model (my file: ECMWF-WeatherModel.zip).
the output should be:
data.variables.keys(): dict_keys(['number', 'valid_time', 'pressure_level', 'latitude', 'longitude', 'expver', 'z', 't', 'u', 'v'])