Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--Please ensure the PR fulfills the following requirements! --> <!-- If this is your first PR, make sure to add your details to the AUTHORS.rst! --> ### Pull Request Checklist: - [x] This PR addresses an already opened issue (for bug fixes / features) - This PR fixes #1270 and fixes #1416 and fixes #1474 - [x] Tests for the changes have been added (for bug fixes / features) - [x] (If applicable) Documentation has been added / updated (for bug fixes / features) - [x] HISTORY.rst has been updated (with summary of main changes) - [x] Link to issue (:issue:`number`) and pull request (:pull:`number`) has been added ### What kind of change does this PR introduce? * Make SPI/SPEI faster * fit params are now modular, can be computed before computing SPI/SPEI. This allows more options to segment computations and allow to obtain the fitting params if troubleshooting is needed. * time indexing now possible * `dist_method` now avoids `vectorize=True` in its `xr.apply_ufunc`. This is the main improvement in SPI/SPEI. * Better document the limits of usage of standardized indices. Now standardized indices are capped at extreme values ±8.21. The upper bound is a limit resulting of the use of float64. ### Does this PR introduce a breaking change? Yes. * `pr_cal` or `wb_cal` will not be input options in the future: > Inputing `pr_cal` will be deprecated in xclim==0.46.0. If `pr_cal` is a subset of `pr`, then instead of: `standardized_precipitation_index(pr=pr,pr_cal=pr.sel(time=slice(t0,t1)),...)`, one can call: `standardized_precipitation_index(pr=pr,cal_range=(t0,t1),...)`. If for some reason `pr_cal` is not a subset of `pr`, then the following approach will still be possible: `params = standardized_index_fit_params(da=pr_cal, freq=freq, window=window, dist=dist, method=method)`. `spi = standardized_precipitation_index(pr=pr, params=params)`. This approach can be used in both scenarios to break up the computations in two, i.e. get params, then compute standardized indice I could revert this breaking change if we prefer. This was a first attempt to make the computation faster, but the improvements are now independent of this change. We could also keep the modular structure for params, but revert to `pr_cal` instead of `cal_range`. It's a bit less efficient when `pr_cal` is simply a subset of `pr`, because you end up doing resampling/rolling two times on the calibration range for nothing. When first computing `params`, then obtaining `spi` in two steps, then it makes no difference ### Other information:
- Loading branch information