stems.masking module¶
Helpers with data masks (clouds, qa/qc, etc)
References
-
stems.masking.
bitpack_to_coding
(bitpack, bitinfo, fill=0, dtype=None)[source]¶ Unpack a bipacked QA/QC band to some coding (e.g. CFMask)
- Parameters
bitpack (np.ndarray, dask.array.Array, or xr.DataArray) – Bitpacked data
bitinfo (Dict[int, Sequence[Tuple[Int, Int, Int]]) – A dict mapping output codes to bit unpacking info(s) (offsets, widths, and values) for use in unpacking. Should be ordered in order of preference with values listed first possibly overwriting later ones
fill (int, float, etc, optional) – Fill value to initialize array with (e.g., your “clear” value, since qa/qc bands usually indicate issues with data)
dtype (np.dtype, optional) – Output NumPy datatype. If
None
, output will be same datatype as inputbitpack
- Returns
CFmask look-alike array
- Return type
array
-
stems.masking.
checkbit
(data, offset, width=1, value=3)[source]¶ Unpack a bit into True/False
- Parameters
data (np.ndarray, da.Array, xr.DataArray) – Bitpacked array data
offset (int) – Bit offset
width (int, optional) – Width of bitpacking (e.g., 1=>[0, 1], 2=>[0, 1, 2, 3])
value (int, optional) – If
width > 1
, specify the value required to be True (e.g., 3 for ‘high’, 2 for ‘medium’, etc. in some codings)
- Returns
True or False value of unpacked bit(s)
- Return type
array-like, dtype=bool