-
Notifications
You must be signed in to change notification settings - Fork 300
Added zonal (i.e. longitudinal) mean support to LBPROC save rule #1975
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
Conversation
|
I would be inclined to create a new test class in iris/tests/integration/test_pp.py called I would also be inclined to write a new function in
This function can then handle latitude, longitude, grid_longitude and grid_latitude etc. Not handling these other cases might be seen as deceptive/unexpected behaviour to the end user. Can an iris developer confirm what actions will be required to get this through a review? Cheers |
|
the handling of the pp_save_rules is planned to change in teh near future, so I would be inclined to keep the code in the save rules, and not add a helper function into the rules module @pp-mo was working in this space, and may care to comment i agree with @cpelley that a new test class in iris/tests/integration/test_pp.py would be sensible; we would certainly appreciate a test for the new behaviour |
90c8002 to
cc6f7dd
Compare
|
I've added tests that cater to the specific cases we're interested in (time mean, zonal mean, time & zonal mean). There's two failing tests on an area of code that I don't think these changes touch - TimedOutExceptions on AreaWeightedRegrid tests i.e. similar issues to #1986. Any ideas? |
Those can be safely ignored in this case. These tests fail intermittently due to timeouts, I believe @cpelley is on the case already so this shouldn't be a problem for too much longer. |
To clarify, if you haven't seen this before:
|
|
Don't you need to be a project dev to restart builds? |
I'm agreed with that in this case. As for latitude/grid_latitude, I've not heard of that -- would you call it a "meridional mean" ? -- I don't think there is an LBPROC bit encoding for such a thing. |
Sorry, I didn't know that. |
23c21df to
ae014e3
Compare
I've added grid_longitude to the pp_save_rules - I have not added a separate test for this, it seems to me as though it's a bit redundant with the existing tests. If you'd prefer an additional test, I'll certainly add one.
If you could re-do your magic on the timing out tests, I'd be grateful. |
|
I hadn't noticed that there were conflicts again on this one - is the procedure that I keep fixing this each time there's a conflict, or do I wait and resolve the conflicts after it's reviewed? Given how close the conflicting change is to this one, it's a shame the two fixes weren't combined. |
Ordinarily rebasing first is preferable otherwise the reviewer is not reviewing the changes that are going onto trunk, however, before going to the effort of rebasing again - I'm happy to review this myself but were still going to need someone with the big green button to merge once I give it the thumbs up. Any takers? |
ae014e3 to
ea92201
Compare
|
If someone could wave a magic wand at the timing out test, I'd be grateful. |
|
@hdyson Done 😉 |
| units=Unit('days since 0001-01-01 00:00:00', | ||
| calendar='gregorian'), | ||
| points=np.arange(2),), | ||
| 0) |
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.
Formatting on this makes it difficult to read, instead:
def create_cube(self):
cube = Cube(np.zeros((2, 3, 4)))
tunit = Unit('days since 0001-01-01 00:00:00', calendar='gregorian')
tcoord = DimCoord(np.arange(2), standard_name='time', units=tunit)
cube.add_dim_coord(tcoord, 0)
...|
There's another timing out test, so if someone could retry that test, that'd be great. |
| cube = self.create_cube() | ||
| cube.cell_methods = ( | ||
| iris.coords.CellMethod(method='mean', coords='time'), | ||
| ) |
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.
@hdyson
A minor point, but it's probably safer (from a maintenance point of view) to use the add_cell_method method ...
cm = CellMethod(method='mean', coords='time')
cube.add_cell_method(cm)Note that, CellMethod is imported directly from iris.coords ... so there's no need to specify the full namespace i.e. iris.coords.CellMethod
If you agree, then rinse-and-repeat for all below ... ?
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 @bjlittle - will do.
|
@hdyson I'm 👍 for this PR, once you've serviced some minor comments. |
|
|
||
| def create_cube(self): | ||
| cube = Cube(np.zeros((2, 3, 4))) | ||
| tunit = Unit('days since 0001-01-01 00:00:00', calendar='gregorian') |
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.
@hdyson
Just noticed this line (after a double-take) ... did you know that you can also do this Unit('days since epoch') ?
Which is kinda handy 😉
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.
@bjlittle Nope, that's a new one on me - but one I'll certainly recycle. Thanks!
|
@hdyson |
|
@hdyson Push up your PEP8 fix and we'll get this merged 😉 |
|
@bjlittle Apologies - I'd missed the '-a' when making the commit yesterday, so didn't even commit the fix, let alone push it. Is something up with travis? It seems to be having problems running the tests. |
|
@hdyson No worries. I'll try restarting Travis, although it seems to be a systemic problem (at their end?) |
|
@hdyson Hmmm seems like some dependencies may have moved under our feet. Not your doing. I'll need to investigate further, hang tight. |
|
@hdyson I'll try to recreate the problem locally so that I can identify the dependency issue and generate a fix. |
45d2b92 to
533ab6f
Compare
|
@bjlittle Thanks, that solved it. |
|
@hdyson Finally, a clean run through travis, phew! I'm 👍 for this PR so could you please squash your commits into one and I'll happily merge! |
533ab6f to
e9be1f3
Compare
|
@bjlittle You may want to double check the squashed commit - it's not something I've done before. Is it worth perhaps adding the procedure to the iris development workflow instructions? Thanks for all your help on this, everyone. |
|
@hdyson Your squashed commit looks good to me. Typically, if a PR contains many commits the reviewer can request that the author squashes their commits into one, as it makes the commit history on master that much less noisy. It's a normal practice, and a good skill to have, so congrats to you! As of today, we've just changed the settings on the iris repo to take advantage of a new GitHub feature that allows the reviewer to automatically squash and merge multiple commits into one new merge commit. This saves the whole reviewer and author ding dong, requesting the author to squash. So, looking forward this shouldn't be much of an issue. |
|
@hdyson - we have some documentaion on this in the developer's guide: http://scitools.org.uk/iris/docs/latest/developers_guide/gitwash/development_workflow.html#rewriting-commit-history. Even though we can squash on merge through the Github GUI, it is still worth understanding this aspect of git as it can be very helpful. |
|
@hdyson ... and we're over the line! Thanks! |
|
Thanks again everyone - much appreciated. @ajdawson Sorry, my mistake: I didn't make the mental connection between rewriting commit history and squashing commits, so I had the right page, but not the right understanding. Consequently, I didn't read that section in sufficient depth to spot where it talks about combining commits. |
This is a fix to correctly set the LBPROC upon saving as a pp file for zonal mean data. I have not included a test - if you can point me in the direction of where the tests should be for a pp_save_rules fix, I'd be grateful.
For a bit of context, the closest test I could find was here However, that is acting on zonal mean being set in a particular cube attribute rather than the cube cell methods. Simplifying that test down to just time and longitudinal mean yields this:
Which correctly reports 192. However, this snippet using cell methods instead reports 128 (i.e. just time mean):
This PR corrects that.