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

Merge branch 'master' into sometests

parents 847c9606 90e57542
......@@ -11,8 +11,8 @@ def _init_gridder(nxdirty, nydirty, epsilon, nchan, nrow):
conf = ng.GridderConfig(nxdirty=nxdirty,
nydirty=nydirty,
epsilon=epsilon,
pixsize_x=pixsize,
pixsize_y=0.5*pixsize)
pixsize_x=0.368*pixsize,
pixsize_y=pixsize)
speedoflight, f0 = 3e8, 1e9
freq = f0 + np.arange(nchan)*(f0/nchan)
uvw = (np.random.rand(nrow, 3)-0.5)/(pixsize*f0/speedoflight)
......@@ -213,18 +213,41 @@ def test_correlations(nxdirty, nydirty, nrow, nchan, epsilon, du, dv, weight):
assert_allclose(np.zeros_like(y1), y1.imag)
@pmp("nrow", (1, 1000))
@pmp("nchan", (1, 10))
@pmp("epsilon", (1e-2, 1e-7, 2e-12))
@pmp("weight", (True, False))
def test_no_correlation(nrow, nchan, epsilon, weight):
np.random.seed(42)
bl, conf, idx = _init_gridder(128, 128, epsilon, nchan, nrow)
wgt = np.random.rand(*idx.shape) if weight else None
w = conf.W()
for uu in range(-2*w, 2*w):
for vv in range(-2*w, 2*w):
if abs(uu) >= w or abs(vv) >= w:
with pytest.raises(RuntimeError):
ng.get_correlations(bl, conf, idx, uu, vv, wgt)
else:
ng.get_correlations(bl, conf, idx, uu, vv, wgt)
@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):
@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)
uvw = bl.effectiveuvw(idx)
res0 = conf.grid2dirty_c(ng.vis2grid_c(bl, conf, idx, vis))
res1 = _dft(uvw, vis, conf, False)
if complex_mode:
res0 = conf.grid2dirty_c(ng.vis2grid_c(bl, conf, idx, vis))
res1 = _dft(uvw, vis, conf, False)
else:
res0 = conf.grid2dirty(ng.vis2grid(bl, conf, idx, vis))
res1 = _dft(uvw, vis, conf, False).real
assert_(_l2error(res0, res1) < epsilon)
......
Markdown is supported
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