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
re-add correctly region-extracted cell measures and ancillary variables after extract_region
(for Changelog v2.10: authors: @valeriupredoi and @schlunma)
#2166
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2166 +/- ##
==========================================
+ Coverage 93.09% 93.10% +0.01%
==========================================
Files 237 237
Lines 12795 12816 +21
==========================================
+ Hits 11911 11932 +21
Misses 884 884
|
extract_region
extract_region
BTW @ledm I have a feeling that this bit you as well, in your continual battle with fx variables |
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 V for tackling this!
I have three main comments:
- I think you can simplify this by re-using
extract_region
on a cell measure/ancillary variable cube (see code suggestions). - Why do change the formatting of unrelated code? This has been formatted by
black
to look nice and shiny β - Could you maybe come up with a test that doesn't require adding a 1.1 MB file to the repo? We have plenty of example code that sets up a cube with a
CellMeasure
, e.g., here.
esmvalcore/preprocessor/_area.py
Outdated
@@ -467,15 +531,13 @@ def _process_ids(geometries, ids: list | dict | None) -> tuple: | |||
if len(ids) != 1: | |||
raise ValueError( | |||
f"If `ids` is given as dict, it needs exactly one entry, got " | |||
f"{ids}" | |||
) | |||
f"{ids}") |
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.
Why do you change the nice formatting by black
? π
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.
ah yes, totally my bad, I yapf-ed it, flake8 was getting on me nerves - but, we don't use black
so why the bother?
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.
if we use it for precommit stuff, I'd turn it off TBF, black
is black magic and introduces a lot of shtuff on its own
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.
my bad for yapf-ing it, should I restore the old formatting from unrelated sections?
Yeah, would be nice to change it back π
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.
Sounds good, bud, shall revert, in a jiffy
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.
will tacke the other suggestions that I got from you (git them in already, but need to make sure all's shipshape, fix the tests too) then will backtrack on this, π» with me for a few, bud
Cheers muchly, Manu! πΊ
I'm a bit afraid of unexpected behaviour knowing that
my bad for
Indeed, I can do that - I was lazy and knew this will be removed at some point in the future anyway π |
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
Co-authored-by: Manuel Schlund <32543114+schlunma@users.noreply.github.com>
with the latest changes when you try print the cube that's been changed you get this:
|
sorry @schlunma a few too many issues with your review suggestions (both at our end and iris - iris issue which I am not prepared to dive into at the moment, see #2166 (comment)); if you think we'd benefit enough from those changes, I suggest we merge this, then you can open a PR based off |
OK Manu, I have finished poslishing this:
I think we should do this: merge this to have correct functionality for extract_region, then you and me we can go back to the suggestions you made earlier in a follow up PR, unfortunately there are quite a few hitches (not least the iris one that we should look at) to be looked at here; we may as well not even do it all if we'll remove all this when iris fix their intersection, but at least I'd like to understand that print(cube) issue above. What say you? πΊ |
Also, as a note to all of us (I am guilty as charged myself) - everytime we suggest major code changes in a PR, in the form of suggested code via the browser/GitHub API, it would be a lot easier for the PR owner if the reviewer tested those changes by either running the test provided in the PR or by running a small independent test - this, to catch serious issues (not style, minor issues with the suggestions, those can be taken care of the PR owner, after including the suggested code changes). I think we should add this to our best practices PR reviewing docs π |
Well, if you use Also, in this form, this won't work (and will actually crash) for cell measures and ancillary variables that do not exactly span latitude/longitude. We need to take care of this properly here, otherwise it will break recipes. I am honestly confused why my suggestion didn't work. From the failing test on CircleCI it looks just like a |
sounds like a very good plan! Cheers, Manu! Can grab this branch, edit locally, and when things look OK to you just push changes here - that was my point in #2166 (comment) - reviewer's minimal testing is something we should start doing πΊ |
Tests pass fine for me locally (your test and my suggestion). Can I push it? π |
Pliz do πΊ |
That is now beautiful, and I don't see any more iris-related issues either - excellent work, Manu! π» |
extract_region
extract_region
(for Changelog v2.10: authors: @valeriupredoi and @schlunma)
@schlunma let's get this in plz so I can help @rebeccaherman1 with an install at DKRZ πΊ |
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 V! Can I be a bother and ask to to test this with the script mentioned here? I think we need to make sure that this properly works for cubes with time dimensions, too (If you like, you could also add a brief test of this π).
I will be in a seminar today with limitied availability, so I pre-approve this. Thanks for the fix!!
Very many thanks, Manu! Yes, that's what I've been using to test the PR (alas, slightly changed, but I'll test with the exact script that Rebecca had initially). Good point, I'll put a time dim in the integration test in this PR πΊ |
Boss level, Manu! Added time dim and check on final shapes, think the test is pretty bullet-proof now. Gonna merge and get @rebeccaherman1 an env done on DKRZ so she can get her data done up π |
Description
Cube intersection removes all cell measures and ancillary variables in certain conditions (for certain regions ie certain coordinates of the region box). This has been raised upstream, see below. NOTE for Codacy fails: I intentionally placed the imports inside block for ease of removal when we will eventually remove the workaround code block,
Closes #2162
Brought to my attention by @rebeccaherman1 in the above linked issue, which is, in fact a bug in iris - raised upstream in SciTools/iris#5413 - this is a workaround (temporary too) so that we have something outputting correct data before iris fix it at their end.
Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the π Technical or π§ͺ Scientific review.
To help with the number pull requests: