dep_tools.s2_utils module
This module contains useful functions for working with Sentinel-2 data.
- dep_tools.s2_utils.mask_clouds(xr, filters=None, keep_ints=False, return_mask=False)[source]
Mask Sentinel-2 data using the “SCL” band, with optional filters.
- The following classes are masked:
“SATURATED_OR_DEFECTIVE” (SCL = 1)
“CLOUD_SHADOWS” (SCL = 3)
“CLOUD_MEDIUM_PROBABILITY” (SCL = 8)
“CLOUD_HIGH_PROBABILITY” (SCL = 9)
“THIN_CIRRUS” (SCL = 10)
- Parameters:
xr (
DataArray) – Input Sentinel-2 data including, at least, a variable called “scl”, which contains the scene classification band.filters (
Optional[Iterable[Tuple[str,int]]]) – Filters to apply, passed toodc.algo.mask_cleanup().keep_ints (
bool) – If True, data is kept as input (typically integer) data type, and masking is performed usingodc.algo.erase_bad().return_mask (
bool) – Whether to return the mask itself along with the data.
- Return type:
DataArray- Returns:
If return_mask is False, the input data is returned, with the specified masking applied, If True, then a tuple of (<data>, <mask>).
- dep_tools.s2_utils.harmonize_to_old(data)[source]
Harmonize new Sentinel-2 data to the old baseline.
Inspired by https://planetarycomputer.microsoft.com/dataset/sentinel-2-l2a#Baseline-Change
- Parameters:
data (xarray.DataArray) – A DataArray with four dimensions: time, band, y, x
- Returns:
harmonized – A DataArray with all values harmonized to the old processing baseline.
- Return type:
xarray.DataArray