0
$\begingroup$

I'm attempting to perform multi-resolution analysis via Continuous-Wavelet Transform (CWT) using Pywavelets. I've heard that CWT is supposed to be superior to STFT due to varying frequency content as a function of the time-window.

My test signal is two sinusoids of 1Hz and 5Hz, each lasting 10 seconds (see picture): f=np.sin(2.*np.pi*t)*((t>=10)&(t<=20))+np.sin(2*np.pi*5*t)*((t>=30)&(t<=40)). The sampling period is 20Hz.

Time Domain

Using Pywavelets, I perform the CWT as follows with the resulting spectrogram:

scales = np.arange(0.6,65,step=0.2)
coef, freqs=pywt.cwt(f,scales,'cgau1', sampling_period=dT)

CWT

As you can see the frequency resolution is quite lousy, and the peak (complex magnitude) doesn't even seem to line up at 5Hz for the second segment.

In contrast, a STFT using the Gaussian window with a standard deviation of 5 results in much sharper frequency resolution (at the expense of time sharpness):

STFT

Am I doing something here? I'm willing to sacrifice time resolution but I do need to sharpen up the frequency.

$\endgroup$
0
$\begingroup$

The CWT is not, per se, superior to STFT. Due to its variations in scale, it can be better, for instance, when:

  • you address natural signals where transients are shorter than more stationary parts,
  • you do not know the appropriate scale of observation.

which is neither the case from your signal: precise frequency on the same support.

On the one hand, you can work with a continuous wavelet with more oscillations, and better refine the scales and voices.

On the other hand, there are so-called STFT with windows whose width vary with frequency.

Add-ons like hybrid time-scale/time-frequency transformations, reassignement, etc. may be used, but choosing the appropriate tool requires to refine your goal.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.