View source: R/analyze_wavelet_coherence.R
| analyze_wavelet_coherence | R Documentation |
Computes the cross-wavelet transform and wavelet coherence between two time/depth series using a superlet-based wavelet approach. The function internally interpolates both input series onto a common grid, computes individual wavelet transforms, and derives cross-wavelet power, phase, and coherence with configurable smoothing.
analyze_wavelet_coherence(
data_1,
data_2,
dj = 1/100,
lowerPeriod = 2,
upperPeriod = 1024,
verbose = FALSE,
omega_nr = 8,
n_simulations = 10,
window.type.t = 4,
window.type.s = 4,
abs_window_t = 500,
abs_window_s = 0.5
)
data_1 |
First input dataset as a two-column matrix or data.frame. First column must contain time/depth, second column the signal. |
data_2 |
Second input dataset as a two-column matrix or data.frame.
Must have the same structure as |
dj |
Spacing between discrete scales. Smaller values increase resolution.
Default is |
lowerPeriod |
Lower bound of the period range to analyze. |
upperPeriod |
Upper bound of the period range to analyze. |
verbose |
Logical; if |
omega_nr |
Number of oscillations in the Morlet/superlet wavelet. Controls time-frequency resolution trade-off. |
n_simulations |
Number of simulations (reserved for future significance testing). Currently not used internally. |
window.type.t |
Type of smoothingw indow applied in the time direction. Options: "none", "bar" (Bartlett), "tri" (triangular), "box" (boxcar), "han" (Hanning, default), "ham" (Hamming) or "bla" (Blackman) |
window.type.s |
Type of smoothing window applied in the scale direction. Same options as window.type.t. |
abs_window_t |
Absolute smoothing window size in the time direction (same units as input data). |
abs_window_s |
Absolute smoothing window size in the scale direction (in units of dj). |
A list of class containing: Wave Smoothed cross-wavelet transform (complex) Coherence Wavelet coherence matrix Phase Phase difference between the two signals Coh.avg Average coherence over time Period (m)vector corresponding to scales Scale Wavelet scales dt Time step of interpolated grid dj Scale resolution axis.1 Time/depth axis axis.2 Period axis nc, nr Dimensions of the wavelet matrices x1, y1 Interpolated first dataset x2, y2 Interpolated second dataset
plotting code based on the "analyze.coherency" function of the 'WaveletComp' R package
Torrence, C., and G. P. Compo (1998). A practical guide to wavelet analysis. Bulletin of the American Meteorological Society, 79(1), 61–78.
# Generate two synthetic signals
t <- seq(0, 1000, by = 1)
x1 <- sin(2 * pi * t / 100) + rnorm(length(t), 0, 0.5)
x2 <- sin(2 * pi * t / 100 + pi/4) + rnorm(length(t), 0, 0.5)
data_1 <- cbind(t, x1)
data_2 <- cbind(t, x2)
coh <- analyze_wavelet_coherence(
data_1 = data_1,
data_2 = data_2,
lowerPeriod = 2,
upperPeriod = 256
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.