yatsm.phenology.longtermmean module

Implementation of Eli Melaas’ Landsat phenology algorithm

See:
Melaas, EK, MA Friedl, and Z Zhu. 2013. Detecting interannual variation in deciduous broadleaf forest phenology using Landsat TM/ETM+ data. Remote Sensing of Environment 132: 176-185.
class yatsm.phenology.longtermmean.LongTermMeanPhenology(red_index=2, nir_index=3, blue_index=0, scale=0.0001, evi_index=None, evi_scale=None, year_interval=3, q_min=10, q_max=90)[source]

Bases: object

Calculate long term mean phenology metrics for each YATSM record

Long term mean phenology metrics describe the general spring greenup and autumn senescence timing using an algorithm by Melaas et al., 2013 based on fitting smoothing splines to timeseries of EVI.

Variables:

self.pheno (np.ndarray) –

NumPy structured array containing phenology metrics. These metrics include:

  • spring_doy: the long term mean day of year of the start of spring
  • autumn_doy: the long term mean day of year of the start of autumn
  • pheno_cor: the correlation coefficient of the observed EVI and the smoothed prediction
  • peak_evi: the highest smoothed EVI value within the year (maximum amplitude of EVI)
  • peak_doy: the day of year corresponding to the peak EVI value
  • spline_evi: the smoothing spline prediction of EVI for days of year between 1 and 365
  • pheno_nobs: the number of observations used to fit the smoothing spline

Parameters:
  • red_index – index of model.Y containing red band (default: 2)
  • nir_index – index of model.Y containing NIR band (default: 3)
  • blue_index – index of model.Y containing blue band (default: 0)
  • scale – scale factor for reflectance bands in model.Y to transform data into [0, 1] (default: 0.0001)
  • evi_index – if EVI is already used within timeseries model, provide index of model.Y containing EVI to override computation from red/nir/blue bands (default: None)
  • evi_scale – if EVI is already used within timeseries model, provide scale factor to transform EVI into [0, 1] range (default: None)
  • year_interval – number of years to group together when normalizing EVI to upper and lower percentiles of EVI within the group (default: 3)
  • q_min – lower percentile for scaling EVI (default: 10)
  • q_max – upper percentile for scaling EVI (default: 90)
fit(model)[source]

Fit phenology metrics for each time segment within a YATSM model

Parameters:model – instance of yatsm.YATSM that has been run for change detection
Returns:
updated copy of YATSM model instance with phenology
added into yatsm.record structured array
Return type:np.ndarray
yatsm.phenology.longtermmean.CRAN_spline(x, y, spar=0.55)[source]

Return a prediction function for a smoothing spline from R

Use rpy2 package to fit a smoothing spline using “smooth.spline”.

Parameters:
  • x – independent variable
  • y – dependent variable
  • spar – smoothing parameter
Returns:

prediction function of smoothing spline that provides

smoothed estimates of the dependent variable given an input independent variable array

Return type:

callable

Example

Fit a smoothing spline for y ~ x and predict for days in year:

pred_spl = CRAN_spline(x, y)
y_smooth = pred_spl(np.arange(1, 366))
yatsm.phenology.longtermmean.group_years(years, interval=3)[source]

Return integers representing sequential groupings of years

Note: years specified must be sorted

Parameters:
  • years – the year corresponding to each EVI value
  • interval – number of years to group together (default: 3)
Returns:

integers representing sequential year groupings

Return type:

np.ndarray

yatsm.phenology.longtermmean.halfmax(x)[source]

Return index of the observation closest to the half of some data

Assumes that data are scaled between [0, 1] and half-max is 0.5

Parameters:x – a one dimensional vector
Returns:the index of the observation closest to the half-max of the data
Return type:int
yatsm.phenology.longtermmean.ordinal2yeardoy(ordinal)[source]

Convert ordinal dates to two arrays of year and doy

Parameters:ordinal – ordinal dates
Returns:
nobs x 2 np.ndarray containing the year and DOY for each
ordinal date
Return type:np.ndarray
yatsm.phenology.longtermmean.scale_EVI(evi, periods, qmin=10, qmax=90)[source]

Returns EVI scaled to upper and lower quantiles

Quantiles are calculated based on EVI within some year-to-year interval. As part of finding the quantiles, EVI values not within the (0, 1) range will be removed.

Parameters:
  • evi – EVI values
  • periods – intervals of years to group and scale together
  • qmin – lower quantile for scaling (default: 10)
  • qmax – upper quantile for scaling (default: 90)
Returns:

scaled EVI array

Return type:

np.ndarray