scipy python中利用连续小波变换生成信号尺度图

kmpatx3s  于 2022-11-10  发布在  Python
关注(0)|答案(1)|浏览(141)

我想为我的数组(7680,)生成标度图。我在这个网站上工作https://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.signal.cwt.html我不知道如何为我的数组获得这个方程scipy.signal.cwt(data, wavelet, widths)的参数。

inn6fuwd

inn6fuwd1#


# a rough solution here

from scipy import signal
y,sr=librosa.load("your audio  file.wav")
widths = np.arange(1, 128) # scales for morlet wavelet 
cwtmatr = signal.cwt(y, signal.morlet, widths) # the second parameter is where we are selecting a mother wavelet and the widths defines how many alterations on the mother wavelet needs to be performed to analyse the signal from different frequency resolutions, you should read more about them. 
plt.imshow(abs(cwtmatr), extent=[-1, 1, 31, 1],cmap='plasma', aspect='auto',
           vmax=abs(cwtmatr).max(),
           vmin=-abs(cwtmatr).min()) # finally we plot the scalogram
plt.show()

pywavelets库更适合于小波分析任务,然后您可以使用matplotlib来绘制尺度图。

相关问题