Commit d0685c95 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add tests

parent 736bf3b3
......@@ -11,7 +11,7 @@ def _init_gridder(nxdirty, nydirty, epsilon, nchan, nrow):
conf = ng.GridderConfig(nxdirty=nxdirty,
nydirty=nydirty,
epsilon=epsilon,
pixsize_x=pixsize,
pixsize_x=0.368*pixsize,
pixsize_y=pixsize)
speedoflight, f0 = 3e8, 1e9
freq = f0 + np.arange(nchan)*(f0/nchan)
......@@ -243,22 +243,31 @@ def test_correlations(nxdirty, nydirty, nrow, nchan, epsilon, du, dv, weight):
@pmp('nydirty', [4, 12, 128])
@pmp("nrow", (10, 100))
@pmp("nchan", (1, 10))
def test_against_dft(nxdirty, nydirty, epsilon, nchan, nrow):
@pmp("complex_mode", (False, True))
def test_against_dft(nxdirty, nydirty, epsilon, nchan, nrow, complex_mode):
bl, conf, idx = _init_gridder(nxdirty, nydirty, epsilon, nchan, nrow)
ms = np.random.rand(nrow, nchan)-0.5 + 1j*(np.random.rand(nrow, nchan)-0.5)
vis = bl.ms2vis(ms, idx)
res0 = conf.grid2dirty(ng.vis2grid(bl, conf, idx, vis))
if complex_mode:
res0 = conf.grid2dirty_c(ng.vis2grid_c(bl, conf, idx, vis))
else:
res0 = conf.grid2dirty(ng.vis2grid(bl, conf, idx, vis))
x, y = np.meshgrid(*[-ss/2 + np.arange(ss) for ss in [nxdirty, nydirty]],
indexing='ij')
x *= conf.Pixsize_x()
y *= conf.Pixsize_y()
res1 = np.zeros_like(res0)
dt = np.complex128 if complex_mode else np.float64
res1 = np.zeros_like(res0, dtype=dt)
uvw = bl.effectiveuvw(idx)
for ii in idx:
phase = x*uvw[ii, 0] + y*uvw[ii, 1]
res1 += (vis[ii]*np.exp(2j*np.pi*phase)).real
foo = vis[ii]*np.exp(2j*np.pi*phase)
if complex_mode:
res1 += foo
else:
res1 += foo.real
assert_(_l2error(res0, res1) < epsilon)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment