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

Add eva main function and add eva.fit_gev fitstart options #79

Merged
merged 4 commits into from
Oct 23, 2024

Conversation

stellema
Copy link
Member

@stellema stellema commented Oct 11, 2024

  • Added main() function to eva.py so that GEV parameters can be saved in a workflow.
    • Added eva.py to setup.py entry_points, so unseen will have to be reinstalled before it will work (e.g., run pip install --no-deps -e .)
  • Added lmoments3 to ci/environment.yml
  • Updates to eva.fit_gev:
    • Renamed keywords to more descriptive names:
      • test_fit_goodness => assert_good_fit
      • test_relative_fit => pick_best_model
    • Added keyword fitstart that replaces generate_estimates and user_estimates. The new keyword can be a string or a list of initial estimates.
    • Added a bunch of options that utilise the fit or fit start methods from scipy and xclim and one that uses the L-moments method. I've found the linear moments estimate LMM is very good, but kept scipy_fitstart as the default because it reproduces the original scipy.stats.genextreme.fit method. The scipy_fitstart and scipy difference is a bit confusing because using 'scipy' will basically fit the parameters twice.
    • The functionality of generate_estimates can be reproduced using scipy_subset or retry_fit.
    • There is now a specific option retry_fit, which retries the fit using a different initial estimate - generated by running the same fitstart method with data[::2]. If the retry attempt is not better than the first estimate (based on the log-likelihood), then the original parameters are returned. We could retry the fit using different fitstart methods, but I don't think this is a good idea because it could impact reproducibility.
  • The eva tests have been updated for consistency and now utilise pytest fixtures.
  • Updated fit_gev output so that is more consistent with xclim.indices.stats.fit, including renaming theta => dparams and adding attributes tofit_gev output.
  • Updated check_gev_fit: The goodness of fit test is now based on the one-sample Kolmogorov-Smirnov or Cramér-von Mises test.
  • Deleted fit_stationary_gev
  • Added gev_confidence_interval - it is a vectorised version of the CI bootstrapping methods used in the eva plots (return periods or return levels). It still needs some work - I can finish it if it is needed.

unseen/eva.py Outdated Show resolved Hide resolved
stellema and others added 2 commits October 21, 2024 16:33
Co-authored-by: Damien Irving <irving.damien@gmail.com>
@stellema
Copy link
Member Author

I also added a copy of the ari_to_aep and aep_to_ari functions from https://github.com/climate-innovation-hub/frequency-analysis/blob/master/eva.py.

@stellema stellema merged commit 1afb9d8 into AusClimateService:master Oct 23, 2024
4 checks passed
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.

2 participants