I have a signal sampled at 128 Hz. I used to extract features with the spectrogram function and I decided to upgrade my algorithm and I'm trying to analyze it using Continuous Wavelet Transform (pywt.cwt) in python. this function has only 2 outputs: coefficient and frequency, while spectrogram returns the time vector as well. Similar to what is said in theory, the resulting frequency vector has varying differences between each two samples (high density at low frequencies, and vice versa). According to the uncertainty principle, the time vector also has to change its density inversely to the frequency vector, is not it? My understanding is based on the famous graph in the picture attached. If I'm not mistaken, the time vector (that is not returned) is just the original time vector of the signal, meaning the difference between each two adjacent samples is constant. Please help me understand this mismatch.
1 Answer
Similar question here Which time-frequency coefficients does the Wavelet transform compute?
The picture you've shown is used for DWT such as pywt.wavedec
, not CWT.
CWT is a continuous function; it exists at all points in the time-scale plane.
pywt.cwt
produces a 2D array with constant numbers of columns and rows, so it's a regular sampling of the CWT, at whatever scales you specify, for every sample of the input:
shape(y)
Out[5]: (512,)
shape(freqs)
Out[6]: (128,)
shape(coef)
Out[7]: (128, 512)
I think the DWT's coefficients contain just enough information to reproduce the original exactly with an inverse DWT, while the CWT output has a lot of redundant information and is maybe missing some information.
-
$\begingroup$ I'm looking for an alternative for the STFT (spectrogram plot) by using some kind of wavelet transform. I'm not interested in reconstructing the signal in time domain. I only what to get the scalogram plot as in the example in Mathworks for the cwt function ('Continuous Wavelet Transform of Two Sine Waves'). can tou tell me which transform will work for me? $\endgroup$– pyigalCommented Apr 25, 2017 at 9:49
-
$\begingroup$ @pyigal Well that's a CWT, but
pywt
doesn't seem to have the Morse wavelet used in that example. Looks similar to complex Morlet? $\endgroup$– endolithCommented Apr 25, 2017 at 14:30