-
Notifications
You must be signed in to change notification settings - Fork 91
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
Specifying vertical levels rather than height levels #2063
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2063 +/- ##
==========================================
+ Coverage 98.39% 98.41% +0.01%
==========================================
Files 124 135 +11
Lines 12212 13304 +1092
==========================================
+ Hits 12016 13093 +1077
- Misses 196 211 +15 ☔ View full report in Codecov by Sentry. |
0ff1f90
to
d7d8142
Compare
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 have reviewed your code and highlight only very minor typo corrections. I will put the ticket into second review.
The ticket mentions adding pressure/height flags to the synthetic data but I think this has already been done. #1993 |
After reviewing the work, I think that this hasn't quite been done yet. Ben has mentioned that there is already a pressure flag to change from height to pressure which is what you've noticed too, and this was fine back when all the levels were called height. |
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'm a little confused how the acceptance tests are passing at the moment. This PR updates the kgo names so they shouldn't be able to find them - these fail for me locally, plus some extra ones relating to cell methods from this PR: #2062
I think you need to update the names of any KGO files that you have changed in the acceptance tests. These need another PR in the imrpover_test_data repository
@@ -428,54 +433,54 @@ def test_error_unmatched_realizations(self): | |||
self.data_3d, realizations=np.arange(realizations_len) | |||
) | |||
|
|||
def test_error_unmatched_height_levels(self): | |||
def test_error_unmatched_vertical_levels(self): | |||
"""Test error is raised if the heights provided do not match the |
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 think this should docstring be changed to "levels" rather than heights
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 still needs changing
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 test actually needs to be duplicated. One named height levels, one named pressure levels. They are testing explicitly as the coordinate name is set in the set up function. So this test should be test_error_unmatched_height_levels
as it was originally, with the height=True
keyword argument provided. The copy should be called test_error_unmatched_pressure_levels
, with pressure=True
, and the msg
tested will be modified to say `"Cannot generate {} pressures with data of length {}".
pressure: | ||
Flag to indicate whether the height levels are specified as pressure, in Pa. | ||
Flag to indicate whether the vertical levels are specified as pressure, in Pa. |
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 add another flag here for "height" and subsequent places that need it.
The kgo names have been changed and I have added a height flag as requested |
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.
Just a few more changes needed here and some minor docstring additions.
We discussed defaulting the new height flag to True but looking further into the code, this is already happening so I suggest we change it to False.
@@ -420,6 +421,7 @@ def set_up_spot_variable_cube( | |||
realizations: Optional[Union[List[float], ndarray]] = None, | |||
vertical_levels: Optional[Union[List[float], ndarray]] = None, | |||
pressure: bool = False, | |||
height: bool = True, |
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.
Need to add the height flag to this docstring below (line 468)
@@ -420,6 +421,7 @@ def set_up_spot_variable_cube( | |||
realizations: Optional[Union[List[float], ndarray]] = None, | |||
vertical_levels: Optional[Union[List[float], ndarray]] = None, | |||
pressure: bool = False, | |||
height: bool = True, |
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.
Have we considered what happens if pressure is set to True and the height flag is left unset? It's default is True so we would have 2 True coords which will likely fail. For this to work you'd probably have to write a bit of code to handle it.
On line 370 which is the function that uses the pressure and height flags, there is a bit of code that says if pressure is set (i.e. if pressure=True) then set pressure, else use height. For this reason it might be worth just setting the default flag for height to False as it's already defaulting to height within the code.
@@ -539,6 +542,7 @@ def set_up_variable_cube( | |||
realizations: Optional[Union[List[float], ndarray]] = None, | |||
vertical_levels: Optional[Union[List[float], ndarray]] = None, | |||
pressure: bool = False, | |||
height: bool = True, |
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.
As above, please add height to the docstring below the pressure flag. And consider changing height default to False.
@@ -428,54 +433,54 @@ def test_error_unmatched_realizations(self): | |||
self.data_3d, realizations=np.arange(realizations_len) | |||
) | |||
|
|||
def test_error_unmatched_height_levels(self): | |||
def test_error_unmatched_vertical_levels(self): | |||
"""Test error is raised if the heights provided do not match the |
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 still needs changing
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.
One last thing.
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.
Thanks, looks good to me now, passing to @bayliffe for a quick glance.
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.
Thanks for tackling this Phoebe. I've put an upsetting number of comments on this, but that's largely to try and help make it clear what I want, rather than leaving you one comment and saying "repeat everywhere".
We should have a chat about this to ensure you understand the reasoning for what I've requested. Give me a call once you've read the review.
465514b
to
01296aa
Compare
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.
Many fewer comments this time. Thanks for all the changes, nearly there with just a few to go.
improver_tests/utilities/cube_manipulation/test_maximum_in_height.py
Outdated
Show resolved
Hide resolved
improver_tests/utilities/cube_manipulation/test_maximum_in_height.py
Outdated
Show resolved
Hide resolved
improver_tests/wind_calculations/wind_components/test_ResolveWindComponents.py
Outdated
Show resolved
Hide resolved
Thanks for the comments Ben, I have made the changes and added the tests required. |
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.
The tiniest comment which I've largely included to demonstrate how you can reset a file from an older commit. If you make that change I will approve and merge all of this.
Thanks for all the work.
@@ -791,7 +791,7 @@ def height_of_maximum( | |||
A cube of the maximum value over the height coordinate. | |||
find_lowest: | |||
If true then the lowest maximum height will be found (for cases where | |||
there are two heights with the maximum vertical velocity.) Otherwise the highest | |||
there are two heights with the maximum height velocity.) Otherwise the highest |
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.
We've nearly left this file unchanged. Last thing is that whilst we are talking about height levels, the velocity discussed is the velocity in the z-dimension, i.e. the vertical velocity. If you can put this back as shown here then this file will be exactly as it was before.
there are two heights with the maximum height velocity.) Otherwise the highest | |
there are two heights with the maximum vertical velocity.) Otherwise the highest |
If in future you want to completely undo the changes to a file, the easiest way is to go and get the file back from a commit before you made any changes. You can do this as follows.
- Use
git log
to have a look at the commit history of your branch. - Copy the hash (the long number/letter string) that identifies the commit you want.
- Checkout the file that you want to reset from that commit. In this case, assuming your in the head directory (
~/improver
) it would be this:
git checkout 347a8a437c1284e04d01253828cac48ce11487e4 -- improver/utilities/cube_manipulation.py
This works fine if you've got a nice linear commit history, or even if you've merged in master, as long as no one else is editing the file you're interested in.
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.
Thanks Ben, that is useful to know for future! I have made the final change.
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.
🎉 Thanks for all the work on this, I think we have made the setting of vertical levels in our test data much more explicit now.
Description:
I have changed all variables named height_levels to vertical_level. This is to make the setting of vertical levels more transparent with the previous height_level referring to height, or pressure levels if needed (using a boolean pressure option). The vertical_level argument is therefore clearer to use.
Testing: