environmentaltools.spatiotemporal.indicators.local_persistence
- environmentaltools.spatiotemporal.indicators.local_persistence(data_cube, size=3)[source]
Calculate local persistence as proportion of time cell exceeds its neighborhood.
Computes the fraction of time that each cell has values higher than its neighborhood mean. This measures local dominance and persistence patterns.
- Parameters:
data_cube (np.ndarray) – 3D array with shape (time, lat, lon) containing spatiotemporal data.
size (int, optional) – Neighborhood size. Default is 3.
- Returns:
persistence_map – 2D map of persistence values (0-1 scale).
- Return type:
np.ndarray
Notes
Values near 1 indicate cells that consistently exceed their neighborhood (local maxima or persistent hotspots). Values near 0 indicate cells that consistently fall below their neighborhood (local minima or cold spots).
Examples
>>> import numpy as np >>> data_cube = np.random.exponential(1, (40, 20, 20)) >>> persistence_map = local_persistence(data_cube, size=5)