xclim.indicators.generic package

Generic Indicators

Submodules

xclim.indicators.generic._stats module

xclim.indicators.generic._stats.fit(da='da', *, dist='norm', method='ML', dim='time', ds=None, **fitkwargs)

Distribution parameters fitted over the time dimension. (realm: generic)

This indicator will check for missing values according to the method “from_context”. Based on indice fit().

Parameters:
  • da (str or DataArray) – Time series to be fitted along the time dimension. Default : ds.da.

  • dist (str) – Name of the univariate distribution, such as beta, expon, genextreme, gamma, gumbel_r, lognorm, norm (see :py:mod:scipy.stats for full list) or the distribution object itself. Default : norm.

  • method (str) – Fitting method, either maximum likelihood (ML or MLE), method of moments (MM) or approximate method (APP). Can also be the probability weighted moments (PWM), also called L-Moments, if a compatible dist object is passed. The PWM method is usually more robust to outliers. Default : ML.

  • dim (str) – The dimension upon which to perform the indexing (default: “time”). Other arguments passed directly to _fitstart() and to the distribution’s fit. Default : time.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default : None.

  • fitkwargs – Required.

Returns:

params (DataArray) – {dist} distribution parameters ({dist} parameters), with additional attributes: cell_methods: time: fit; description: Parameters of the {dist} distribution.

Return type:

xarray.DataArray

Notes

Coordinates for which all values are NaNs will be dropped before fitting the distribution. If the array still contains NaNs, the distribution parameters will be returned as NaNs.

xclim.indicators.generic._stats.return_level(da='da', *, mode, t, dist, window=1, freq=None, method='ML', ds=None, **indexer)

Return level from frequency analysis (realm: generic)

Frequency analysis on the basis of a given mode and distribution.

This indicator will check for missing values according to the method “from_context”. Based on indice frequency_analysis().

Parameters:
  • da (str or DataArray) – Input data. Default : ds.da.

  • mode ({‘min’, ‘max’}) – Whether we are looking for a probability of exceedance (high) or a probability of non-exceedance (low). Required.

  • t (number or sequence of numbers) – Return period. The period depends on the resolution of the input data. If the input array’s resolution is yearly, then the return period is in years. Required.

  • dist (str) – Name of the univariate distribution, e.g. beta, expon, genextreme, gamma, gumbel_r, lognorm, norm. Or an instance of the distribution. Required.

  • window (number) – Averaging window length (days). Default : 1.

  • freq (offset alias (string)) – Resampling frequency. If None, the frequency is assumed to be ‘YS’ unless the indexer is season=’DJF’, in which case freq would be set to YS-DEC. See https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases for available options. Default : None.

  • method (str) – Fitting method, either maximum likelihood (ML or MLE), method of moments (MOM) or approximate method (APP). Also accepts probability weighted moments (PWM), also called L-Moments, if dist is an instance from the lmoments3 library. The PWM method is usually more robust to outliers. Time attribute and values over which to subset the array. For example, use season=’DJF’ to select winter values, month=1 to select January, or month=[6,7,8] to select summer months. If indexer is not provided, all values are considered. Default : ML.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default : None.

  • indexer – Required.

Returns:

fa_{window}{mode (r}{indexer} : DataArray) – N-year return level, with additional attributes: description: Frequency analysis for the {mode} {indexer} {window}-day value estimated using the {dist} distribution.

Return type:

xarray.DataArray

xclim.indicators.generic._stats.stats(da='da', *, op, freq='YS', ds=None, **indexer)

Simple resampled statistic of the values. (realm: generic)

This indicator will check for missing values according to the method “from_context”. Based on indice select_resample_op(). With injected parameters: out_units=None.

Parameters:
  • da (str or DataArray) – Input data. Default : ds.da.

  • op ({‘min’, ‘argmin’, ‘integral’, ‘argmax’, ‘sum’, ‘std’, ‘mean’, ‘max’, ‘var’, ‘count’}) – Reduce operation. Can either be a DataArray method or a function that can be applied to a DataArray. Required.

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in Resampling. See https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases for available options. Default : YS.

  • ds (Dataset, optional) – A dataset with the variables given by name. Default : None.

  • indexer – Time attribute and values over which to subset the array. For example, use season=’DJF’ to select winter values, month=1 to select January, or month=[6,7,8] to select summer months. If not indexer is given, all values are considered. Required.

Returns:

stat_{indexer}{op (r} : DataArray) – {op:noun} of variable, with additional attributes: description: {freq} {op:noun} of variable ({indexer}).

Return type:

xarray.DataArray