xhydro.frequency_analysis package

Frequency analysis module.

Submodules

xhydro.frequency_analysis.local module

Local frequency analysis functions and utilities.

xhydro.frequency_analysis.local.criteria(ds: Dataset, p: Dataset) Dataset[source]

Compute information criteria (AIC, BIC, AICC) from fitted distributions, using the log-likelihood.

Parameters

dsxr.Dataset

Dataset containing the yearly data that was fitted.

pxr.Dataset

Dataset containing the parameters of the fitted distributions. Must have a dimension dparams containing the parameter names and a dimension scipy_dist containing the distribution names.

Returns

xr.Dataset

Dataset containing the information criteria for the distributions.

xhydro.frequency_analysis.local.fit(ds, distributions: list[str] | None = None, min_years: int | None = None, method: str = 'ML') Dataset[source]

Fit multiple distributions to data.

Parameters

dsxr.Dataset

Dataset containing the data to fit. All variables will be fitted.

distributionslist of str, optional

List of distribution names as defined in scipy.stats. See https://docs.scipy.org/doc/scipy/reference/stats.html#continuous-distributions. Defaults to [“expon”, “gamma”, “genextreme”, “genpareto”, “gumbel_r”, “pearson3”, “weibull_min”].

min_yearsint, optional

Minimum number of years required for a distribution to be fitted.

methodstr

Fitting method. Defaults to “ML” (maximum likelihood).

Returns

xr.Dataset

Dataset containing the parameters of the fitted distributions, with a new dimension scipy_dist containing the distribution names.

Notes

In order to combine the parameters of multiple distributions, the size of the dparams dimension is set to the maximum number of unique parameters between the distributions.

xhydro.frequency_analysis.local.parametric_quantiles(p: Dataset, t: float | list[float], mode: str = 'max') Dataset[source]

Compute quantiles from fitted distributions.

Parameters

pxr.Dataset

Dataset containing the parameters of the fitted distributions. Must have a dimension dparams containing the parameter names and a dimension scipy_dist containing the distribution names.

tfloat or list of float

Return period(s) in years.

mode{‘max’, ‘min’}

Whether the return period is the probability of exceedance (max) or non-exceedance (min).

Returns

xr.Dataset

Dataset containing the quantiles of the distributions.