windowed_scalogram: Windowed scalograms of a signal

View source: R/windowed_scalogram.R

windowed_scalogramR Documentation

Windowed scalograms of a signal

Description

This function computes the normalized windowed scalograms of a signal for the scales given. It is computed using time windows with radius windowrad centered at a vector of central times with increment of time delta_t. It is important to note that the notion of scalogram here is analogous to the spectrum of the Fourier transform. It gives the contribution of each scale to the total energy of the signal. For each scale s and central time tc, it is defined as the square root of the integral of the squared modulus of the wavelet transform w.r.t the time variable t, i.e.

WS_{windowrad}(tc,s):= (integral_{tc-windowrad}^{tc+windowrad}|Wf(t,s)|^2 dt)^{1/2}.

"Normalized" means that the windowed scalograms are divided by the square root of the length of the respective time windows in order to be comparable between them.

Usage

windowed_scalogram(signal,
                          dt = 1,
                          scales = NULL,
                          powerscales = TRUE,
                          windowrad = NULL,
                          delta_t = NULL,
                          wname = c("MORLET", "DOG", "PAUL", "HAAR", "HAAR2"),
                          wparam = NULL,
                          waverad = NULL,
                          border_effects = c("BE", "INNER", "PER", "SYM"),
                          energy_density = TRUE,
                          makefigure = TRUE,
                          time_values = NULL,
                          figureperiod = TRUE,
                          xlab = "Time",
                          ylab = NULL,
                          main = "Windowed Scalogram",
                          zlim = NULL)

Arguments

signal

A vector containing the signal whose windowed scalogram is wanted.

dt

Numeric. The time step of the signal.

scales

A vector containing the wavelet scales at wich the windowed scalograms are computed. This can be either a vector with all the scales or, following Torrence and Compo 1998, a vector of 3 elements with the minimum scale, the maximum scale and the number of suboctaves per octave. In the first case, powerscales must be FALSE if the given scales are not power 2 scales. In the second case, powerscales must be TRUE in order to construct power 2 scales using a base 2 logarithmic scale). If scales is NULL, they are automatically constructed.

powerscales

Logical. It must be TRUE (default) only in these cases:

  • If scales are power 2 scales, i.e. they use a base 2 logarithmic scale.

  • If we want to construct power 2 scales automatically. In this case, scales must be NULL.

  • If we want to construct power 2 scales from scales. In this case, length(scales) must be 3.

Otherwise, it must be FALSE.

windowrad

Integer. Time radius for the windows, measured in dt. By default, it is set to ceiling(length(signal) / 20).

delta_t

Integer. Increment of time for the construction of windows central times, measured in dt. By default, it is set to ceiling(length(signal) / 256).

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 √{2} for Morlet and DoG, 1/√{2} for Paul and 0.5 for Haar.

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.

  • "BE": With border effects, padding time series with zeroes.

  • "INNER": Normalized inner scalogram with security margin adapted for each different scale. Although there are no border effects, it is shown as a regular COI the zone in which the length of J(s) (see Benítez et al. 2010) is smaller and it has to be normalized.

  • "PER": With border effects, using boundary wavelets (periodization of the original time series).

  • "SYM": With border effects, using a symmetric catenation of the original time series.

energy_density

Logical. If TRUE (default), divide the scalograms by the square root of the scales for convert them into energy density.

makefigure

Logical. If TRUE (default), a figure with the scalograms is plotted.

time_values

A numerical vector of length length(signal) containing custom time values for the figure. If NULL (default), it will be computed starting at 0.

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 figureperiod if length(scales) > 1, or "Windowed Scalogram" if length(scales) == 1.

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:

  • wsc: A matrix of size length(tcentral) x length(scales) containing the values of the windowed scalograms at each scale and at each time window.

  • tcentral: The vector of central times at which the windows are centered.

  • scales: The vector of the scales.

  • windowrad: Radius for the time windows, measured in dt.

  • fourierfactor: A factor for converting scales into periods.

  • coi_maxscale: A vector of length length(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.

R. Benítez, V. J. Bolós, M. E. Ramírez. A wavelet-based tool for studying non-periodicity. Comput. Math. Appl. 60 (2010), no. 3, 634-641.

Examples

dt <- 0.1
time <- seq(0, 50, dt)
signal <- c(sin(pi * time), sin(pi * time / 2))
wscalog <- windowed_scalogram(signal = signal, dt = dt)



wavScalogram documentation built on Dec. 28, 2022, 2:06 a.m.