check_input: check_input

Description Usage Arguments Value See Also Examples

View source: R/check_input.R

Description

Check input data, interpolate NA values in y, remove spike values, and set weights for NA in y and w.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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,
  ...
)

Arguments

t

Numeric vector, Date variable

y

Numeric vector, vegetation index time-series

w

(optional) Numeric vector, weights of y. If not specified, weights of all NA values will be wmin, the others will be 1.0.

QC_flag

Factor (optional) returned by qcFUN, levels should be in the range of c("snow", "cloud", "shadow", "aerosol", "marginal", "good"), others will be categoried into others. QC_flag is used for visualization in get_pheno() and plot_phenofit().

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 phenofit::backval()).

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 ylu. Snow flag is an important flag of ending of growing season. Snow points is more valuable than marginal points. Hence, the weight of snow should be great than that of marginal.

ymin

If specified, ylu[1] is constrained greater than ymin. This value is critical for bare, snow/ice land, where vegetation amplitude is quite small. Generally, you can set ymin=0.08 for NDVI, ymin=0.05 for EVI, ymin=0.5 gC m-2 s-1 for GPP.

missval

Double, which is used to replace NA values in y. If missing, the default vlaue is ylu[1].

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 ylu[1].
Replacing NA values with a constant missing value (e.g. background value ymin) is inappropriate for middle growing season points. Interpolating all values by na.approx, it is unsuitable for large number continous missing segments, e.g. in the start or end of growing season.

alpha

Double value in [0,1], quantile prob of ylu_min.

alpha_high

Double value in [0,1], quantile prob of ylu_max. If not specified, alpha_high=alpha.

date_start, date_end

starting and ending date of the original vegetation time-sereis (before add_HeadTail)

mask_spike

Boolean. Whether to remove spike values?

...

Others will be ignored.

Value

A list object returned:

See Also

phenofit::backval()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
library(phenofit)
data("MOD13A1")

df <- tidy_MOD13.gee(MOD13A1$dt)
st <- MOD13A1$st

date_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), ]
sp    <- st[site == sitename, ]
south <- sp$lat < 0
nptperyear <- 23

# global parameter
IsPlot = TRUE
print  = FALSE
ypeak_min  = 0.05
wFUN = wTSM

# add one year in head and tail
dnew     <- add_HeadTail(d, south = south, nptperyear = nptperyear) 
INPUT    <- check_input(dnew$t, dnew$y, dnew$w, QC_flag = dnew$QC_flag,
     nptperyear = nptperyear, south = south, 
     maxgap = nptperyear/4, alpha = 0.02, wmin = 0.2)

phenofit documentation built on April 2, 2020, 5:07 p.m.