xclim.indicators.generic package

Generic indicators

Submodules

xclim.indicators.generic._stats module

xclim.indicators.generic._stats.fit(da: Union[DataArray, str] = 'da', *, dist: str = 'norm', method: str = 'ML', dim: str = 'time', ds: Dataset = None, **fitkwargs) DataArray

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

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). If the PWM method is used, only the following distributions are currently supported: ‘expon’, ‘gamma’, ‘genextreme’, ‘genpareto’, ‘gumbel_r’, ‘pearson3’, ‘weibull_min’. Default : norm.

  • method ({‘APP’, ‘ML’, ‘PWM’}) – Fitting method, either maximum likelihood (ML), probability weighted moments (PWM), also called L-Moments, or approximate method (APP). 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 – Default : None.

Returns

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

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: Union[DataArray, str] = 'da', *, mode: str, t: int | Sequence[int], dist: str, window: int = 1, freq: str | None = None, ds: Dataset = None, **indexer) DataArray

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 “skip”. Based on indice frequency_analysis().

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

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

  • 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. Default : ds.da.

  • dist (str) – Name of the univariate distribution, e.g. beta, expon, genextreme, gamma, gumbel_r, lognorm, norm. Default : ds.da.

  • 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 AS-DEC. Default : None.

  • 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. Default : None.

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.

xclim.indicators.generic._stats.stats(da: Union[DataArray, str] = 'da', *, op: str, freq: str = 'YS', ds: Dataset = None, **indexer) DataArray

Statistic of the daily values for a given period. (realm: generic)

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

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

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

  • freq (offset alias (string)) – Resampling frequency defining the periods as defined in https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#resampling. 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. Default : None.

Returns

stat_{indexer}{op (r} : DataArray) – Daily statistics, with additional attributes: description: {freq} {op} of daily values ({indexer}).