yatsm.masking module

yatsm.masking.multitemp_mask(x, Y, n_year, crit=400, green=1, swir1=4, maxiter=10)[source]

Multi-temporal masking using RLM

Taken directly from CCDC (Zhu and Woodcock, 2014). This “temporal masking” procedure was ported from CCDC v9.3.

Parameters:
  • x – array of ordinal dates
  • Y – matrix of observed spectra
  • n_year – “number of years to mask”
  • crit – critical value for masking clouds/shadows
  • green – 0 indexed value for green band in Y (default: 1)
  • swir1 – 0 indexed value for SWIR (~1.55-1.75um) band in Y (default: 4)
  • maxiter – maximum iterations for RLM fit
Returns:

mask where False indicates values to be masked

Return type:

mask (np.ndarray)

yatsm.masking.smooth_mask(x, Y, span, crit=400, green=1, swir1=4, maxiter=5)[source]

Multi-temporal masking using LOWESS

Taken directly from newer version of CCDC than Zhu and Woodcock, 2014. This “temporal masking” replaced the older method which used robust linear models. This version uses a regular LOWESS instead of robust LOWESS

Note

“span” argument is the inverse of “frac” from statsmodels and is actually ‘k’ in their code:

n = x.shape[0] k = int(frac * n + 1e-10)

Todo

We need to put the data on a regular period since span changes as is right now. Statsmodels will only allow for dropna, so we would need to impute missing data somehow...

Parameters:
  • x – array of ordinal dates
  • Y – matrix of observed spectra
  • span – span of LOWESS
  • crit – critical value for masking clouds/shadows
  • green – 0 indexed value for green band in Y (default: 1)
  • swir1 – 0 indexed value for SWIR (~1.55-1.75um) band in Y (default: 4)
  • maxiter – maximum increases to span when checking for NaN in LOWESS results
Returns:

mask where False indicates values to be masked

Return type:

mask (ndarray)