roughFit {phenofit}R Documentation

Rough fitting

Description

Divide growing seasons according to rough fitting (rFUN) result .

For season, rough fitting is applied for whole. For season_mov rough fitting is applied in every year, during which maxExtendMonth is extended.

Usage

roughFit(
  INPUT,
  options = list(),
  frame = floor(INPUT$nptperyear/5) * 2 + 1,
  ...
)

Arguments

INPUT

A list object with the elements of t, y, w, Tn (optional) and ylu, returned by check_input().

options

see details

...

ignored.

Details

Before division growing season, INPUT should be added a year in head and tail first by add_HeadTail.

Finally, use findpeaks() to get local maximum and local minimum values. Two local minimum define a growing season. If two local minimum(maximum) are too closed, then only the smaller(biger) is left.

Value

options for season

(a) Parameters for rough fitting

(b) Parameters for growing season division

See Also

findpeaks().

Examples

data("CA_NS6")
d <- CA_NS6

nptperyear <- 23
INPUT <- check_input(d$t, d$y, d$w,
    QC_flag = d$QC_flag,
    nptperyear = nptperyear, south = FALSE,
    maxgap = nptperyear / 4, alpha = 0.02, wmin = 0.2
)
# plot_input(INPUT)

wFUN <- "wTSM"
# all year as a whole
options = list(rFUN = "smooth_wWHIT", wFUN = wFUN, lambda = 10)
brks <- season(INPUT, lambda = 10)
plot_season(INPUT, brks, d)

brks2 = season_input(INPUT, options)
all.equal(brks2, brks)

c(d_fit, info_peak) %<-% roughFit(INPUT)
d_season = find_season.peaks(d_fit, info_peak)

c(t, ypred) %<-% d_fit[, .(t, ziter2)]
d_season = find_season.default(ypred, t)
all.equal(brks$dt, d_season)

# opt <- .options$season
# brks$fit - d_fit # function passed test

# curve fitting by year
brks_mov <- season_mov(INPUT,
    options = list(
        rFUN = "smooth_wWHIT", wFUN = wFUN,
        lambda = 10,
        r_min = 0.05, ypeak_min = 0.05,
        verbose = TRUE
    )
)
plot_season(INPUT, brks_mov)

rfit <- brks2rfit(brks_mov)
r <- get_pheno(rfit)

[Package phenofit version 0.3.10 Index]