curvefits: Fine Curve fitting

Description Usage Arguments Value Examples

View source: R/curvefits.R

Description

Fine Curve fitting for INPUT time-series.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
curvefits(
  INPUT,
  brks,
  wFUN = wTSM,
  iters = 2,
  wmin = 0.1,
  nextend = 2,
  maxExtendMonth = 2,
  minExtendMonth = 1,
  minT = 0,
  methods = c("AG", "Beck", "Elmore", "Gu", "Klos", "Zhang"),
  minPercValid = 0.2,
  print = TRUE,
  use.rough = FALSE,
  use.y0 = TRUE,
  ...
)

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?

use.y0

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

...

Other parameters will be ignore.

Value

fits Multiple phenofit object.

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
27
28
29
30
31
32
33
34
35
36
37
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 = smooth_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)

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