# bruges.filters.wavelets module¶

Seismic wavelets.

copyright: 2021 Agile Geoscience Apache 2.0
bruges.filters.wavelets.berlage(duration, dt, f, n=2, alpha=180, phi=-1.5707963267948966, t=None, return_t=False, sym=None)[source]

Generates a Berlage wavelet with a peak frequency f. Implements

$w(t) = AH(t) t^n \mathrm{e}^{-lpha t} \cos(2 \pi f_0 t + \phi_0)$

as described in Aldridge, DF (1990), The Berlage wavelet, GEOPHYSICS 55 (11), p 1508-1511. Berlage wavelets are causal, minimum phase and useful for modeling marine airgun sources.

If you pass a 1D array of frequencies, you get a wavelet bank in return.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (often one of 0.001, 0.002, or 0.004). f (array-like) – Centre frequency of the wavelet in Hz. If a sequence is passed, you will get a 2D array in return, one row per frequency. n (float) – The time exponent; non-negative and real. alpha (float) – The exponential decay factor; non-negative and real. phi (float) – The phase. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. ndarray. Berlage wavelet(s) with centre frequency f sampled on t. If you passed return_t=True then a tuple of (wavelet, t) is returned.
bruges.filters.wavelets.cosine(duration, dt, f, t=None, return_t=False, taper='gaussian', sigma=None, sym=None)[source]

With the default Gaussian window, equivalent to a ‘modified Morlet’ also sometimes called a ‘Gabor’ wavelet. The bruges.filters.gabor function returns a similar shape, but with a higher mean frequancy, somewhere between a Ricker and a cosine (pure tone).

If you pass a 1D array of frequencies, you get a wavelet bank in return.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (often one of 0.001, 0.002, or 0.004). f (array-like) – Dominant frequency of the wavelet in Hz. If a sequence is passed, you will get a 2D array in return, one row per frequency. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. taper (str or function) – The window or tapering function to apply. To use one of NumPy’s functions, pass ‘bartlett’, ‘blackman’ (the default), ‘hamming’, or ‘hanning’; to apply no tapering, pass ‘none’. To apply your own function, pass a function taking only the length of the window and returning the window function. sigma (float) – Width of the default Gaussian window, in seconds. Defaults to 1/8 of the duration. ndarray. sinc wavelet(s) with centre frequency f sampled on t. If you passed return_t=True then a tuple of (wavelet, t) is returned.
bruges.filters.wavelets.gabor(duration, dt, f, t=None, return_t=False, sym=None)[source]

Generates a Gabor wavelet with a peak frequency f0 at time t.

https://en.wikipedia.org/wiki/Gabor_wavelet

If you pass a 1D array of frequencies, you get a wavelet bank in return.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (often one of 0.001, 0.002, or 0.004). f (array-like) – Centre frequency of the wavelet in Hz. If a sequence is passed, you will get a 2D array in return, one row per frequency. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. ndarray. Gabor wavelet(s) with centre frequency f sampled on t. If you passed return_t=True then a tuple of (wavelet, t) is returned.
bruges.filters.wavelets.generalized(duration, dt, f, u=2, t=None, return_t=False, imag=False, sym=None)[source]

Wang’s generalized wavelet, of which the Ricker is a special case where u = 2. The parameter u is the order of the time-domain derivative, which can be a fractional derivative.

As given by Wang (2015), Generalized seismic wavelets. GJI 203, p 1172-78. DOI: https://doi.org/10.1093/gji/ggv346. I am using the (more accurate) frequency domain method (eq 4 in that paper).

Parameters: duration (float) – The length of the wavelet, in s. dt (float) – The time sample interval in s. f (float or array-like) – The frequency or frequencies, in Hertz. u (float or array-like) – The fractional derivative parameter u. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – Whether to return the time basis array. center (bool) – Whether to center the wavelet on time 0. imag (bool) – Whether to return the imaginary component as well. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. ndarray. If f and u are floats, the resulting wavelet has duration/dt = A samples. If you give f as an array of length M and u as an array of length N, then the resulting wavelet bank will have shape (M, N, A). If f or u are floats, their size will be 1, and they will be squeezed out: the bank is always squeezed to its minimum number of dimensions. If you passed return_t=True then a tuple of (wavelet, t) is returned.
bruges.filters.wavelets.klauder(duration, dt, f, autocorrelate=True, t=None, return_t=False, taper='blackman', sym=None, **kwargs)[source]

By default, gives the autocorrelation of a linear frequency modulated wavelet (sweep). Uses scipy.signal.chirp, adding dimensions as necessary.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – is the sample interval in seconds (usually 0.001, 0.002, or 0.004) f (array-like) – Upper and lower frequencies. Any sequence like (f1, f2). A list of lists will create a wavelet bank. autocorrelate (bool) – Whether to autocorrelate the sweep(s) to create a wavelet. Default is True. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. taper (str or function) – The window or tapering function to apply. To use one of NumPy’s functions, pass ‘bartlett’, ‘blackman’ (the default), ‘hamming’, or ‘hanning’; to apply no tapering, pass ‘none’. To apply your own function, pass a function taking only the length of the window and returning the window function. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. **kwargs – Further arguments are passed to scipy.signal.chirp. They are method (‘linear’,’quadratic’,’logarithmic’), phi (phase offset in degrees), and vertex_zero. The waveform. If you passed return_t=True then a tuple of (wavelet, t) is returned. ndarray
bruges.filters.wavelets.ormsby(duration, dt, f, t=None, return_t=False, sym=None)[source]

