fill_s2ts: Fill not equally-spaced time series

View source: R/fill_s2ts.R

fill_s2tsR Documentation

Fill not equally-spaced time series

Description

Fill temporal gaps in a time series smoothed with function smooth_s2ts() to obtain homogeneous values (daily or with a regular time step).

Usage

fill_s2ts(
  ts,
  frequency = "daily",
  method = "fmm",
  max_na_days = Inf,
  max_extrapolation = 0.1
)

Arguments

ts

Time series in s2ts format (generated using smooth_s2ts()).

frequency

(optional) One of the followings:

  • daily: daily frequency (default);

  • dop (Days Of Passage): values are returned corresponding to the theoretic Sentinel-2 dates of passage.

method

(optional) Argument passed to spline().

max_na_days

(optional) maximum number of consecutive days with missing values which can be filled (in case of longer time windows with missing data, NA are returned). Default is to fit everything (unless this could lead to errors in case of long NT time windows, currently it is the only way to get subsequent functions working).

max_extrapolation

(optional) Numeric: maximum allowed extrapolation out of original range (relative value). Default is 0.1 (+10%). Set to Inf in order not to set any constraint.

Value

The output time series in tabular format (see extract_ts()).

Author(s)

Luigi Ranghetti, PhD (2020) luigi@ranghetti.info

Examples

#' # Load input data
data("ts_smoothed")

# Gap filling using default parameters (daily)
ts_filled <- fill_s2ts(ts_smoothed)
ts_filled # standard print
head(as.data.frame(ts_filled)) # see content
plot(ts_filled)

# Generate a regular time series using the minimum number of required records
ts_filled_2 <- fill_s2ts(ts_smoothed, frequency = "dop")
print(ts_filled_2, topn = 5) # standard print

ranghetti/sen2rts documentation built on March 31, 2024, 1:18 a.m.