I'm using the code I found here to compute the wavelet transform of a sine wave with a constant frequency.


from pylab import *
import matplotlib.pyplot as plt
import numpy as np
import scipy

x = np.linspace(0, 10, 65536)
y = np.sin(2 * pi * 60 * x)
N = len(y)
Y = np.fft.fft(y)

J = 128
scales = np.asarray([2 ** (i * 0.1) for i in range(J)])

morletft = np.zeros((J, N))
for i in range(J):
    morletft[i][:N/2] = sqrt(2 * pi * scales[i]) * exp(-(scales[i] * 2 * pi * scipy.array(range(N/2)) / N - 2) ** 2 / 2.0)

U = empty((J, N), dtype=complex128)
for i in range(J):
    U[i] = np.fft.ifft(Y * morletft[i])

plt.imshow(abs(U[:,scipy.arange(0,N,1)]), interpolation='none', aspect='auto')
plt.title("Sine Wave")

The result looks alright. alright

What I'm really interested in looking at is the phase. I'm extracting phase from the above code using:

imshow(np.unwrap(np.angle(U)), aspect='auto')

and it looks like this:

Why is the phase information present at frequencies higher than (or scales lower than, NOTE: inverted y-axis) that of the signal?


As you can see there is energy also in higher frequencies than your original. This is probably since every level of the wavelet has a band, so the wavelet can show energy at frequencies higher.

The phase exists only as long as there is energy... so it directly connected to it. You can see if the data on the spectrum exists only where there is non zero energy in the spectrum.

  • $\begingroup$ Thank you. I set up a threshold below which the phase information is not processed as described here and most of that stuff goes away. $\endgroup$ – SgrA Mar 4 '17 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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