environmentaltools.spatiotemporal.indicators.mean_presence_boundary

environmentaltools.spatiotemporal.indicators.mean_presence_boundary(data_cube, threshold=None)[source]

Calculate spatial boundary where temporal mean exceeds a presence threshold.

Computes the contour lines that define areas where the temporal average of values exceeds a specified threshold. This is useful for identifying persistent zones of influence or presence in spatiotemporal data.

Parameters:
  • data_cube (np.ndarray, xarray.DataArray, or xarray.Dataset) – 3D array with shape (time, lat, lon) containing spatiotemporal data. If Dataset, uses the first data variable.

  • threshold (float, optional) – Presence threshold. If None, uses the global mean of the temporal average map.

Returns:

  • contours (list) – List of contour coordinates defining the presence boundary.

  • mean_map (np.ndarray) – 2D map of temporal means for each spatial location.

Notes

The function computes temporal means for each spatial cell, then identifies contours where these means exceed the specified threshold. The contours represent boundaries between areas of high and low temporal presence.

Examples

>>> import numpy as np
>>> data_cube = np.random.random((365, 50, 50))  # Daily data for 1 year
>>> contours, mean_map = mean_presence_boundary(data_cube, threshold=0.6)