Search code examples
pythontransformcontinuouswavelet

Why the output of pywt wavelet transfor is a complex array?


I'm using the python package pywt of python to do continuous wavelet transform for some signals. As the length of the signals are different, the output coefficient 2d arrays have different number of columns. In order to have coefficient arrays with same shape, I emploied the scipy.ndimage.interpolation.zoom to do interpolation. But the inerpolation raised error message as 'Complex type not supported' which means the input array is a complex array. As we know, actaually the output of pywt cwt is a array/matrix made up of coefficients of the wavelets with different scales and time shifts, and these coefficents should be real number other than complex number. So I really don't know how to figure it out. Could anyone solve this problem or suggest some alternative way to do this interpolation and get same-size out put arrays? The simple codes are as what follows

import pywt
import scipy
...
[coefficients_return, frequencies] = pywt.cwt(signal, scales, waveletname, dt)
coefficients_interp = scipy.ndimage.interpolation.zoom(input=coefficients_return, zoom= 2., order=3) 
...

TypeError: Complex type not supported

Solution

  • Some wavelets do have complex components, and these are typically chosen when both phase and amplitude are desired.

    Easiest way to solve your problem is to simply chose a different wavelet.