-
Notifications
You must be signed in to change notification settings - Fork 38
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
Use smarter (units-aware) weights #2139
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2139 +/- ##
==========================================
+ Coverage 93.10% 93.14% +0.03%
==========================================
Files 237 237
Lines 12826 12828 +2
==========================================
+ Hits 11942 11948 +6
+ Misses 884 880 -4
|
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 very nice PR and introduced functionality, very cool, @schlunma 🍺 Proper testing too 🎖️ (I don't see any reason) but do we expect any changes in results for recipes that use this set of preprocessors? Also, were there any distinct changes in performance you might have noticed? Cheers!
PS: I meant actual result changes, not if the recipes just run. I guess we could find that out at v2.10 release time - which reminds me, maybe we should curate a list of PRs that may lead to changes in results and have that at hand when testing for a release |
Good point!
Old version: New version: |
awesome you doing testing, Manu! About those K -> m.K units change - it's a bit fishy (excuse the pun) at first glance since the numbers are the same, only units changed? You wanna do more testing before we merge this? 🍺 |
No, nothing fishy at all, that's exactly what was to be expected: In this preprocessor ( This has also been expected by the author of ESMValCore/esmvalcore/preprocessor/_volume.py Lines 256 to 258 in 4c2578b
|
excellent! I'll take my 🐟 back then 😁 |
Description
Since version 3.5.0, iris allows the usage of cell measures (and a lot of other objects) as weights. This has the great benefit that units in statistical calculations are handled properly, e.g., for an area-weighted sum, resulting units are multiplied by
m2
.In addition, this PR adds type hints for all functions of the affected modules.
Closes #1613
Closes #708
Link to documentation:
Backwards-compatibility
The changes of these PR are NOT backwards-compatible. Since this PR fixes calculations that have been scientifically wrong in previous versions, no deprecation cycle is used. The following preprocessors are affected:
area_statistics
operator='sum'
kg m-2 s-1
m2
, e.g.,kg s-1
climate_statistics
period='full'
andoperator='sum'
kg m-2 s-1
kg m-2
axis_statistics
operator='sum'
kg m-2 s-1
kg m-1 s-1
depth_integration
kg m-2 s-1
kg m-1 s-1
In addition, there has been a bug in
climate_statistics
, which lead to a wrong calculation of weighted sums if the weights are equal for all time points. These are the relevant lines of code:ESMValCore/esmvalcore/preprocessor/_time.py
Lines 740 to 746 in 1abaf8e
While this simplification is correct for calculating means and RMSE, the weighted sum actually differs in both cases. Thus, we need to always consider the weights here, regardless if they are equal or not. This PR fixes that.
I will test all affected recipes and open corresponding PR in ESMValTool if any changes are necessary.EDIT: I tested all affected recipes; they run fine with minimal changes (ESMValGroup/ESMValTool#3300).
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.
Changes are backward compatible(see note above)All checks below this pull request were successful(I thinkassert
in production code is fine to make other developers aware of something; this is not intended to catch errors by users)To help with the number pull requests: