environmentaltools.spatiotemporal.raster.binary_matrix
- environmentaltools.spatiotemporal.raster.binary_matrix(data_cube, levels, info)[source]
Create binary mask matrix based on threshold levels for spatiotemporal analysis.
This function generates a binary mask matrix by comparing elevation data in the data cube against corresponding threshold levels for each time step. Values below the threshold are marked as True (1), values above as False (0).
- Parameters:
data_cube (xarray.DataArray) – The input spatiotemporal data cube containing elevation or other environmental variable data with dimensions (time, y, x).
levels (pandas.DataFrame) – DataFrame containing threshold levels indexed by time/date, with columns corresponding to variables. Must have the same temporal index as data_cube.
info (dict) – Configuration dictionary containing project parameters, including: - project.variables: List of variable names to process
- Returns:
Binary mask array with the same shape as data_cube, where: - 1 (True): Values below the threshold level - 0 (False): Values above or equal to the threshold level
- Return type:
numpy.ndarray
Notes
The function performs temporal iteration over the data cube, applying thresholds for each time step. This is commonly used for: - Flood risk analysis (areas below water level) - Environmental threshold exceedance analysis - Binary classification of environmental conditions
The mask creation follows the pattern: mask[t, y, x] = data_cube[t, y, x] < levels[t, variable]