Skip to content
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

Return period calculation based on a Gumbel-distribution fit to sample data #29

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

chpolste
Copy link
Member

@chpolste chpolste commented Jan 6, 2025

Adds distribution and extreme_values submodules to earthkit.plots.stats for computing recurrence statistics based on a Gumbel distribution fit to a data sample. Can be used, e.g., to compute return periods of extreme precipitation of flooding events in a given time interval.

The implementation is class-based, since the fitted distribution parameters need to be stored for subsequent invocations of the statistics calculations. The interface for the distributions so far matches that of scipy's rv_continuous and the distributions are only reimplemented here to allow for fitting of multiple distributions in a vectorised fashion along a given axis (scipy only fits to 1D samples).

The Gumbel fit makes use of scipy's lmoment function, which was only added in the latest 1.15 release, so a vectorized implementation by @corentincarton is included for environments with older versions of scipy. The included implementation only works along the first array axis, but that covers the common use-case of fitting a distribution to a (time)series of fields. The scipy implementation supports application along any axis and is therefore preferred, despite being a little slower.

chpolste and others added 6 commits December 19, 2024 18:38
The plan is to exclusively rely on scipy for the functionality in the future,
but for now to provide a substitute that doesn't rely on a version of scipy
that is still under development (as of Dec 2024).

Co-authored-by: Christopher Polster <[email protected]>
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.71%. Comparing base (756dcf2) to head (2dbcdbb).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #29      +/-   ##
===========================================
+ Coverage    98.68%   98.71%   +0.03%     
===========================================
  Files            8        8              
  Lines          684      703      +19     
  Branches        26       26              
===========================================
+ Hits           675      694      +19     
  Misses           7        7              
  Partials         2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chpolste chpolste marked this pull request as draft January 22, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants