Issue with CWT, Haar wavelet

2,227 views
Skip to first unread message

Alin Plesoianu

unread,
Dec 12, 2016, 2:28:19 AM12/12/16
to PyWavelets
Hi!
I am trying to use the CWT, but I get this error, everytime I run the pywt.cwt(args) command, with the Haar wavelet:
Example command:
vals, freqs = pywt.cwt(np.arange(1, 10, 1), np.arange(1, 11, 1), wavelet='Haar')

I get this error every time:
AttributeError: 'pywt._extensions._pywt.Wavelet' object has no attribute 'complex_cwt'

Why does this appear, and how can I solve it?

Thanks for any help!
*Using Python 2.7.10 on x64.


Gregory Lee

unread,
Dec 12, 2016, 12:56:46 PM12/12/16
to PyWavelets
Hi Alin,

The Haar wavelet is only compatible with the discrete wavelet transforms (DWT, SWT).  For CWT there are a separate set of continuous wavelets available.  You can get a list of the wavelets compatible with CWT via

import pywt
print(pywt.wavelist(kind='continuous'))

While looking up that function, I just noticed that there is a problem in the doctoring causing the documentation not to show the `kind` parameter in the function signature. 
I can make a small PR to fix the docs so that this option is easier to find.

caicedo...@gmail.com

unread,
Oct 12, 2017, 1:59:53 PM10/12/17
to PyWavelets
Hello, I see this was posted about a year ago, is this still the case for haar wavelets only compatible with dwt? 

Thanks!!

Gregory Lee

unread,
Oct 20, 2017, 12:32:37 PM10/20/17
to PyWavelets
Yes.  I believe this is still the case. 

james.g...@gmail.com

unread,
Apr 10, 2018, 5:27:00 PM4/10/18
to PyWavelets
Hi there

Is there some documentation on the reasons why the Haar and Daubechies wavelets are only compatible with dwt and cannot be used with pywt.cwt? The old matlab function for cwt used to allow specification of haar and db, although I note that the new matlab cwt function doesn't. Is there a theoretical reason why this is the case, or are these wavelets not included for pragmatic reasons?

Thanks
James

james.g...@gmail.com

unread,
Apr 17, 2018, 7:15:17 PM4/17/18
to PyWavelets
Hello

Sorry for the repetition - but any insight / documentation on this issue would be greatly appreciated.

Regards
James

Gregory Lee

unread,
Apr 20, 2018, 3:52:15 PM4/20/18
to pywav...@googlegroups.com
Hi James,

I don't know if the person who contributed cwt to PyWavelets excluded the Haar or Daubechies wavelets for any specific reason. It actually looks like the code already will work if we fix one line where there is an attribute check that is not valid for these wavelets.  I opened an issue here:
https://github.com/PyWavelets/pywt/issues/365

Is there a specific reason you want to use Haar or Daubechies with cwt as opposed to other options?  I am mainly familiar with use cases for the DWT and am less familiar with CWT analyses.

- Greg

--
You received this message because you are subscribed to the Google Groups "PyWavelets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pywavelets+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

james.g...@gmail.com

unread,
Apr 22, 2018, 4:30:25 PM4/22/18
to PyWavelets
Thanks for the reply Greg, much appreciated. I just find these wavelets useful for identifying signals that are sharply localised in the x dimension, but less so in scale. I did some empirical testing and found my model worked better with sharper Daubechies wavelets than with typical continuous wavelets. I don't know if these use of these wavelets is common practice in CWT analysis, as it's just my empirical observation.

And also thanks for raising the issue. Good to know that the change is simple if I want to check how the pywt coefficients look compared to the matlab ones.

Best,
James

To unsubscribe from this group and stop receiving emails from it, send an email to pywavelets+...@googlegroups.com.

Mahmoud Hachem

unread,
Jun 15, 2022, 12:18:47 PM6/15/22
to PyWavelets
Has there been any update to supporting Daubechies wavelet (e.g. db4) with CWT?
Reply all
Reply to author
Forward
0 new messages