2014-04-22 38 views
4

嘗試使用scipy.signal.cwt時,我得到一個奇怪的錯誤:scipy.signal.cwt越來越在相關()的值錯誤

我有一些名單c,我想拿連續小波變換是這樣的:

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

,我得到一個奇怪的錯誤:

--------------------------------------------------------------------------- 
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) 

是什麼造成這個錯誤?

+0

scipy.signal.morlet不符合scipy.signal.cwt兼容HTTP:// DSP。 stackexchange.com/a/18104/29 – endolith

回答

4

scipy.signal.cwt第三個參數是寬度必須大於1,因此您的代碼更改爲:

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