PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
2.04k stars 470 forks source link

error ocurred when using function cwt #444

Closed wumaster closed 5 years ago

wumaster commented 5 years ago

Hi: I met some problems when I ran some simple codes. Here is my code:

     import pywt
     import numpy as np
     import matplotlib.pyplot as plt
     x = np.arange(512)
     y = np.sin(2*np.pi*x/32)
     coef, freqs=pywt.cwt(y,np.arange(1,129),'db3')
     plt.matshow(coef)
    plt.show()

Then some errors ocurred:

File "C:\Users\admin\Anaconda3\lib\site-packages\pywt_cwt.py", line 78, in cwt if wavelet.complex_cwt: AttributeError: 'pywt._extensions._pywt.Wavelet' object has no attribute 'complex_cwt'

when I changed the wavelet to ' mexh', it can run well. I looked into the _cwt file, it's true that there is no attribute called 'complex_cwt' in the class 'Wavelet'.

I wonder if there is a mistake in the source code or I don't understand the theory of CWT well. Hoping you will answer my question soon and thank you very much!

wumaster commented 5 years ago

I tried the same matlab code: x = 1:1:512; y = sin(2*pi*x/32); coefs = cwt(y,1:1:129,'db3'); and it worked. So I guess it might be some errors in the source code.

grlee77 commented 5 years ago

The CWT currently only supports the wavelets shown on this documentation page: https://pywavelets.readthedocs.io/en/latest/ref/cwt.html#continuous-wavelet-families

In PyWavelets, the 'db3' wavelet is only available for the discrete wavelet transforms. We should add a type check in CWT to raise a more informative error message to avoid confusion on this.

In general, Matlab's cwt has a number of additional features which are not currently available in PyWavelets.

wumaster commented 5 years ago

The CWT currently only supports the wavelets shown on this documentation page: https://pywavelets.readthedocs.io/en/latest/ref/cwt.html#continuous-wavelet-families

In PyWavelets, the 'db3' wavelet is only available for the discrete wavelet transforms. We should add a type check in CWT to raise a more informative error message to avoid confusion on this.

In general, Matlab's cwt has a number of additional features which are not currently available in PyWavelets.

Thank you very much! In the morning I found the matlab func cwt had changed too, the old cwt si not recommended. Thank you for your answer!