# `signal.wavelets`¶

## Module Contents¶

### Functions¶

 `daub`(p) The coefficients for the FIR low-pass filter producing Daubechies wavelets. `qmf`(hk) Return high-pass qmf filter from low-pass `cascade`(hk,J=7) Return (x, phi, psi) at dyadic points `K/2**J` from filter coefficients. `morlet`(M,w=5.0,s=1.0,complete=True) Complex Morlet wavelet. `ricker`(points,a) Return a Ricker wavelet, also known as the “Mexican hat wavelet”. `cwt`(data,wavelet,widths) Continuous wavelet transform.
`daub`(p)

The coefficients for the FIR low-pass filter producing Daubechies wavelets.

p>=1 gives the order of the zero at f=1/2. There are 2p filter coefficients.

p : int
Order of the zero at f=1/2, can have values from 1 to 34.
daub : ndarray
Return
`qmf`(hk)

Return high-pass qmf filter from low-pass

hk : array_like
Coefficients of high-pass filter.
`cascade`(hk, J=7)

Return (x, phi, psi) at dyadic points `K/2**J` from filter coefficients.

hk : array_like
Coefficients of low-pass filter.
J : int, optional
Values will be computed at grid points `K/2**J`. Default is 7.
x : ndarray
The dyadic points `K/2**J` for `K=0...N * (2**J)-1` where `len(hk) = len(gk) = N+1`.
phi : ndarray
The scaling function `phi(x)` at x: `phi(x) = sum(hk * phi(2x-k))`, where k is from 0 to N.
psi : ndarray, optional
The wavelet function `psi(x)` at x: `phi(x) = sum(gk * phi(2x-k))`, where k is from 0 to N. psi is only returned if gk is not None.

The algorithm uses the vector cascade algorithm described by Strang and Nguyen in “Wavelets and Filter Banks”. It builds a dictionary of values and slices for quick reuse. Then inserts vectors into final vector at the end.

`morlet`(M, w=5.0, s=1.0, complete=True)

Complex Morlet wavelet.

M : int
Length of the wavelet.
w : float, optional
Omega0. Default is 5
s : float, optional
Scaling factor, windowed from `-s*2*pi` to `+s*2*pi`. Default is 1.
complete : bool, optional
Whether to use the complete or the standard version.

morlet : (M,) ndarray

scipy.signal.gausspulse

The standard version:

```pi**-0.25 * exp(1j*w*x) * exp(-0.5*(x**2))
```

This commonly used wavelet is often referred to simply as the Morlet wavelet. Note that this simplified version can cause admissibility problems at low values of w.

The complete version:

```pi**-0.25 * (exp(1j*w*x) - exp(-0.5*(w**2))) * exp(-0.5*(x**2))
```

This version has a correction term to improve admissibility. For w greater than 5, the correction term is negligible.

Note that the energy of the return wavelet is not normalised according to s.

The fundamental frequency of this wavelet in Hz is given by `f = 2*s*w*r / M` where r is the sampling rate.

Note: This function was created before cwt and is not compatible with it.

`ricker`(points, a)

Return a Ricker wavelet, also known as the “Mexican hat wavelet”.

It models the function:

`A (1 - x^2/a^2) exp(-x^2/2 a^2)`,

where `A = 2/sqrt(3a)pi^1/4`.

points : int
Number of points in vector. Will be centered around 0.
a : scalar
Width parameter of the wavelet.
vector : (N,) ndarray
Array of length points in shape of ricker curve.
```>>> from scipy import signal
>>> import matplotlib.pyplot as plt
```
```>>> points = 100
>>> a = 4.0
>>> vec2 = signal.ricker(points, a)
>>> print(len(vec2))
100
>>> plt.plot(vec2)
>>> plt.show()
```
`cwt`(data, wavelet, widths)

Continuous wavelet transform.

Performs a continuous wavelet transform on data, using the wavelet function. A CWT performs a convolution with data using the wavelet function, which is characterized by a width parameter and length parameter.

data : (N,) ndarray
data on which to perform the transform.
wavelet : function
Wavelet function, which should take 2 arguments. The first argument is the number of points that the returned vector will have (len(wavelet(length,width)) == length). The second is a width parameter, defining the size of the wavelet (e.g. standard deviation of a gaussian). See ricker, which satisfies these requirements.
widths : (M,) sequence
Widths to use for transform.
cwt: (M, N) ndarray
Will have shape of (len(widths), len(data)).
```length = min(10 * width[ii], len(data))
cwt[ii,:] = signal.convolve(data, wavelet(length,
width[ii]), mode='same')
```
```>>> from scipy import signal
>>> import matplotlib.pyplot as plt
>>> t = np.linspace(-1, 1, 200, endpoint=False)
>>> sig  = np.cos(2 * np.pi * 7 * t) + signal.gausspulse(t - 0.4, fc=2)
>>> widths = np.arange(1, 31)
>>> cwtmatr = signal.cwt(sig, signal.ricker, widths)
>>> plt.imshow(cwtmatr, extent=[-1, 1, 31, 1], cmap='PRGn', aspect='auto',
...            vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
>>> plt.show()
```