Check input data, interpolate NA values in y, remove spike values, and set weights for NA in y and w.
check_input( t, y, w, QC_flag, nptperyear, south = FALSE, Tn = NULL, wmin = 0.2, wsnow = 0.8, ymin, missval, maxgap, alpha = 0.02, alpha_high = NULL, date_start = NULL, date_end = NULL, mask_spike = TRUE, ... )
t | Numeric vector, |
---|---|
y | Numeric vector, vegetation index time-series |
w | (optional) Numeric vector, weights of |
QC_flag | Factor (optional) returned by |
nptperyear | Integer, number of images per year. |
south | Boolean. In south hemisphere, growing year is 1 July to the following year 31 June; In north hemisphere, growing year is 1 Jan to 31 Dec. |
Tn | Numeric vector, night temperature, default is null. If provided,
Tn is used to help divide ungrowing period, and then get background value in
ungrowing season (see details in |
wmin | Double, minimum weight of bad points, which could be smaller the weight of snow, ice and cloud. |
wsnow | Doulbe. Reset the weight of snow points, after get |
ymin | If specified, |
missval | Double, which is used to replace NA values in y. If missing,
the default vlaue is |
maxgap | Integer, nptperyear/4 will be a suitable value. If continuous
missing value numbers less than maxgap, then interpolate those NA values by
zoo::na.approx; If false, then replace those NA values with a constant value
|
alpha | Double, in |
alpha_high | Double, |
date_start, date_end | starting and ending date of the original vegetation
time-sereis (before |
mask_spike | Boolean. Whether to remove spike values? |
... | Others will be ignored. |
A list object returned:
t
: Numeric vector
y0
: Numeric vector, original vegetation time-series.
y
: Numeric vector, checked vegetation time-series, NA
values are interpolated.
w
: Numeric vector
Tn
: Numeric vector
ylu
: = [ymin, ymax]
. w_critical
is used to filter not too bad values.
If the percentage good values (w=1) is greater than 30\
The else, if the percentage of w >= 0.5 points is greater than 10\
w_critical
=0.5. In boreal regions, even if the percentage of w >= 0.5
points is only 10\
We can't rely on points with the wmin weights. Then,
y_good = y[w >= w_critical]
,
ymin = pmax( quantile(y_good, alpha/2), 0)
ymax = max(y_good)
.
phenofit::backval()
#> Error in library(phenofit): there is no package called ‘phenofit’#> Warning: data set ‘MOD13A1’ not found#> Error in tidy_MOD13(MOD13A1$dt): object 'MOD13A1' not foundst <- MOD13A1$st#> Error in eval(expr, envir, enclos): object 'MOD13A1' not founddate_start <- as.Date('2013-01-01') date_end <- as.Date('2016-12-31') sitename <- 'CA-NS6' # df$site[1] d <- df[site == sitename & (date >= date_start & date <= date_end), ]#> Error in eval(expr, envir, enclos): object 'site' not foundsp <- st[site == sitename, ]#> Error in eval(expr, envir, enclos): object 'st' not foundsouth <- sp$lat < 0#> Error in eval(expr, envir, enclos): object 'sp' not foundnptperyear <- 23 # global parameter IsPlot = TRUE print = FALSE ypeak_min = 0.05 wFUN = wTSM # add one year in head and tail # d <- add_HeadTail(d, south = south, nptperyear = nptperyear) INPUT <- check_input(d$t, d$y, d$w, QC_flag = d$QC_flag, nptperyear = nptperyear, south = south, maxgap = nptperyear/4, alpha = 0.02, wmin = 0.2)#> Error in check_input(d$t, d$y, d$w, QC_flag = d$QC_flag, nptperyear = nptperyear, south = south, maxgap = nptperyear/4, alpha = 0.02, wmin = 0.2): object 'd' not found