environmentaltools.spatiotemporal.indicators.neighbourhood_gradient_influence
- environmentaltools.spatiotemporal.indicators.neighbourhood_gradient_influence(data_cube, size=3)[source]
Calculate gradient magnitude between each cell and its neighborhood.
Computes the absolute difference between each cell’s value and its neighborhood mean. This measures how much each cell deviates from its local spatial context.
- Parameters:
data_cube (np.ndarray) – 3D array with shape (time, lat, lon) containing spatiotemporal data.
size (int, optional) – Neighborhood size. Default is 3.
- Returns:
influence_map – 2D map of average gradient influence.
- Return type:
np.ndarray
Notes
High values indicate cells that consistently differ from their neighbors, suggesting local anomalies or gradient boundaries. Low values indicate cells that are well-integrated with their spatial context.
Examples
>>> import numpy as np >>> data_cube = np.random.random((20, 15, 15)) >>> influence_map = neighbourhood_gradient_influence(data_cube, size=5)