66
77from arl .fourier_transforms .fft_support import *
88from arl .fourier_transforms .convolutional_gridding import w_kernel_function , kernel_oversample , \
9- coordinates2 , anti_aliasing_transform , fixed_kernel_degrid , fixed_kernel_grid
9+ coordinates2 , anti_aliasing_transform , anti_aliasing_calculate , fixed_kernel_degrid , fixed_kernel_grid
1010
1111
1212class TestConvolutionalGridding (unittest .TestCase ):
@@ -16,13 +16,19 @@ def assertAlmostEqualScalar(self, a, result=1.0):
1616
1717 def _test_pattern (self , npixel ):
1818 return coordinates2 (npixel )[0 ] + coordinates2 (npixel )[1 ] * 1j
19+
1920
20- def test_anti_aliasing (self ):
21- for shape in [(4 , 4 ), (5 , 5 ), (4 , 6 ), (7 , 3 )]:
22- aaf = anti_aliasing_transform (shape , 0 , 10 )
23- self .assertEqual (aaf .shape , shape )
24- self .assertAlmostEqual (aaf [shape [0 ] // 2 , shape [1 ] // 2 ], 1.0 )
25-
21+ def test_anti_aliasing_transform (self ):
22+ for shape in [(64 , 64 ), (128 , 128 ), (256 , 256 )]:
23+ _ , aaf = anti_aliasing_transform (shape , 8 )
24+ self .assertAlmostEqual (numpy .max (aaf [..., aaf .shape [1 ] // 2 , aaf .shape [0 ] // 2 ]), 1.0 )
25+
26+
27+ def test_anti_aliasing_calculate (self ):
28+ for shape in [(64 , 64 ), (128 , 128 ), (256 , 256 )]:
29+ _ , aaf = anti_aliasing_calculate (shape , 8 )
30+ self .assertAlmostEqual (numpy .max (aaf [..., aaf .shape [1 ] // 2 , aaf .shape [0 ] // 2 ]), 1.0 )
31+
2632 def test_w_kernel_function (self ):
2733 assert_allclose (w_kernel_function (5 , 0.1 , 0 ), 1.0 )
2834 self .assertAlmostEqualScalar (w_kernel_function (5 , 0.1 , 100 )[2 , 2 ], 1 )
@@ -71,17 +77,16 @@ def test_convolutional_grid(self):
7177 nchan = 1
7278 npol = 4
7379 uvgrid = numpy .zeros ([nchan , npol , npixel , npixel ], dtype = 'complex' )
74- aaf = anti_aliasing_transform (shape , 0 , 10 )
75- # gcf has shape [kernel_oversampling, kernel_oversampling, npixel, npixel] The fractional
80+ gcf , kernel = anti_aliasing_transform (( npixel , npixel ), 8 )
81+ # kernel has shape [kernel_oversampling, kernel_oversampling, npixel, npixel] The fractional
7682 # part of the coordinate maps onto the first two axes.
77- gcf = kernel_oversample (aaf , npixel , kernel_oversampling , 32 )
7883 # Make some uv coordinates with random locations
7984 uvcoords = numpy .array ([[random .uniform (- 0.25 , 0.25 ), random .uniform (- 0.25 , 0.25 )] for ivis in range (nvis )])
8085 # Make some visibilities, all complex unity
8186 vis = numpy .ones ([nchan , npol , nvis ], dtype = 'complex' )
8287 visweights = numpy .ones ([nchan , npol , nvis ])
8388 uvscale = numpy .array ([1.0 ])
84- fixed_kernel_grid (gcf , uvgrid , uvcoords , uvscale , vis , visweights )
89+ fixed_kernel_grid (kernel , uvgrid , uvcoords , uvscale , vis , visweights )
8590
8691 def test_convolutional_degrid (self ):
8792 shape = (7 , 7 )
@@ -91,15 +96,14 @@ def test_convolutional_degrid(self):
9196 nchan = 1
9297 npol = 4
9398 uvgrid = numpy .ones ([nchan , npol , npixel , npixel ], dtype = 'complex' )
94- aaf = anti_aliasing_transform (shape , 0 , 10 )
95- gcf = kernel_oversample (aaf , npixel , kernel_oversampling , 32 )
99+ gcf , kernel = anti_aliasing_transform ((npixel , npixel ), 8 )
96100 # gcf has shape [kernel_oversampling, kernel_oversampling, npixel, npixel] The fractional
97101 # part of the coordinate maps onto the first two axes.
98102 # Make some uv coordinates with random locations
99103 uvcoords = numpy .array ([[random .uniform (- 0.25 , 0.25 ), random .uniform (- 0.25 , 0.25 )] for ivis in range (nvis )])
100104 # Degrid the visibilities
101105 uvscale = numpy .array ([1.0 ])
102- vis = fixed_kernel_degrid (gcf , uvgrid , uvcoords , uvscale )
106+ vis = fixed_kernel_degrid (kernel , uvgrid , uvcoords , uvscale )
103107 assert vis .shape [0 ] == nvis
104108 assert vis .shape [1 ] == nchan
105109 assert vis .shape [2 ] == npol
0 commit comments