Search code examples
pythonpywt

wavedec does not returning any coefficients in python using pywt library


i used wavelet decomposition command in python using pywt library but it does not return any coefficients. my code is given below .

import numpy as np
import pywt as pywt

(e,f)=pywt.wavedec(y,'db12' ,level=2)
print("e:"+str(e))
print("f:"+str(f))

I also tried with pywt.dwt(y,' db12', level=2) it is also not returning any coefficients

it returns a null output, where y is a matrix contains my input


Solution

  • I tried reproducing your results with a random (discrete) signal like so:

    import numpy as np
    import pyw
    
    x = np.random.randint(0,100,500)
    
    y = pywt.wavedec(x, 'db12', level=2)
    (e,f) = pywt.dwt(x, 'db12')
    

    I noticed two things: For a 1D signal, wavedec returns more than two coefficient arrays, as also mentioned in the docs. Similarly, the dwt function does not know the keyword level=, but works just fine with the command specified above.
    Hope that helps