xhydro.extreme_value_analysis package

Extreme value analysis analysis module.

xhydro.extreme_value_analysis.fit(ds: Dataset, locationcov: list[str] | None = None, scalecov: list[str] | None = None, shapecov: list[str] | None = None, variables: list[str] | None = None, dist: str | rv_continuous = 'genextreme', method: str = 'ML', dim: str = 'time', confidence_level: float = 0.95, niter: int = 5000, warmup: int = 2000) Dataset[source]

Fit an array to a univariate distribution along a given dimension.

Parameters

dsxr.DataSet

Xarray Dataset containing the data to be fitted.

locationcovlist[str]

List of names of the covariates for the location parameter.

scalecovlist[str]

List of names of the covariates for the scale parameter.

shapecovlist[str]

List of names of the covariates for the shape parameter.

variableslist[str]

List of variables to be fitted.

diststr or rv_continuous distribution object

Name of the univariate distribution or the distribution object itself. Supported distributions are genextreme, gumbel_r, genpareto.

method{« ML », « PWM », « BAYES}

Fitting method, either maximum likelihood (ML), probability weighted moments (PWM) or bayesian (BAYES).

dimstr

Specifies the dimension along which the fit will be performed (default: « time »).

confidence_levelfloat

The confidence level for the confidence interval of each parameter.

niterint

The number of iterations of the bayesian inference algorithm for parameter estimation (default: 5000).

warmupint

The number of warmup iterations of the bayesian inference algorithm for parameter estimation (default: 2000).

Returns

xr.Dataset

Dataset of fitted distribution parameters and confidence interval values.

Notes

Coordinates for which all values are NaNs will be dropped before fitting the distribution. If the array still contains NaNs or has less valid values than the number of parameters for that distribution, the distribution parameters will be returned as NaNs.

xhydro.extreme_value_analysis.return_level(ds: Dataset, locationcov: list[str] | None = None, scalecov: list[str] | None = None, shapecov: list[str] | None = None, variables: list[str] | None = None, dist: str | rv_continuous = 'genextreme', method: str = 'ML', dim: str = 'time', confidence_level: float = 0.95, return_period: float = 100, niter: int = 5000, warmup: int = 2000, threshold_pareto: float | None = None, nobs_pareto: int | None = None, nobsperblock_pareto: int | None = None) Dataset[source]

Compute the return level associated with a return period based on a given distribution.

Parameters

dsxr.DataSet

Xarray Dataset containing the data for return level calculations.

locationcovlist[str]

List of names of the covariates for the location parameter.

scalecovlist[str]

List of names of the covariates for the scale parameter.

shapecovlist[str]

List of names of the covariates for the shape parameter.

variableslist[str]

List of variables to be fitted.

diststr or rv_continuous distribution object

Name of the univariate distribution or the distribution object itself. Supported distributions are genextreme, gumbel_r, genpareto.

method{« ML », « PWM », « BAYES}

Fitting method, either maximum likelihood (ML), probability weighted moments (PWM) or bayesian (BAYES).

dimstr

Specifies the dimension along which the fit will be performed (default: « time »).

confidence_levelfloat

The confidence level for the confidence interval of each parameter.

return_periodfloat

Return period used to compute the return level.

niterint

The number of iterations of the bayesian inference algorithm for parameter estimation (default: 5000).

warmupint

The number of warmup iterations of the bayesian inference algorithm for parameter estimation (default: 2000).

threshold_paretofloat

The value above which the Pareto distribution is applied.

nobs_paretoint

The total number of observations used when applying the Pareto distribution.

nobsperblock_paretoint

The number of observations per block when applying the Pareto distribution.

Returns

xr.Dataset

Dataset of with the return level and the confidence interval values.

Notes

Coordinates for which all values are NaNs will be dropped before fitting the distribution. If the array still contains NaNs or has less valid values than the number of parameters for that distribution, the distribution parameters will be returned as NaNs.

Subpackages

Submodules

xhydro.extreme_value_analysis.julia_import module

