Continous Wavelet Transform (CWT)¶
This section describes functions used to perform single continous wavelet transforms.
Single level - cwt
¶
-
pywt.
cwt
(data, scales, wavelet)¶ One dimensional Continuous Wavelet Transform.
Parameters: data : array_like
Input signal
scales : array_like
scales to use
wavelet : Wavelet object or name
Wavelet to use
sampling_period : float
Sampling period for frequencies output (optional)
Returns: coefs : array_like
Continous wavelet transform of the input signal for the given scales and wavelet
frequencies : array_like
if the unit of sampling period are seconds and given, than frequencies are in hertz. Otherwise Sampling period of 1 is assumed.
Notes
Size of coefficients arrays depends on the length of the input array and the length of given scales.
Examples
>>> import pywt >>> import numpy as np >>> import matplotlib.pyplot as plt >>> x = np.arange(512) >>> y = np.sin(2*np.pi*x/32) >>> coef, freqs=pywt.cwt(y,np.arange(1,129),'gaus1') >>> plt.matshow(coef) >>> plt.show() ---------- >>> import pywt >>> import numpy as np >>> import matplotlib.pyplot as plt >>> t = np.linspace(-1, 1, 200, endpoint=False) >>> sig = np.cos(2 * np.pi * 7 * t) + np.real(np.exp(-7*(t-0.4)**2)*np.exp(1j*2*np.pi*2*(t-0.4))) >>> widths = np.arange(1, 31) >>> cwtmatr, freqs = pywt.cwt(sig, widths, 'mexh') >>> plt.imshow(cwtmatr, extent=[-1, 1, 1, 31], cmap='PRGn', aspect='auto', ... vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max()) >>> plt.show()