environmentaltools.spatiotemporal.indicators.spatial_change_rate

environmentaltools.spatiotemporal.indicators.spatial_change_rate(data_cube, dx=1, dy=1)[source]

Calculate mean spatial change rate for each cell over time.

Computes the temporal average of spatial gradient magnitudes for each location. This measures how rapidly values change spatially and how this spatial variability evolves over time.

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:

rate_map – 2D map of mean spatial change rates.

Return type:

np.ndarray

Notes

For each time step, the function computes spatial gradients using finite differences, then calculates the gradient magnitude. The final result is the temporal average of these magnitudes.

High values indicate areas with consistently high spatial variability, while low values suggest spatially smooth regions.

Examples

>>> import numpy as np
>>> data_cube = np.random.random((50, 20, 20))
>>> rate_map = spatial_change_rate(data_cube, dx=0.1, dy=0.1)