dm_wavelet_reconstruct: Reconstruct or remove selected cycle components from a...

View source: R/dm_wavelet_reconstruct.R

dm_wavelet_reconstructR Documentation

Reconstruct or remove selected cycle components from a dm_wavelet object

Description

Reconstructs a selected oscillatory component, or a selected period band, from a dm_wavelet object using WaveletComp::reconstruct().

Requested periods are supplied in hours. They are internally converted to the native wavelet period units used when dm_wavelet() was computed, then passed to WaveletComp::reconstruct().

The function supports two modes:

  • mode = "extract" returns the selected cycle or band itself.

  • mode = "remove" returns the original series with the selected cycle or band removed.

Usage

dm_wavelet_reconstruct(
  x,
  series = NULL,
  mode = c("extract", "remove"),
  period_hours = NULL,
  lower_hours = NULL,
  upper_hours = NULL,
  lvl = 0,
  only_sig = TRUE,
  siglvl = 0.05,
  only_coi = FALSE,
  only_ridge = FALSE,
  rescale = FALSE,
  verbose = TRUE
)

Arguments

x

An object of class "dm_wavelet" returned by dm_wavelet().

series

Optional character vector of series names to reconstruct. If NULL, all available series are used.

mode

One of "extract" or "remove".

period_hours

Optional numeric vector of exact periods, in hours, to reconstruct. If supplied, lower_hours and upper_hours are ignored.

lower_hours

Optional lower period bound in hours for band reconstruction.

upper_hours

Optional upper period bound in hours for band reconstruction.

lvl

Minimum wavelet power level to include in the reconstruction.

only_sig

Logical. If TRUE, use wavelet power significance in reconstruction.

siglvl

Significance level used when only_sig = TRUE.

only_coi

Logical. If TRUE, restrict reconstruction to the cone of influence.

only_ridge

Logical. If TRUE, reconstruct from the power ridge only.

rescale

Logical. Passed to WaveletComp::reconstruct().

verbose

Logical. If TRUE, prints a completion message.

Value

An object of class "dm_wavelet_reconstruct" with elements:

call

Matched function call.

series

Selected series names.

mode

Reconstruction mode, either "extract" or "remove".

selection

A list describing the requested selection in hours and in native wavelet units.

results

Named list of WaveletComp::reconstruct() outputs.

reconstructed_long

Tidy table with columns TIME, series, original, reconstructed, difference, and filtered.

used_periods

Per-series table of periods actually used in the reconstruction, in native units and in hours.

filtered_wide

Wide table with TIME in the first column and one filtered series column per selected tree/series.

parent

Minimal metadata copied from the parent dm_wavelet object.

Examples


wv <- dm_wavelet(
  x = gf_nepa17,
  TreeNum = 1:2,
  source = "raw",
  make_pval = TRUE,
  verbose = FALSE
)

# extract circadian component
rec_extract <- dm_wavelet_reconstruct(
  wv,
  mode = "extract",
  lower_hours = 20,
  upper_hours = 28,
  only_sig = TRUE
)

# remove circadian component
rec_remove <- dm_wavelet_reconstruct(
  wv,
  mode = "remove",
  lower_hours = 20,
  upper_hours = 28,
  only_sig = TRUE
)

head(rec_extract$filtered_wide)
head(rec_remove$filtered_wide)



dendRoAnalyst documentation built on May 20, 2026, 5:07 p.m.