python小波变换_使用Scipy.signal(Python)进行连续小波变换:cwt()函数中的参数“ widths”是什么? (时间频率)...

本文探讨如何使用Python的Scipy.signal库进行连续小波变换(CWT),特别关注Morlet波形参数的选择(如宽度与尺度),并解释了频率与尺度的关系。通过实例代码和参数解释,帮助读者解决在CWT中遇到的困惑,包括波宽与尺度的链接以及中心频率的计算。
摘要由CSDN通过智能技术生成

1586010002-jmsa.png

I search to draw a time-frequency signal with a discrete temporal signal (sampling step = 0.001sec). I use Python and the library Scipy.signal. I use the function cwt(data, wavelet, widths), which returns a matrix, to do a continuous wavelet transform, with the complex morlet wavelet (or gabor wavelet). Unfortunately, there is not a lot of documentations of this use. The best which I found are:

- this for Matlab (I try to find the same scale-time result) but I have naturally not access to the same fonctions,

- And this which explain what is continuous wavelet transform, without details of wavelet parameters.

First step: Obtain a scale-translation signal. In doubt, I associated directly the array “widths” with the array of the possible different scales. Because, I don’t understood what is parameter width if it’s not scale. Perhaps, you would tell me “it’s the width of your current wavelet”! But, even now, I'm not sure how link width with scale… In the Morlet documentation in Scipy, it seems that the link could be: "s: Scaling factor, windowed from -s*2*pi to +s*2*pi", so, I thought that width = 4*pi*scale (width=width of the window). But when I draw the wavelets, more scale increases, more the visual width of the wavelet decreases...

My second problem is to find and draw the equivalent with frequency. In literature, I find this formula: Fa = Fc / (s*delta), where Fa is the final frequency, Fc the center frequency of a wavelet in Hz, s the scale and delta the sampling period. So, ok for scale (if I find the link with the width) and delta (=0.001sec), but it’s more complicated with center frequency of the wavelet. In scipy documentation, I find that: “The fundamental frequency of this wavelet [morlet wavelet] in Hz is given by f = 2*s*w*r / M, where r is the sampling rate [s is here Scaling factor, windowed from -s*2*pi to +s*2*pi. Default is 1; w the width; and M the length of the wavelet].” I think it’s the center frequency, is it?

Thank you

Here my remanied code for cwt():

def MyCWT(data, wavelet, scales):

output = zeros([len(scales), len(data)], dtype=complex)

for ind, scale in enumerate(scales):

window = scale*4*pi*10#Number of points to define correctly the wavelet

waveletLength = min(window, len(data))#Number of points of the wavelet

wavelet_data = wavelet(waveletLength, s=scale)#Need to precise w parameter???

#To see the wavelets:

plot(wavelet_data)

xlabel('time (10^-3 sec)')

ylabel('amplitude')

title('Morlet Wavelet for scale='+str(scale)+'\nwidth='+str(window))

show()

#Concolution to calculate the current line for the current scale:

z = convolve(data, wavelet_data, mode='same')

i = 0

for complexVal in z:

output[ind][i] = complex(complexVal.real, complexVal.imag)

i+=1

return output

解决方案

The widths parameter is an array of width sizes to which the wavelet is stretched to before convolving the wavelet with the data.

You should choose a range starting with a value slightly smaller than your expected signal width, up to slightly larger. The more values you supply, the slower the calculation but the higher the resolution.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值