예제 #1
0
    def test_expand_fourier_sp_odd1d(self):
        """
        Test function with odd input size
        """
        arr = np.random.rand(151)
        arr_ft = fft.fftshift(fft.fft(fft.ifftshift(arr)))

        arr_ex_ft = tools.resample_bandlimited_ft(arr_ft, (2, ))
        arr_exp = fft.fftshift(fft.ifft(fft.ifftshift(arr_ex_ft))).real

        max_err = np.max(np.abs(arr_exp[1::2] - arr))
        self.assertTrue(max_err < 1e-14)
예제 #2
0
    def test_expand_fourier_sp_even2d(self):
        """
        test function with even input size
        """
        arr = np.random.rand(100, 100)
        arr_ft = fft.fftshift(fft.fft2(fft.ifftshift(arr)))

        arr_ex_ft = tools.resample_bandlimited_ft(arr_ft, (2, 2))
        arr_exp = fft.fftshift(fft.ifft2(fft.ifftshift(arr_ex_ft))).real

        max_err = np.max(np.abs(arr_exp[::2, ::2] - arr))
        self.assertTrue(max_err < 1e-14)
예제 #3
0
    def test_expand_fourier_sp(self):
        """
        Test expand_fourier_sp() function
        :return:
        """

        arr = np.array([[1, 2], [3, 4]])
        arr_ft = fft.fftshift(fft.fft2(fft.ifftshift(arr)))

        arr_ft_ex = tools.resample_bandlimited_ft(arr_ft, (2, 2))
        arr_ex = fft.fftshift(fft.ifft2(fft.ifftshift(arr_ft_ex)))

        self.assertTrue(
            np.array_equal(
                arr_ex.real,
                np.array([[1, 1.5, 2, 1.5], [2, 2.5, 3, 2.5], [3, 3.5, 4, 3.5],
                          [2, 2.5, 3, 2.5]])))