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

Spei, proper use of loc parameter in scipy dists #1653

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Breaking changes
* `black` formatting style has been updated to the 2024 stable conventions. `isort` has been added to the `dev` installation recipe. (:pull:`1626`).
* The indice and indicator for ``winter_storm`` has been removed (deprecated since `xclim` v0.46.0 in favour of ``snd_storm_days``). (:pull:`1565`).
* `xclim` has dropped support for `scipy` version below v1.9.0 and `numpy` versions below v1.20.0. (:pull:`1565`).
* For generic function ``select_resample_op`` and ``core.units.to_agg_units``, operation "sum" will now return the same units as the input, and not implicitly be translated to an "integral". (:issue:`1645`, :pull:`1649`).
* `lmoments3` was removed as a dependency of `xclim` due to incompatible licensing (GPLv3 vs `xclim`'s Apache 2.0). Depending on the outcome of efforts to modify the licensing of `lmoments3`, this change may eventually be reverted. See `Ouranosinc/lmoments3#12 <https://github.com/Ouranosinc/lmoments3/issues/12>`_. See also the "frequency analysis" notebook for an example on how to continue using the probability weighted moments method for fitting distributions. (:issue:`1620`, :pull:`1644`).
* Argument `offset` is removed from ``xclim.indices.standardized_precipitation_evapotranspiration_index``. This will slightly change results when using SPEI with default values (:issue:`1477` :pull:`1653`).
coxipi marked this conversation as resolved.
Show resolved Hide resolved

Bug fixes
Expand Down
11 changes: 8 additions & 3 deletions xclim/indices/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ def standardized_index(
da: xr.DataArray,
freq: str | None,
window: int,
dist: str,
dist: str | scipy.stats.rv_continuous | None,
method: str,
cal_start: DateStr | None,
cal_end: DateStr | None,
Expand All @@ -785,6 +785,11 @@ def standardized_index(
) -> xr.DataArray:
r"""Standardized Index (SI).

This computes standardized indices which measure the deviation of variables in the dataset compared
to a reference distribution. The reference is a statistical distribution computed with fitting parameters `params`
over a given calibration period of the dataset. Those fitting parameters are obtained with
``xclim.standardized_index_fit_params``.

Parameters
----------
da : xarray.DataArray
Expand All @@ -795,9 +800,9 @@ def standardized_index(
window : int
Averaging window length relative to the resampling frequency. For example, if `freq="MS"`,
i.e. a monthly resampling, the window is an integer number of months.
dist : {"gamma", "fisk"}
dist : str or rv_continuous
Name of the univariate distribution. (see :py:mod:`scipy.stats`).
method : {'APP', 'ML'}
method : str
Name of the fitting method, such as `ML` (maximum likelihood), `APP` (approximate). The approximate method
uses a deterministic function that doesn't involve any optimization.
cal_start : DateStr, optional
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.