The Ormsby wavelet requires four frequencies which together define a trapezoid shape in the spectrum. The Ormsby wavelet has several sidelobes, unlike Ricker wavelets.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (usually 0.001, 0.002, or 0.004). f (array-like) – Sequence of form (f1, f2, f3, f4), or list of lists of frequencies, which will return a 2D wavelet bank. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. A vector containing the Ormsby wavelet, or a bank of them. If you passed return_t=True then a tuple of (wavelet, t) is returned. ndarray
bruges.filters.wavelets.ormsby_fft(duration, dt, f, P=(0, 0), return_t=True, sym=True)[source]

Non-white Ormsby, with arbitary amplitudes.

Can use as many points as you like. The power of f1 and f4 is assumed to be 0, so you only need to provide p2 and p3 (the corners). (You can actually provide as many f points as you like, as long as there are n - 2 matching p points.)

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (usually 0.001, 0.002, or 0.004). f (array-like) – Sequence of form (f1, f2, f3, f4), or list of lists of frequencies, which will return a 2D wavelet bank. P (tuple) – The power of the f2 and f3 frequencies, in relative dB. (The magnitudes of f1 and f4 are assumed to be -∞ dB, i.e. a magnitude of 0.) The default power values of (0, 0) results in a trapezoidal spectrum and a conventional Ormsby wavelet. Pass, e.g. (0, -15) for a ‘pink’ wavelet, with more energy in the lower frequencies. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. A vector containing the Ormsby wavelet, or a bank of them. If you passed return_t=True then a tuple of (wavelet, t) is returned. ndarray
bruges.filters.wavelets.ricker(duration, dt, f, t=None, return_t=False, sym=None)[source]

Also known as the mexican hat wavelet, models the function:

$A = (1 - 2 \pi^2 f^2 t^2) e^{-\pi^2 f^2 t^2}$

If you pass a 1D array of frequencies, you get a wavelet bank in return.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (often one of 0.001, 0.002, or 0.004). f (array-like) – Centre frequency of the wavelet in Hz. If a sequence is passed, you will get a 2D array in return, one row per frequency. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. ndarray. Ricker wavelet(s) with centre frequency f sampled on t. If you passed return_t=True then a tuple of (wavelet, t) is returned.
bruges.filters.wavelets.rotate_phase(w, phi, degrees=False)[source]

Performs a phase rotation of wavelet or wavelet bank using:

$A = w(t)\cos(\phi) - h(t)\sin(\phi)$

where w(t) is the wavelet and h(t) is its Hilbert transform.

The analytic signal can be written in the form S(t) = A(t)exp(j*theta(t)) where A(t) = magnitude(hilbert(w(t))) and theta(t) = angle(hilbert(w(t)) then a constant phase rotation phi would produce the analytic signal S(t) = A(t)exp(j*(theta(t) + phi)). To get the non analytic signal we take real(S(t)) == A(t)cos(theta(t) + phi) == A(t)(cos(theta(t))cos(phi) - sin(theta(t))sin(phi)) <= trig identity == w(t)cos(phi) - h(t)sin(phi)

Parameters: w (ndarray) – The wavelet vector, can be a 2D wavelet bank. phi (float) – The phase rotation angle (in radians) to apply. degrees (bool) – If phi is in degrees not radians. The phase rotated signal (or bank of signals).
bruges.filters.wavelets.sinc(duration, dt, f, t=None, return_t=False, taper='blackman', sym=None)[source]

sinc function centered on t=0, with a dominant frequency of f Hz.

If you pass a 1D array of frequencies, you get a wavelet bank in return.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – The sample interval in seconds (often one of 0.001, 0.002, or 0.004). f (array-like) – Dominant frequency of the wavelet in Hz. If a sequence is passed, you will get a 2D array in return, one row per frequency. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. taper (str or function) – The window or tapering function to apply. To use one of NumPy’s functions, pass ‘bartlett’, ‘blackman’ (the default), ‘hamming’, or ‘hanning’; to apply no tapering, pass ‘none’. To apply your own function, pass a function taking only the length of the window and returning the window function. ndarray. sinc wavelet(s) with centre frequency f sampled on t. If you passed return_t=True then a tuple of (wavelet, t) is returned.
bruges.filters.wavelets.sweep(duration, dt, f, autocorrelate=True, t=None, return_t=False, taper='blackman', sym=None, **kwargs)

By default, gives the autocorrelation of a linear frequency modulated wavelet (sweep). Uses scipy.signal.chirp, adding dimensions as necessary.

Parameters: duration (float) – The length in seconds of the wavelet. dt (float) – is the sample interval in seconds (usually 0.001, 0.002, or 0.004) f (array-like) – Upper and lower frequencies. Any sequence like (f1, f2). A list of lists will create a wavelet bank. autocorrelate (bool) – Whether to autocorrelate the sweep(s) to create a wavelet. Default is True. t (array-like) – The time series to evaluate at, if you don’t want one to be computed. If you pass t then duration and dt will be ignored, so we recommend passing None for those arguments. return_t (bool) – If True, then the function returns a tuple of wavelet, time-basis. taper (str or function) – The window or tapering function to apply. To use one of NumPy’s functions, pass ‘bartlett’, ‘blackman’ (the default), ‘hamming’, or ‘hanning’; to apply no tapering, pass ‘none’. To apply your own function, pass a function taking only the length of the window and returning the window function. sym (bool) – If True (default behaviour before v0.5) then the wavelet is forced to have an odd number of samples and the central sample is at 0 time. **kwargs – Further arguments are passed to scipy.signal.chirp. They are method (‘linear’,’quadratic’,’logarithmic’), phi (phase offset in degrees), and vertex_zero. The waveform. If you passed return_t=True then a tuple of (wavelet, t) is returned. ndarray