I am trying to understand one simple thing in wavelets and I searched a lot, but did not get any idea.

I need to perform Multilevel 1-D wavelet decomposition on my signal. I have arrays

signal[] and time[]  

( time[x] corresponds to the time at which signal[x] occurs ) . After I perform


I need to plot cA1 vs the time signal. But how do I know which time points should I select. If i change the 'wname' , I get different length cA1.

For example, for a signal of length 9285, when I do

[cA1,cD1]=pywt.wavedec(signal,db1, level=1,mode=pywt.MODES.zpd)
length of cA1=4643

[cA1,cD1]=pywt.wavedec(signal,db2, level=1,mode=pywt.MODES.zpd)
length of cA1 = 4644

How can we determine the variation of cA1 and how can we select the corresponding time. I use pywavelet

  • 1
    $\begingroup$ I think I got the answer. We should reconstruct using upcoef. But I am not very sure $\endgroup$
    – Thothadri
    Commented Sep 23, 2013 at 17:50

1 Answer 1


The length of the arrays you get back depends on the mode you use to do the decomposition and the wavelet length, which can vary like you see between db1 and db2:

len(cA) == len(cD) == floor((len(data) + wavelet.dec_len - 1) / 2)

If you switch to periodization mode mode='per', you get a different calculation that may be more consistent for you:

len(cA) == len(cD) == ceil(len(data) / 2)

Regardless, decomposition is generally dyadic, so your dyad width is len(signal)/len(cAn).

Once you go muiltilevel (use level='2', etc.), you'll have small variations in length as well. To account for this, use IDWT to reconstruct.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.