def check_wavelets(t0, f0, Q, t): h = sinegauss(t, t0, f0, Q) f, H = FT_continuous(t, h) H2 = sinegauss_FT(f, t0, f0, Q) assert_allclose(H, H2, atol=1E-8)
def check_IFT_continuous(a, t0, f0, method, f): H = sinegauss_FT(f, t0, f0, a) t, h = IFT_continuous(f, H, method=method) assert_allclose(h, sinegauss(t, t0, f0, a), atol=1E-12)
N = 10000 t0 = 5 f0 = 2 Q = 2 #------------------------------------------------------------ # Compute the wavelet on a grid of times Dt = 0.01 t = t0 + Dt * (np.arange(N) - N / 2) h = sinegauss(t, t0, f0, Q) #------------------------------------------------------------ # Approximate the continuous Fourier Transform f, H = FT_continuous(t, h) rms_err = np.sqrt(np.mean(abs(H - sinegauss_FT(f, t0, f0, Q))**2)) #------------------------------------------------------------ # Plot the results fig = plt.figure() fig.subplots_adjust(hspace=0.25) # plot the wavelet ax = fig.add_subplot(211) ax.plot(t, h.real, '-', c='black', label='$Re[h]$', lw=1) ax.plot(t, h.imag, ':', c='black', label='$Im[h]$', lw=1) ax.legend(prop=dict(size=14)) ax.set_xlim(2, 8) ax.set_ylim(-1.2, 1.2) ax.set_xlabel('$t$')
def check_FT_continuous(a, t0, f0, method, t): h = sinegauss(t, t0, f0, a) f, H = FT_continuous(t, h, method=method) assert_allclose(H, sinegauss_FT(f, t0, f0, a), atol=1E-12)
def test_FT_continuous(a, t0, f0, method): t = np.linspace(-9, 10, 10000) h = sinegauss(t, t0, f0, a) f, H = FT_continuous(t, h, method=method) assert_allclose(H, sinegauss_FT(f, t0, f0, a), atol=1E-12)
def check_IFT_continuous(a, t0, f0, method): f = np.linspace(-9, 10, 10000) H = sinegauss_FT(f, t0, f0, a) t, h = IFT_continuous(f, H, method=method) assert_allclose(h, sinegauss(t, t0, f0, a), atol=1E-12)
def test_wavelets(t0, f0, Q): t = np.linspace(-10, 10, 10000) h = sinegauss(t, t0, f0, Q) f, H = FT_continuous(t, h) H2 = sinegauss_FT(f, t0, f0, Q) assert_allclose(H, H2, atol=1E-8)
N = 10000 t0 = 5 f0 = 2 Q = 2 #------------------------------------------------------------ # Compute the wavelet on a grid of times Dt = 0.01 t = t0 + Dt * (np.arange(N) - N / 2) h = sinegauss(t, t0, f0, Q) #------------------------------------------------------------ # Approximate the continuous Fourier Transform f, H = FT_continuous(t, h) rms_err = np.sqrt(np.mean(abs(H - sinegauss_FT(f, t0, f0, Q)) ** 2)) #------------------------------------------------------------ # Plot the results fig = plt.figure(figsize=(5, 3.75)) fig.subplots_adjust(hspace=0.25) # plot the wavelet ax = fig.add_subplot(211) ax.plot(t, h.real, '-', c='black', label='$Re[h]$', lw=1) ax.plot(t, h.imag, ':', c='black', label='$Im[h]$', lw=1) ax.legend() ax.set_xlim(2, 8) ax.set_ylim(-1.2, 1.2) ax.set_xlabel('$t$')