Learn R Programming

phenofit (version 0.2.5-2)

curvefits: Fine Curve fitting

Description

Fine Curve fitting for INPUT time-series.

Usage

curvefits(INPUT, brks, wFUN = wTSM, iters = 2, wmin = 0.2,
  nextend = 2, maxExtendMonth = 3, minExtendMonth = 1, minT = 0,
  methods = c("AG", "Beck", "Elmore", "Gu", "Klos", "Zhang"),
  minPercValid = 0.2, print = TRUE, use.rough = FALSE, ...)

Arguments

INPUT

A list object with the elements of 't', 'y', 'w', 'Tn' (option) 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.

wFUN

weights updating function, can be one of wTSM(), wChen(), wBisquare() and wSELF().

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

Double, use night temperature Tn to define backgroud value. Tn < minT is treated as ungrowing season.

methods

Fine curve fitting methods, can be one or more of c('AG', 'Beck', 'Elmore', 'Gu', 'Klos', 'Zhang').

minPercValid

If the percentage of good and marginal quality points is less than minPercValid, curve fiting result is set to NA.

print

Whether to print progress information?

use.rough

Whether to use rough fitting smoothed time-series as input?

...

Other parameters will be ignore.

Value

fits Multiple phenofit object.

Examples

Run this code
# NOT RUN {
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)
# Rough fitting and growing season dividing
brks2 <- season_mov(INPUT,
    rFUN = wWHIT, wFUN = wFUN,
    plotdat = d, IsPlot = IsPlot, print = FALSE, IsPlot.OnlyBad = FALSE)
# 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,
    print = TRUE, verbose = FALSE)
# }

Run the code above in your browser using DataLab