0
$\begingroup$

Question

I'm trying to use Python's scipy library to compute the IDFT of the Ricker wavelet function and compare it with the analytical time-domain version of the same function. When I compare the results, they do not match. I want to understand why.


Details

I'm using Python for the experiment. The Ricker pulse function in time domain is defined as follows:

def ricker_pulse_time(w0, t):
    return (1. - .5 * w0**2 * t**2) * np.e ** (-.25 * w0**2 * t**2)

def ricker_pulse_freq(w0, w):
    return (2. * w**2) / (np.sqrt(np.pi) * w0**3) * \
        np.e ** (-w**2 / w0**2)

So, for 2Hz, for example:

hz_to_rad = lambda x: 2. * np.pi * x

w0 = hz_to_rad(2.0) # [Rad/s]
time_step = 1e-6 # [s]
t = np.arange(-2.0, 2.0, time_step)
y = ricker_pulse_time(w0, t)
N = len(t)

omega = np.arange(0.0, 100.0, 1e-4)
yy = ricker_pulse_freq(w0, omega)

plt.plot(t, y, 'r-');
plt.show();
plt.plot(omega, yy, 'b-');

Time domain Frequency domain

But, when I try to make the ifft of the ricker pulse in the frequency domain, I don't seem to get the expected curve in time domain, as above...

omega = np.arange(-300.0, 300.0, 1e-4)
yy = ricker_pulse_freq(w0, omega)
plt.plot(omega, yy);
plt.show();

y_ta = fft.fftshift(ifft(yy))
tt = np.arange(-2.0, 2.0, 4. / len(y_ta))
plt.plot(tt, y_ta.real, 'b-');
plt.xlim(-.005, +.005)
plt.show();

Frequency domain full Time domain wrong

I don't understand the reasoning behind this, and what should I do to get the same results. I understand that, perhaps, I won't get the same amplitude of signal, but I want to at least get the same shape...

$\endgroup$
1
  • $\begingroup$ Try ifft(fft.ifftshift(yy)). At the moment, you are taking the inverse DFT of some peaks very close to the Nyquist rate. So the output is going to be very high frequency. $\endgroup$
    – TimWescott
    Dec 29 '20 at 22:05

Your Answer

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

Browse other questions tagged or ask your own question.