Commit 1e121c2b authored by Philipp Arras's avatar Philipp Arras
Browse files

Test against dft

parent 6acee462
......@@ -32,6 +32,10 @@ def _wscreen(npix, dst, w):
return wscreen
def _l2error(a, b):
return np.sqrt(np.sum(np.abs(a-b)**2)/np.sum(np.abs(a)**2))
@pmp("nxdirty", (128, 300))
@pmp("nydirty", (128, 250))
@pmp("nrow", (1, 10, 10000))
......@@ -232,3 +236,27 @@ def test_correlations(nxdirty, nydirty, nrow, nchan, epsilon, du, dv, weight):
ind = (pp[0]+du) % (2*nxdirty), (pp[1]+dv) % (2*nydirty)
assert_allclose(y0[pp], y1[ind].real)
assert_allclose(np.zeros_like(y1), y1.imag)
@pmp('epsilon', [1e-2, 1e-4, 1e-7, 1e-10, 1e-11, 1e-12, 2e-13])
@pmp('nxdirty', [12, 128])
@pmp('nydirty', [4, 12, 128])
@pmp("nrow", (10, 100))
@pmp("nchan", (1, 10))
def test_against_dft(nxdirty, nydirty, epsilon, nchan, nrow):
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))
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)
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
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