environmentaltools.spatiotemporal.indicators.directional_influence
- environmentaltools.spatiotemporal.indicators.directional_influence(data_cube, dx=1, dy=1)[source]
Calculate mean direction of spatial gradient for each cell.
Computes the temporal average direction and magnitude of spatial gradients. This identifies the predominant direction of spatial influence and the strength of directional patterns.
- Parameters:
data_cube (np.ndarray) – 3D array with shape (time, lat, lon) containing spatiotemporal data.
dx (float, optional) – Spatial resolution in X and Y directions. Default is 1.
dy (float, optional) – Spatial resolution in X and Y directions. Default is 1.
- Returns:
angle_map (np.ndarray) – 2D map of mean gradient directions in radians.
magnitude_map (np.ndarray) – 2D map of mean gradient magnitudes.
Notes
The function computes spatial gradients for each time step, then averages both the direction (angle) and magnitude across time. This reveals persistent spatial patterns and directional influences.
Examples
>>> import numpy as np >>> data_cube = np.random.random((50, 25, 25)) >>> angles, magnitudes = directional_influence(data_cube, dx=0.1, dy=0.1)