PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
1.97k stars 460 forks source link

A question about cwt when I try to do Time-Frenquency analysis #633

Closed etoilestar closed 1 year ago

etoilestar commented 2 years ago

hello, here is my code:

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,128),'gaus1')
print(freqs.shape, np.argmax(abs(coef), 0).shape)
print(freqs[np.argmax(abs(coef), 0)])
plt.contourf(range(len(y)), freqs, abs(coef))
plt.ylabel(u"freq(Hz)")
plt.xlabel(u"time(s)")
plt.subplots_adjust(hspace=0.4)
plt.show()

I guess I might get the result for pi/16, but it doesn't, could you give me some suggestion

rgommers commented 1 year ago

I'm sorry, we have lots of demos/examples like this in the docs. We can't help with debugging. Hope you figured it out!