hypergas.quality_mask module#

Create a 2D quality mask for hyperspectral satellite data.

class hypergas.quality_mask.QualityMask(scn)[source]#

Bases: object

Quality mask for hyperspectral satellite scenes.

Computes per-pixel boolean flags for water, cloud, and cirrus contamination based on top-of-atmosphere (TOA) reflectance thresholds, and combines them into a single qmask DataArray.

Parameters:

scn (Scene) –

Satpy Scene that must contain the following datasets:

  • 'radiance' – spectral radiance in W m-2 sr-1 um-1, with dimensions (bands, y, x).

  • 'sza' – solar zenith angle in degrees, shape (y, x).

scn#

The input scene (stored for reference).

Type:

Scene

rad#

Radiance converted to uW cm-2 sr-1 nm-1 (divided by 10).

Type:

DataArray

sza#

Scene-mean solar zenith angle in radians.

Type:

float

rho#

TOA apparent reflectance, shape (bands, y, x).

Type:

DataArray

water#

Boolean water mask, shape (y, x).

Type:

DataArray

cloud#

Boolean cloud mask, shape (y, x).

Type:

DataArray

cirrus#

Boolean cirrus mask, shape (y, x).

Type:

DataArray

qmask#

Combined quality mask with a quality_flag dimension whose labels are ['water', 'cloud', 'cirrus', 'invalid'].

Type:

DataArray

cirrus_mask(rho=None)[source]#

Identify cirrus cloud pixels using TOA reflectance at 1380 nm.

The 1380 nm water-vapour absorption band is used as a cirrus proxy: surface-leaving radiance is almost entirely absorbed by atmospheric water vapour at this wavelength, so any residual reflectance above the threshold is attributed to high-altitude cirrus ice clouds.

Sets self.cirrus to a boolean DataArray of shape (y, x).

References

Gao & Goetz, GRL, 20(4), 301–304, 1993. https://doi.org/10.1029/93GL00106

cloud_mask(rho=None)[source]#

Identify cloud pixels using multi-band TOA reflectance thresholds.

Three independent reflectance tests are applied:

  • 450 nm > 0.28 (high visible reflectance)

  • 1250 nm > 0.46 (high short-wave infrared reflectance)

  • 1650 nm > 0.22 (high short-wave infrared reflectance)

A pixel is flagged as cloudy only when all three conditions are satisfied (majority vote ≥ 3 out of 3), reducing false positives over bright land surfaces.

Sets self.cloud to a boolean DataArray of shape (y, x).

References

Sandford et al., AMT, 13, 7047–7057, 2020. https://doi.org/10.5194/amt-13-7047-2020

mask()[source]#

Compute all individual masks and combine into self.qmask.

Calls water_mask(), cloud_mask(), and cirrus_mask() in sequence, then concatenates the results along a new quality_flag dimension. An additional 'invalid' flag is appended that is True wherever any of the three masks is True.

After calling this method the combined mask is available as self.qmask with shape (quality_flag, y, x) and quality_flag labels ['water', 'cloud', 'cirrus', 'invalid'].

water_mask(rho=None)[source]#

Identify water pixels using TOA reflectance at 1000 nm.

A pixel is flagged as water when its near-infrared reflectance falls below 0.05, exploiting the strong absorption of liquid water beyond 900 nm.

Sets self.water to a boolean DataArray of shape (y, x).