wsd {wavScalogram} | R Documentation |
Windowed Scalogram Difference
Description
This function computes the Windowed Scalogram Difference of two signals. The definition and details can be found in (Bolós et al. 2017).
Usage
wsd(signal1,
signal2,
dt = 1,
scaleparam = NULL,
windowrad = NULL,
rdist = NULL,
delta_t = NULL,
normalize = c("NO", "ENERGY", "MAX", "SCALE"),
refscale = NULL,
wname = c("MORLET", "DOG", "PAUL", "HAAR", "HAAR2"),
wparam = NULL,
waverad = NULL,
border_effects = c("BE", "INNER", "PER", "SYM"),
mc_nrand = 0,
commutative = TRUE,
wscnoise = 0.02,
compensation = 0,
energy_density = TRUE,
parallel = FALSE,
makefigure = TRUE,
time_values = NULL,
figureperiod = TRUE,
xlab = "Time",
ylab = NULL,
main = "-log2(WSD)",
zlim = NULL)
Arguments
signal1 |
A vector containing the first signal. |
signal2 |
A vector containing the second signal (its length should be equal to
that of |
dt |
Numeric. The time step of the signals. |
scaleparam |
A vector of three elements with the minimum scale, the maximum scale and the number of suboctaves per octave for constructing power 2 scales (following Torrence and Compo 1998). If NULL, they are automatically constructed. |
windowrad |
Integer. Time radius for the windows, measured in |
rdist |
Integer. Log-scale radius for the windows measured in suboctaves. By
default, it is set to |
delta_t |
Integer. Increment of time for the construction of windows central
times, measured in |
normalize |
String, equal to "NO", "ENERGY", "MAX" or "SCALE". If "ENERGY", signals are
divided by their respective energies. If "MAX", each signal is divided by the maximum
value attained by its scalogram. In these two cases, |
refscale |
Numeric. The reference scale for |
wname |
A string, equal to "MORLET", "DOG", "PAUL", "HAAR" or "HAAR2". The difference between "HAAR" and "HAAR2" is that "HAAR2" is more accurate but slower. |
wparam |
The corresponding nondimensional parameter for the wavelet function (Morlet, DoG or Paul). |
waverad |
Numeric. The radius of the wavelet used in the computations for the cone
of influence. If it is not specified, it is asumed to be |
border_effects |
String, equal to "BE", "INNER", "PER" or "SYM", which indicates how to manage the border effects which arise usually when a convolution is performed on finite-lenght signals.
|
mc_nrand |
Integer. Number of Montecarlo simulations to be performed in order to determine the 95% and 5% significance contours. |
commutative |
Logical. If TRUE (default) the commutative windowed scalogram difference. Otherwise a non-commutative (but simpler) version is computed (see Bolós et al. 2017). |
wscnoise |
Numeric in If we consider absolute differences this would not happen but, on the other hand, using absolute differences is not appropriate for scalogram values not close to zero. So, the parameter Finally, |
compensation |
Numeric. It is an alternative to |
energy_density |
Logical. If TRUE (default), divide the scalograms by the square
root of the scales for convert them into energy density. Note that it does not affect
the results if |
parallel |
Logical. If TRUE, it uses function |
makefigure |
Logical. If TRUE (default), a figure with the WSD is plotted. |
time_values |
A numerical vector of length |
figureperiod |
Logical. If TRUE (default), periods are used in the figure instead of scales. |
xlab |
A string giving a custom X axis label. |
ylab |
A string giving a custom Y axis label. If NULL (default) the Y label is
either "Scale" or "Period" depending on the value of |
main |
A string giving a custom main title for the figure. |
zlim |
A vector of length 2 with the limits for the z-axis (the color bar). |
Value
A list with the following fields:
-
wsd
: A matrix of sizelength(tcentral)
xlength(scales)
containing the values of the windowed scalogram differences at each scale and at each time window. -
tcentral
: The vector of central times used in the computations of the windowed scalograms. -
scales
: The vector of scales. -
windowrad
: Radius for the time windows of the windowed scalograms, measured indt
. -
rdist
: The log-scale radius for the windows measured in suboctaves. -
signif95
: A logical matrix of sizelength(tcentral)
xlength(scales)
. If TRUE, the corresponding point of thewsd
matrix is in the 95% significance. -
signif05
: A logical matrix of sizelength(tcentral)
xlength(scales)
. If TRUE, the corresponding point of thewsd
matrix is in the 5% significance. -
fourierfactor
: A factor for converting scales into periods. -
coi_maxscale
: A vector of lengthlength(tcentral)
containing the values of the maximum scale from which there are border effects for the respective central time.
References
C. Torrence, G. P. Compo. A practical guide to wavelet analysis. B. Am. Meteorol. Soc. 79 (1998), 61–78.
V. J. Bolós, R. Benítez, R. Ferrer, R. Jammazi. The windowed scalogram difference: a novel wavelet tool for comparing time series. Appl. Math. Comput., 312 (2017), 49-65.
Examples
nt <- 1500
time <- 1:nt
sd_noise <- 0.2 #% In Bolós et al. 2017 Figure 1, sd_noise = 1.
signal1 <- rnorm(n = nt, mean = 0, sd = sd_noise) + sin(time / 10)
signal2 <- rnorm(n = nt, mean = 0, sd = sd_noise) + sin(time / 10)
signal2[500:1000] = signal2[500:1000] + sin((500:1000) / 2)
## Not run:
wsd <- wsd(signal1 = signal1, signal2 = signal2)
## End(Not run)