Beispiel #1
0
 def test_nfft_inplace_2d(self):
     a = numpy.random.random((self._size, )*2)
     ft_nfft = numpy.empty(2, dtype="complex128")
     nfft.nfft_inplace(a, [[self._coord_1d[self._2d_coord[0][0]], self._coord_1d[self._2d_coord[0][1]]],
                           [self._coord_1d[self._2d_coord[1][0]], self._coord_1d[self._2d_coord[1][1]]]], ft_nfft)
     ft_fftw = numpy.fft.fftshift(numpy.fft.fft2(numpy.fft.fftshift(a)))
     numpy.testing.assert_almost_equal(ft_nfft, ft_fftw[(self._2d_coord[0][0], self._2d_coord[1][0]), (self._2d_coord[0][1], self._2d_coord[1][1])])
Beispiel #2
0
 def test_nfft_inplace_1d(self):
     a = numpy.random.random(self._size)
     ft_nfft = numpy.empty(self._size, dtype="complex128")
     nfft.nfft_inplace(a, 1., self._coord_1d, ft_nfft)
     ft_fftw = numpy.fft.fftshift(numpy.fft.fft(numpy.fft.fftshift(a)))
     numpy.testing.assert_almost_equal(ft_nfft,
                                       ft_fftw,
                                       decimal=self._decimals)
Beispiel #3
0
 def test_nfft_inplace_direct(self):
     #a = numpy.random.random(self._size)
     a = numpy.random.random((4, )*4)
     #coordinates = -0.5+numpy.random.random(100)
     number_of_points = 100.
     coordinates = numpy.array(zip(-0.5 + numpy.random.random(number_of_points), -0.5 + numpy.random.random(number_of_points),
                                   -0.5 + numpy.random.random(number_of_points), -0.5 + numpy.random.random(number_of_points)))
     ft_nfft = numpy.empty(len(coordinates), dtype="complex128")
     nfft.nfft_inplace(a, coordinates, ft_nfft, use_direct=False)
     ft_nfft_direct = numpy.empty(len(coordinates), dtype="complex128")
     nfft.nfft_inplace(a, coordinates, ft_nfft_direct, use_direct=True)
     numpy.testing.assert_almost_equal(ft_nfft, ft_nfft_direct, decimal=3)
Beispiel #4
0
 def test_nfft_4d(self):
     size = 6
     coord_1d = numpy.linspace(-0.5, 0.5-1./size, size)
     a = numpy.random.random((size, )*4)
     ft_nfft = numpy.empty(2, dtype="complex128")
     nfft.nfft_inplace(a, [[coord_1d[self._4d_coord[0][0]], coord_1d[self._4d_coord[0][1]], coord_1d[self._4d_coord[0][2]], coord_1d[self._4d_coord[0][3]]],
                           [coord_1d[self._4d_coord[1][0]], coord_1d[self._4d_coord[1][1]], coord_1d[self._4d_coord[1][2]], coord_1d[self._4d_coord[1][3]]]],
                       ft_nfft)
     ft_fftw = numpy.fft.fftshift(numpy.fft.fftn(numpy.fft.fftshift(a)))
     numpy.testing.assert_almost_equal(ft_nfft, ft_fftw[(self._4d_coord[0][0], self._4d_coord[1][0]),
                                                        (self._4d_coord[0][1], self._4d_coord[1][1]),
                                                        (self._4d_coord[0][2], self._4d_coord[1][2]),
                                                        (self._4d_coord[0][3], self._4d_coord[1][3])])
Beispiel #5
0
 def test_nfft_inplace_direct(self):
     #a = numpy.random.random(self._size)
     a = numpy.random.random((4, ) * 4)
     #coordinates = -0.5+numpy.random.random(100)
     number_of_points = 100
     coordinates = numpy.array(
         zip(-0.5 + numpy.random.random(number_of_points),
             -0.5 + numpy.random.random(number_of_points),
             -0.5 + numpy.random.random(number_of_points),
             -0.5 + numpy.random.random(number_of_points)))
     ft_nfft = numpy.empty(len(coordinates), dtype="complex128")
     nfft.nfft_inplace(a, 1., coordinates, ft_nfft, use_direct=False)
     ft_nfft_direct = numpy.empty(len(coordinates), dtype="complex128")
     nfft.nfft_inplace(a, 1., coordinates, ft_nfft_direct, use_direct=True)
     #we use lower precision since these are actually expected to differ
     numpy.testing.assert_almost_equal(ft_nfft, ft_nfft_direct, decimal=2)
Beispiel #6
0
 def test_nfft_inplace_1d(self):
     a = numpy.random.random(self._size)
     ft_nfft = numpy.empty(self._size, dtype="complex128")
     nfft.nfft_inplace(a, self._coord_1d, ft_nfft)
     ft_fftw = numpy.fft.fftshift(numpy.fft.fft(numpy.fft.fftshift(a)))
     numpy.testing.assert_almost_equal(ft_nfft, ft_fftw, decimal=self._decimals)