environmentaltools.spatiotemporal.indicators.mean_exceedance_over_exceedance_area

environmentaltools.spatiotemporal.indicators.mean_exceedance_over_exceedance_area(data, thresholds=None)[source]

Compute mean value of exceedances normalized by exceedance area only.

Calculates the average of values that exceed each threshold, considering only the spatial points where exceedance occurs. This indicator (WMEW - Weighted Mean Exceedance over exceedance area) provides the conditional mean given that the threshold is exceeded.

Parameters:
  • data (array_like) – 1D array of spatial data values to analyze.

  • thresholds (array_like, optional) – Array of threshold values to evaluate. If None, generates 100 equally spaced thresholds from 0 to the maximum data value.

Returns:

  • thresholds (np.ndarray) – Array of threshold values used in the analysis.

  • conditional_means (np.ndarray) – Mean values conditional on exceeding each threshold.

Notes

The mean exceedance over exceedance area is computed as:

\[WMEW(t) = \frac{\sum_{i: x_i \geq t} x_i}{\sum_{i=1}^{N} \mathbb{1}(x_i \geq t)}\]

This represents the expected value conditional on exceeding the threshold: \(E[X | X \geq t]\).

Examples

>>> import numpy as np
>>> data = np.random.lognormal(1, 0.5, 1000)
>>> thresholds, cond_means = mean_exceedance_over_exceedance_area(data)