eoio.readers.sentinel2.masks module

eoio.readers.sentinel2.masks module#

eoio.readers.sentinel2.masks - Sentinel-2 L1C classification mask reading

L1C products from processing baseline 04.00 onwards ship a per-granule classification raster, QI_DATA/MSK_CLASSI_B00.jp2: a 60 m, 3-band JP2 in which each band is a binary (0/1) mask. The bands are, in order, opaque clouds, cirrus, and snow/ice – exposed here as the named variables in MASK_OPTIONS.

Earlier baselines carry QA60.jp2 / MSK_CLOUDS_B00.gml instead; those are not supported, and such products simply yield no mask variables (with a warning) rather than raising.

eoio.readers.sentinel2.masks.add_masks(*, ds: Dataset, masks: List[str], layout: S2Layout, subset: ResolvedROISubset | None, config: Any) → Dataset[source]#

Read the requested L1C classification masks and add them to ds.

Mirrors eoio.readers.sentinel3_olci.masks.add_masks(): validates the selection, then delegates the IO to read_masks().

Parameters:
  • ds – dataset to add mask variables to.

  • masks – mask variable names to read (see MASK_OPTIONS).

  • layout – layout helper used to locate the mask file.

  • subset – resolved ROI subset to clip the mask to, or None.

  • config – resolved reader configuration.

Returns:

ds with the mask variables merged in.

Raises:

ValueError – if an unknown mask name is requested.

eoio.readers.sentinel2.masks.read_masks(*, ds: Dataset, masks: List[str], layout: S2Layout, subset: ResolvedROISubset | None = None, chunks: dict | None = None, use_chunks: bool = False) → Dataset[source]#

Read classification mask bands from MSK_CLASSI_B00.jp2 into ds.

The mask is a 60 m raster, which is coarser than the 10/20 m measurement grids, so its variables are placed on their own x_60m/y_60m dimensions following this reader’s existing per-resolution grid naming (see read_bands_into_dataset()) rather than being resampled onto a measurement grid.

Parameters:
  • ds – dataset to add mask variables to.

  • masks – mask variable names to read.

  • layout – layout helper used to locate the mask file.

  • subset – resolved ROI subset to clip the mask to, or None.

  • chunks – explicit dask chunk spec passed to rioxarray.

  • use_chunks – whether to open the raster lazily (chunked).

Returns:

ds with the mask variables merged in.