Search code examples
pythonsignalssignal-processingwavelet

Phase shift of ricker wavelet


I have been struggling with phase shift of Ricker wavelet

from scipy import signal
import matplotlib.pyplot as plt

x = 100
a = 10
vec2 = signal.ricker(x, a)
print(len(vec2))

plt.plot(vec2)
plt.show()

I can't find how to do it through signal.ricker function, so I recreated the original wavelet.

x1 = np.arange(-50,50,1)
wavelet = []
a = 10
A = 2/(sqrt(3*a)*(pi**0.25))

for i in x1:
    i = A * (1 - (i/a)**2) * exp(-0.5*(i/a)**2)
    wavelet.append(i)
plt.plot(wavelet)
plt.show()

So how I can rotate wavelet for example 90 degrees shift?


Solution

  • You can obtain a -90 degrees shift of a signal using the Hilbert transform. This provides a way to obtain other phase shifts via the analytic representation, implemented by scipy.signal.hilbert. Once you have this analytic signal, you 'simply' have to multiply by the complex phase term exp(1j*np.radians(angle)), and extract the real part:

    N = 100
    a = 10
    x = np.arange(0,N)-0.5*(N-1)
    wavelet = signal.ricker(N, a)
    
    plt.plot(x,wavelet,label='wavelet')
    
    angle = 90
    shifted = np.real(np.exp(1j*np.radians(angle)) * signal.hilbert(wavelet))
    plt.plot(x,shifted,label='90º shift')
    
    plt.show()
    

    enter image description here