-
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
Added new operators for statistics preprocesor (e.g., percentile
) and allowed arbitrary kwargs
#2191
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2191 +/- ##
==========================================
+ Coverage 93.29% 93.47% +0.18%
==========================================
Files 238 238
Lines 12848 12927 +79
==========================================
+ Hits 11986 12084 +98
+ Misses 862 843 -19
|
this looks like a superb PR and feature addons, I'll go through it in detail tomorrow @schlunma - 20 files with ~+1,700 lines deserve proper love 😁 |
Nice work @schlunma! I'd like to propose a slightly different API though. It is common practice to pass through keyword arguments using just the def area_statistics(
cube: Cube,
operator: str,
operator_kwargs: Optional[dict] = None,
) -> Cube: to def area_statistics(
cube: Cube,
operator: str,
**kwargs: Any,
) -> Cube: and the recipe usage to: preprocessors:
monthly_percentiles:
climate_statistics:
period: monthly
operator: percentile
percent: 95.0 For multiple statistics in the same preprocessor function, it would be easier to read if the operators were grouped with their arguments, e.g. preprocessors:
mm_stats:
multi_model_statistics:
span: overlap
statistics:
- operator: percentile
percent: 5
- operator: median
- operator: percentile
percent: 95 |
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.
first batch of review (just before rolling window)
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.
couple more minor changes requested, bud. I sped through the tests changes since I know foull well you write very good tests 👍
Co-authored-by: Valeriu Predoi <[email protected]>
Co-authored-by: Valeriu Predoi <[email protected]>
Co-authored-by: Valeriu Predoi <[email protected]>
OK I finished the review - a very solid PR - I guess the fundamental question here is if we want to get this closer to iris - the infrastructure introduced in here ties us inextricably with the way iris does stats - I can see both pros and (a few big) cons, but since we're not even contemplating a switch from iris, it's OK. Many thanks, Manu! 🍺 |
Co-authored-by: Valeriu Predoi <[email protected]>
Co-authored-by: Valeriu Predoi <[email protected]>
Co-authored-by: Valeriu Predoi <[email protected]>
Co-authored-by: Valeriu Predoi <[email protected]>
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.
good work, Manu! If you could please God Flake, then this is ready to go IMO - maybe @zklaus can merge after flake's fixed 🍺
Description
This PR unifies all statistics preprocessors. Now, all statistics preprocessors support the same operators and have a common documentation. In additon, arbitrary keyword arguments for the statistical operation can be directly given to the preprocessor.
Corresponding PR in ESMValTool: ESMValGroup/ESMValTool#3351
Examples:
Deprecations
Prior to this PR, the only preprocessors that supported percentiles were
multi_model_statistics
andensemble_statistics
. The syntax was for examplestatistics: [p50.0]
, which can now be specified by usingstatistics: {operator: percentile, percent: 50.0}]
. The following example shows how to modify existing recipes:Old:
New:
In addition, the usage of the operator
std
has been deprecated in favor ofstd_dev
:Old:
New:
The old syntax will be deprecated with version 2.10 and removed with version 2.12.
Closes #1617
Closes #1249
Closes #1851
Closes #2223
Link to documentation: https://esmvaltool--2191.org.readthedocs.build/projects/ESMValCore/en/2191/recipe/preprocessor.html#statistical-preprocessors
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 compatibleOne deprecation, see aboveTo help with the number pull requests: