Commit bdac5ac6 authored by Martin Reinecke's avatar Martin Reinecke
Browse files


parents 8b794388 5aa488ad
from itertools import product
import nifty_gridder as ng
import numpy as np
import pytest
......@@ -387,3 +389,38 @@ def test_wgridder_against_wdft(nxdirty, nydirty, nchan, nrow, fov, epsilon):
res0 = ng.vis2dirty_wstack(bl, conf, idx, vis)
res1 = _dft(uvw, vis, conf, True)
assert_(_l2error(res0, res1) < epsilon)
@pmp('nxdirty', (32, 16))
@pmp('nydirty', (32, 64))
@pmp("nrow", (100, 1000))
@pmp("nchan", (1, 5))
@pmp('epsilon', (1e-3, 1e-6))
def test_holo_from_correlations(nxdirty, nydirty, nchan, nrow, epsilon):
bl, conf, idx = _init_gridder(nxdirty, nydirty, epsilon, nchan, nrow)
nx, ny = 2*nxdirty, 2*nydirty
grid = np.random.randn(nx, ny) + 1.0j*np.random.randn(nx, ny)
W = conf.Supp()
res0 = np.zeros_like(grid)
# Precompute 2*W**2-2*W+1 images (naive: 4*W**2-4*W+1)
d0, d1 = [], []
for du, dv in product(range(-W + 1, W), range(1, W)):
d0.append(ng.get_correlations(bl, conf, idx, du, dv))
for du in range(1, W):
d1.append(ng.get_correlations(bl, conf, idx, du, 0))
d2 = ng.get_correlations(bl, conf, idx, 0, 0)
# Apply
for ii, (du, dv) in enumerate(product(range(-W + 1, W), range(1, W))):
tmp = np.roll(grid, -du, axis=0)
res0 += d0[ii]*np.roll(tmp, -dv, axis=1)
res0 += np.roll(d0[ii]*tmp, dv, axis=1)
for ii, du in enumerate(range(1, W)):
res0 += d1[ii]*np.roll(grid, -du, axis=0)
res0 += np.roll(d1[ii]*grid, du, axis=0)
res0 += d2*grid
res1 = ng.apply_holo(bl, conf, idx, grid)
assert_allclose(res0, res1, rtol=1e-13)
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