Scipy.signal.cwt gets value error in correlate ()

I get a strange error when trying to use scipy.signal.cwt:

I have a list cand I want to take continuous wavelet transform as follows:

scipy.signal.cwt(np.array(c), scipy.signal.morlet, np.arange(.01,.1,.01))

and I get a strange error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-55-5af5e14b96cd> in <module>()
----> 1 sig.cwt(a, sig.morlet, np.arange(.01,.1,.01))

/usr/local/lib/python2.7/site-packages/scipy/signal/wavelets.pyc in cwt(data, wavelet,     widths)
    359         wavelet_data = wavelet(min(10 * width, len(data)), width)
    360         output[ind, :] = convolve(data, wavelet_data,
--> 361                                               mode='same')
    362     return output

/usr/local/lib/python2.7/site-packages/scipy/signal/signaltools.pyc in convolve(in1,     in2, mode)
    270 
    271     if np.iscomplexobj(kernel):
--> 272         return correlate(volume, kernel[slice_obj].conj(), mode)
    273     else:
    274         return correlate(volume, kernel[slice_obj], mode)

/usr/local/lib/python2.7/site-packages/scipy/signal/signaltools.pyc in correlate(in1, in2, mode)
    129         in1zpadded = np.zeros(ps, in1.dtype)
    130         sc = [slice(0, i) for i in in1.shape]
--> 131         in1zpadded[sc] = in1.copy()
    132 
    133         if mode == 'full':

ValueError: could not broadcast input array from shape (66467) into shape (66466)

What causes this error?

+4
source share
1 answer

the third argument scipy.signal.cwtis the width, which must be greater than 1, so change your code to:

scipy.signal.cwt(np.array(c), scipy.signal.morlet, np.arange(.01,.1,.01) * len(c))
+4
source

Source: https://habr.com/ru/post/1537595/


All Articles