I am looking to draw a time-frequency signal with a discrete time signal (sampling step = 0.001 sec). I am using Python and the Scipy.signal library. I use the cwt function (data, wavelet, width), which returns a matrix to do a continuous wavelet transform, with a complex marlet wavelet (or Gabor wavelet). Unfortunately, documentation on this use is not enough. The best I found: - this for Matlab (I try to find the same timeline result), but I naturally do not have access to the same functions, - and this , which explain what a continuous wavelet transform is, without details wavelet parameters.
First step: Get a zoom signal. In doubt, I directly linked the "width" array to an array of possible different scales. Because, I do not understand what the width of the parameter is, if it is not scale. Perhaps you will tell me "its width of your current wavelet"! But even now I’m not sure how wide the links are with the 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 width = 4 * pi * scale (width = window width). But when I draw bursts, the scale increases, the visual width of the wavelet decreases more ...
My second problem is to find and draw an equivalent with frequency. In the literature I find this formula: Fa = Fc / (s * delta), where Fa is the final frequency, Fc is the center wavelet frequency in Hz, s is the scale and delta of the sampling period. So, ok for the scale (if I find a link with a width) and delta (= 0.001 sec), but its more complicated with the center frequency of the wavelet. In the meager documentation, I find that: "The main frequency of this wavelet [wavelet memory] in Hz is determined by the expression f = 2 * s * w * r / M, where r is the sampling frequency [s here. Scaling factor, window from -s * 2 * pi to + s * 2 * pi. The default is 1; w is the width, and M is the wavelet length]. " I think this is the center frequency, right?
thanks
Here is my restored 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