scatseisnet.wavelet#

Wavelet class and functions.

This module contains the wavelet class and functions to generate wavelets.

Terms of use
Copyright (C) 2023 Léonard Seydoux.

This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program.  If not, see <https://www.gnu.org/licenses/>.

Classes#

ComplexMorletBank

Complex Morlet filter bank.

Functions#

gaussian_window(→ cupy.ndarray)

Gaussian function.

complex_morlet(→ cupy.ndarray)

Complex Morlet wavelet.

Module Contents#

scatseisnet.wavelet.gaussian_window(x: cupy.ndarray, width: float | Sequence[float] | cupy.ndarray) cupy.ndarray[source]#

Gaussian function.

This function can generate a bank of windows at once if the width argument is a vector (and/or amplitude). In this case, it should have a new axis with respect to the time vector to allow for outer product.

Parameters:
  • x (numpy.ndarray or cupy.ndarray) – Input variable, in the same units than the width.

  • width (float or np.ndarray) – Window width (in the same units than the input variable). If an array is provided, the function returns as many windows as the number of elements of this parameter.

  • amplitude (float or np.ndarray, optional) – Window amplitude at maximum (default 1). If this parameter is a vector, it should have the same number of elements than the width.

Returns:

The Gaussian window in the time domain. If the width (and possibly amplitude) argument is a vector, the function returns a matrix with shape (len(width), len(x)).

Return type:

Same type as x.

scatseisnet.wavelet.complex_morlet(x: cupy.ndarray, center: float | Sequence[float] | cupy.ndarray, width: float | Sequence[float] | cupy.ndarray) cupy.ndarray[source]#

Complex Morlet wavelet.

The complex Morlet wavelet is a complex plane wave modulated by a Gaussian window. The oscillatory frequency of the plane wave is the center frequency, and the temporal width of the Gaussian is the width argument.

This function can generate a filter bank at once if the width and center arguments are vectors of the same size. In this case, they should have a new axis with respect to the time vector to allow for outer product.

Parameters:
  • x (numpy.ndarray or cupy.ndarray) – Time vector in seconds.

  • width (float or numpy.ndarray or cupy.ndarray.) – Temporal signal width in seconds.

  • center (float or numpy.ndarray or cupy.ndarray.) – Center frequency in Hertz.

Returns:

The complex Mortlet wavelet in the time domain. If the center and width (and possibly amplitude) arguments are vectors, the function returns a matrix with shape (len(width), len(x)).

Return type:

Same type as x.

class scatseisnet.wavelet.ComplexMorletBank(bins: int, octaves: int = 8, resolution: int = 1, quality: float = 4.0, normalize_wavelet=None, sampling_rate: float = 1.0)[source]#

Complex Morlet filter bank.

bins[source]#
octaves = 8[source]#
resolution = 1[source]#
quality = 4.0[source]#
sampling_rate = 1.0[source]#
wavelets[source]#
spectra[source]#
size[source]#
__repr__() str[source]#

Representation of the filter bank.

__len__() int[source]#

Length of the filter bank.

transform(segment: cupy.ndarray) numpy.ndarray[source]#

Compute the scalogram for a given segment.

Parameters:

segment (numpy.ndarray) – The segment to be transformed of shape (..., channels, bins). The number of bins should be the same as the number of bins of the filter bank.

Returns:

scalogram – The scalograms for all channels with shape (the ellipsis stands for unknown number of input dimensions) n_channels, …, n_filters, n_bins.

Return type:

numpy.ndarray

property times: numpy.ndarray[source]#

Wavelet bank symmetric time vector in seconds.

property frequencies: numpy.ndarray[source]#

Wavelet bank frequency vector in Hertz.

property nyquist: float[source]#

Nyqyust frequency in Hertz.

property shape: tuple[source]#

Filter bank total number of filters.

property ratios: numpy.ndarray[source]#

Wavelet bank ratios.

property scales: numpy.ndarray[source]#

Wavelet bank scaling factors.

property centers: numpy.ndarray[source]#

Wavelet bank center frequencies.

property widths: numpy.ndarray[source]#

Wavelet bank temporal widths.