Hello
I am seeing a factor-of-two error when I try to create a spectrogram using pywt.cwt.
MWE:
timeVec=np.linspace(0,10,1000)
srate=1/(timeVec[1]-timeVec[0])
freqVec=np.linspace(1,10,1000)
signal=np.sin(2*np.pi*freqVec*timeVec)
freqs=np.linspace(0.1,20,30)
widths = np.sort(pywt.frequency2scale('cmor1.5-1.0',freqs/srate))
cwtmatr,cwtFreqs = pywt.cwt(signal, widths, 'cmor1.5-1.0',sampling_period=1/srate)
plt.imshow(np.abs(cwtmatr), extent=[0, 10, 1, 30], cmap='PRGn', aspect='auto',
vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
plt.yticks(ticks=np.arange(len(widths))+1,labels=np.round(freqs,1));
plt.colorbar()
plt.ylabel('Frequency (Hz)')
This shows the frequency rising linearly to 20 Hz, even though it is clearly only rising to 10 hz in the signal definition. Naturally, if I scale the frequencies by the Nyquist frequency instead of the sample rate, everything works out, but that seems to be a mistake?
If have tried it with multiple different wavelets now.
Regards
Kaare Mikkelsen