Example #1
0
    def test_ifft_pattern_real(self, shift):
        # Odd second dimension becomes even with only real valued FFT
        p = np.random.random((101, 100))
        p_fft = fft(p, shift=shift, real_fft_only=False)
        p_ifft = ifft(p_fft, shift=shift, real_fft_only=False)

        p_rfft = fft(p, shift=shift, real_fft_only=True)
        p_irfft = ifft(p_rfft, shift=shift, real_fft_only=True)

        assert p_ifft.shape == p.shape
        assert p_irfft.shape == p.shape
        assert np.allclose(p_ifft, p_irfft)
Example #2
0
    def test_fft_pattern_apodization_window(self, dummy_signal, window):
        p = dummy_signal.inav[0, 0].data
        w = Window(window, shape=p.shape)
        p2 = fft(pattern=p, apodization_window=w, shift=True)
        p3 = fft(pattern=p * w, shift=True)
        p4 = fft(pattern=p, shift=True)

        assert p2.shape == p.shape
        assert p3.shape == p.shape
        assert np.allclose(p2, p3)
        assert not np.allclose(p2, p4, atol=1e-1)
        assert not np.allclose(p3, p4, atol=1e-1)
Example #3
0
    def test_fft_pattern(self, shift, real_fft_only, expected_spectrum_sum):
        p = np.ones((101, 101))
        p[50, 50] = 2

        kwargs = {}

        p_fft = fft(
            pattern=p, shift=shift, real_fft_only=real_fft_only, **kwargs,
        )

        assert np.allclose(
            np.sum(fft_spectrum.py_func(p_fft)),
            expected_spectrum_sum,
            atol=1e-3,
        )
Example #4
0
    def test_ifft_pattern(self, shift):
        p = np.random.random((101, 101))
        p_fft = fft(p, shift=shift)
        p_ifft = ifft(p_fft, shift=shift)

        assert np.allclose(p_ifft, p)