dm_wavelet_coherence: Wavelet coherence between dendrometer and climate series

View source: R/dm_wavelet_coherence.R

dm_wavelet_coherenceR Documentation

Wavelet coherence between dendrometer and climate series

Description

Computes cross-wavelet power and wavelet coherence between dendrometer series and climate variables using WaveletComp::analyze.coherency().

The function:

  • crops dendrometer and climate inputs to their common time window,

  • detects their temporal resolutions,

  • resamples both to the coarser detected resolution,

  • optionally interpolates missing values,

  • optionally uses first differences of the dendrometer series,

  • computes pairwise coherence for all selected tree/climate combinations.

Usage

dm_wavelet_coherence(
  dm,
  clim,
  TreeNum = "all",
  clim_vars = "all",
  source = c("auto", "raw", "detrended", "first_diff"),
  detrended_col = c("detrended_data"),
  dm_fun = c("mean", "max", "min", "sum"),
  clim_funs = "mean",
  na_action = c("interpolate", "fail"),
  loess_span = 0,
  dj = 1/20,
  lowerPeriod = NULL,
  upperPeriod = NULL,
  window.type.t = 1,
  window.type.s = 1,
  window.size.t = 5,
  window.size.s = 1/4,
  make.pval = TRUE,
  make_pval = NULL,
  method = "white.noise",
  n.sim = 10,
  n_sim = NULL,
  verbose = TRUE
)

Arguments

dm

Dendrometer input. Either a data frame with time in the first column or an object of class "dm_detrended".

clim

Climate data frame. The first column must be time; remaining selected columns must be numeric climate variables.

TreeNum

Dendrometer series selector: "all", numeric indices, or character names.

clim_vars

Climate variable selector: "all", numeric indices, or character names.

source

One of "auto", "raw", "detrended", or "first_diff".

detrended_col

For dm_detrended input, which table to use.

dm_fun

Aggregation function for dendrometer resampling: one of "mean", "max", "min", "sum".

clim_funs

Either a single aggregation function applied to all climate variables, or a named character vector such as c(temp = "mean", VPD = "mean", prec = "sum").

na_action

One of "interpolate" or "fail".

loess_span

Detrending span passed to WaveletComp::analyze.coherency(). Use 0 to disable internal loess detrending.

dj

Frequency resolution passed to WaveletComp::analyze.coherency().

lowerPeriod

Optional lower period in native analysis units.

upperPeriod

Optional upper period in native analysis units.

window.type.t

Time-direction smoothing window type.

window.type.s

Scale-direction smoothing window type.

window.size.t

Time-direction smoothing window size.

window.size.s

Scale-direction smoothing window size.

make.pval

Logical. If TRUE, compute p-values.

make_pval

Optional alias for make.pval.

method

Surrogate generation method for p-values.

n.sim

Number of simulations.

n_sim

Optional alias for n.sim.

verbose

Logical.

Details

WaveletComp::analyze.coherency() expects two aligned series in one data frame plus a dt value in the analysis time units, and returns cross-wavelet power, coherence, phase angles, p-values, Fourier periods, and cone-of-influence fields.

Value

An object of class "dm_wavelet_coherence".

Examples


wc <- dm_wavelet_coherence(
  dm = gf_nepa17,
  clim = ktm_clim_hourly,
  TreeNum = 1,
  clim_vars = c("temp", "VPD"),
  source = "raw",
  dm_fun = "mean",
  clim_funs = c(temp = "mean", VPD = "mean"),
  loess_span = 0,
  make.pval = TRUE,
  n.sim = 10,
  verbose = FALSE
)

plot(wc)
plot(wc, type = "cross_power")
plot(wc, type = "average_coherence")
plot(wc, type = "phase")
plot(wc, type = "series")



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