Reconstruction of Time-Series Records from Their Modes
reconstructTSL.RdAdds up, for each series of the tables of decomposeTSL, the
modes that a selection retains and, unless excluded, the remainder of the
series.
Arguments
- decomposition
The list of tables of
decomposeTSL, as formeasureModesTSL. It is not modified.- selection
A table with the keys and
modeof every mode ofdecomposition, once each, andretained,TRUEorFALSE, as the tableselectionofselectModesTSL. It is not modified.- includeResidue
TRUE, the default, adds the remainder of each series,residueorfitResidual;FALSEleaves it out.
Details
The reconstruction of a series is the sum of its retained modes and, with
includeResidue, its remainder. A series without retained modes sums
zero, and a method without remainder, as decomposeEWT, adds
none. With every mode and the remainder, the result follows the
reconstruction relation of the selected method. For EMD the sum recovers
the input up to rounding. In decomposeEEMD with the divisor
"realizations", it gives the signal plus meanNoise.
The order of the rows of the tables does not intervene.
A partial sum implements the declared selection; neither the sum nor the choice to include a remainder establishes that the result is free of noise.
Value
A named list with one data.table table, reconstruction: the
keys of decomposition, t and s, on the grid and in the
order of signal.
Examples
Time <- seq(0, 9, length.out = 3000)
Signal <- sin(pi * Time) + sin(2 * pi * Time) + sin(6 * pi * Time) +
0.5 * Time
# The same series under three IDs and three components.
TSL <- data.table::rbindlist(lapply(c("AT", "VT", "DT"), function(id) {
data.table::rbindlist(lapply(c("H1", "H2", "UP"), function(ocid) {
data.table::data.table(ID = id, OCID = ocid, t = Time, s = Signal)
}))
}))
Sifting <- list(stopRule = "doubleThreshold")
Decomposition <- decomposeTSL(TSL, method = "decomposeEMD",
control = list(sifting = Sifting),
by = character())
Metrics <- measureModesTSL(Decomposition)$metrics
# A minimum energy fraction of zero retains every mode: with the residue,
# the reconstruction is the signal.
Every <- selectModesTSL(Decomposition, metrics = Metrics,
criterion = list(rule = "energyFraction", minimum = 0,
action = "keep"))
Complete <- reconstructTSL(Decomposition, selection = Every$selection)
max(abs(Complete$reconstruction$s - Decomposition$signal$s))
#> [1] 1.332268e-15
# The modes in [2, 15] Hz, without the residue.
Band <- selectModesTSL(Decomposition, metrics = Metrics,
criterion = list(rule = "band", fMin = 2, fMax = 15,
action = "keep"))
Filtered <- reconstructTSL(Decomposition, selection = Band$selection,
includeResidue = FALSE)
head(Filtered$reconstruction)
#> OCID ID t s
#> <char> <char> <num> <num>
#> 1: H1 AT 0.000000000 -0.8149686
#> 2: H1 AT 0.003001000 -0.7334793
#> 3: H1 AT 0.006002001 -0.6524386
#> 4: H1 AT 0.009003001 -0.5720312
#> 5: H1 AT 0.012004001 -0.4924402
#> 6: H1 AT 0.015005002 -0.4138474