Fine Curve fitting for INPUT time-series.

curvefits(
  INPUT,
  brks,
  methods,
  wFUN,
  iters = 2,
  wmin = 0.1,
  nextend = 2,
  maxExtendMonth = 2,
  minExtendMonth = 1,
  minT = 0,
  minPercValid = 0,
  use.rough = FALSE,
  use.y0 = TRUE,
  ...
)

Arguments

INPUT

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

brks

A list object with the elements of 'fit' and 'dt', returned by season or season_mov, which contains the growing season dividing information.

methods

Fine curve fitting methods, can be one or more of c('AG', 'Beck', 'Elmore', 'Zhang', 'Gu', 'Klos'). Note that 'Gu' and 'Klos' are very slow. f not specified, it will be determined by phenofit options methods_fine.

wFUN

Character or function, weights updating function of fine fitting function. If not specified, it will be determined by phenofit options wFUN_fine.

iters

How many times curve fitting is implemented.

wmin

Double, minimum weigth (i.e. weight of snow, ice and cloud).

nextend

Extend curve fitting window, until nextend good or marginal element are found in previous and subsequent growing season.

maxExtendMonth

Search good or marginal good values in previous and subsequent maxExtendMonth period.

minExtendMonth

Extending perid defined by nextend and maxExtendMonth should be no shorter than minExtendMonth. When all points of the input time-series are good value, then the extending period will be too short. In that situation, we can't make sure the connection between different growing seasons is smoothing.

minT

(optional). If Tn not provided in INPUT, minT will not be used. minT use night temperature Tn to define backgroud value (days with Tn < minT treated as ungrowing season).

minPercValid

(optional, default not use). If the percentage of good and marginal quality points is less than minPercValid, curve fiting result is set to NA.

use.rough

Whether to use rough fitting smoothed time-series as input? If false, smoothed VI by rough fitting will be used for Phenological metrics extraction; If true, original input y will be used (rough fitting is used to divide growing seasons and update weights.

use.y0

boolean. whether to use original y0, which is before the process of check_input.

...

other parameters passed to curve fitting function.

Value

List of phenofit fitting object.

See also

Examples

library(phenofit)
#> Error in library(phenofit): there is no package called ‘phenofit’
data("MOD13A1")
#> Warning: data set ‘MOD13A1’ not found
df <- tidy_MOD13(MOD13A1$dt)
#> Error in tidy_MOD13(MOD13A1$dt): object 'MOD13A1' not found
st <- MOD13A1$st
#> Error in eval(expr, envir, enclos): object 'MOD13A1' not found
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), ]
#> Error in eval(expr, envir, enclos): object 'site' not found
sp <- st[site == sitename, ]
#> Error in eval(expr, envir, enclos): object 'st' not found
south <- sp$lat < 0
#> Error in eval(expr, envir, enclos): object 'sp' not found
nptperyear <- 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
# Rough fitting and growing season dividing brks2 <- season_mov(INPUT, rFUN = smooth_wWHIT, wFUN = wFUN, plotdat = d, IsPlot = IsPlot, print = FALSE, IsPlot.OnlyBad = FALSE)
#> Error in season_mov(INPUT, rFUN = smooth_wWHIT, wFUN = wFUN, plotdat = d, IsPlot = IsPlot, print = FALSE, IsPlot.OnlyBad = FALSE): object 'INPUT' not found
# Fine fitting fit <- curvefits( INPUT, brks2, methods = c("AG", "Beck", "Elmore", "Zhang"), #,"klos", "Gu" wFUN = wFUN, nextend = 2, maxExtendMonth = 2, minExtendMonth = 1, minPercValid = 0.2)
#> Error in curvefits(INPUT, brks2, methods = c("AG", "Beck", "Elmore", "Zhang"), wFUN = wFUN, nextend = 2, maxExtendMonth = 2, minExtendMonth = 1, minPercValid = 0.2): object 'INPUT' not found