the third argument of scipy.signal.cwt
is widths, which must larger than 1, so change your code to:
scipy.signal.cwt(np.array(c), scipy.signal.morlet, np.arange(.01,.1,.01) * len(c))
题
I'm getting a weird error when attempting to use scipy.signal.cwt:
I have some list c
, and I want to take the continuous wavelet transform like this:
scipy.signal.cwt(np.array(c), scipy.signal.morlet, np.arange(.01,.1,.01))
and I get a weird 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's causing this error?
解决方案
the third argument of scipy.signal.cwt
is widths, which must larger than 1, so change your code to:
scipy.signal.cwt(np.array(c), scipy.signal.morlet, np.arange(.01,.1,.01) * len(c))