Load and install Julia dependencies into python environment.

xhydro.extreme_value_analysis.parameterestimation module

Parameter estimation functions for the extreme value analysis module.

xhydro.extreme_value_analysis.parameterestimation.fit(ds: Dataset, locationcov: list[str] | None = None, scalecov: list[str] | None = None, shapecov: list[str] | None = None, variables: list[str] | None = None, dist: str | rv_continuous = 'genextreme', method: str = 'ML', dim: str = 'time', confidence_level: float = 0.95, niter: int = 5000, warmup: int = 2000) Dataset[source]

Fit an array to a univariate distribution along a given dimension.

Parameters

dsxr.DataSet

Xarray Dataset containing the data to be fitted.

locationcovlist[str]

List of names of the covariates for the location parameter.

scalecovlist[str]

List of names of the covariates for the scale parameter.

shapecovlist[str]

List of names of the covariates for the shape parameter.

variableslist[str]

List of variables to be fitted.

diststr or rv_continuous distribution object

Name of the univariate distribution or the distribution object itself. Supported distributions are genextreme, gumbel_r, genpareto.

method{« ML », « PWM », « BAYES}

Fitting method, either maximum likelihood (ML), probability weighted moments (PWM) or bayesian (BAYES).

dimstr

Specifies the dimension along which the fit will be performed (default: « time »).

confidence_levelfloat

The confidence level for the confidence interval of each parameter.

niterint

The number of iterations of the bayesian inference algorithm for parameter estimation (default: 5000).

warmupint

The number of warmup iterations of the bayesian inference algorithm for parameter estimation (default: 2000).

Returns

xr.Dataset

Dataset of fitted distribution parameters and confidence interval values.

Notes

Coordinates for which all values are NaNs will be dropped before fitting the distribution. If the array still contains NaNs or has less valid values than the number of parameters for that distribution, the distribution parameters will be returned as NaNs.

xhydro.extreme_value_analysis.parameterestimation.return_level(ds: Dataset, locationcov: list[str] | None = None, scalecov: list[str] | None = None, shapecov: list[str] | None = None, variables: list[str] | None = None, dist: str | rv_continuous = 'genextreme', method: str = 'ML', dim: str = 'time', confidence_level: float = 0.95, return_period: float = 100, niter: int = 5000, warmup: int = 2000, threshold_pareto: float | None = None, nobs_pareto: int | None = None, nobsperblock_pareto: int | None = None) Dataset[source]

Compute the return level associated with a return period based on a given distribution.

Parameters

dsxr.DataSet

Xarray Dataset containing the data for return level calculations.

locationcovlist[str]

List of names of the covariates for the location parameter.

scalecovlist[str]

List of names of the covariates for the scale parameter.

shapecovlist[str]

List of names of the covariates for the shape parameter.

variableslist[str]

List of variables to be fitted.

diststr or rv_continuous distribution object

Name of the univariate distribution or the distribution object itself. Supported distributions are genextreme, gumbel_r, genpareto.

method{« ML », « PWM », « BAYES}

Fitting method, either maximum likelihood (ML), probability weighted moments (PWM) or bayesian (BAYES).

dimstr

Specifies the dimension along which the fit will be performed (default: « time »).

confidence_levelfloat

The confidence level for the confidence interval of each parameter.

return_periodfloat

Return period used to compute the return level.

niterint

The number of iterations of the bayesian inference algorithm for parameter estimation (default: 5000).

warmupint

The number of warmup iterations of the bayesian inference algorithm for parameter estimation (default: 2000).

threshold_paretofloat

The value above which the Pareto distribution is applied.

nobs_paretoint

The total number of observations used when applying the Pareto distribution.

nobsperblock_paretoint

The number of observations per block when applying the Pareto distribution.

Returns

xr.Dataset

Dataset of with the return level and the confidence interval values.

Notes

Coordinates for which all values are NaNs will be dropped before fitting the distribution. If the array still contains NaNs or has less valid values than the number of parameters for that distribution, the distribution parameters will be returned as NaNs.