Commit 16135c1e authored by Simon Perkins's avatar Simon Perkins
Browse files

Test weight gridding

parent da0b9004
......@@ -57,6 +57,7 @@ def test_hoisted_grid_allocation(nxdirty, nydirty, nrow, nchan, epsilon):
pixsize_y=pixsize)
flags = np.zeros((nrow, nchan), dtype=np.bool)
weights = np.random.rand(nrow, nchan)
idx = ng.getIndices(baselines, gconf, flags)
ms = np.random.rand(nrow, nchan)-0.5 + 1j*(np.random.rand(nrow, nchan)-0.5)
vis = baselines.ms2vis(ms, idx)
......@@ -72,6 +73,16 @@ def test_hoisted_grid_allocation(nxdirty, nydirty, nrow, nchan, epsilon):
assert grid.dtype == real_grid.dtype == grid2.dtype
assert id(grid2) == id(real_grid) # Same grid object
real_grid = np.zeros((gconf.Nu(), gconf.Nv()), dtype=np.float64)
grid = ng.ms2grid_wgt(baselines, gconf, idx, ms,
weights, grid_in=None)
grid2 = ng.ms2grid_wgt(baselines, gconf, idx, ms,
weights, grid_in=real_grid)
assert_array_almost_equal(grid, grid2)
assert grid.dtype == real_grid.dtype == grid2.dtype
assert id(grid2) == id(real_grid) # Same grid object
# ------------------------------
# Test real grid case (vis2grid)
# ------------------------------
......@@ -96,6 +107,17 @@ def test_hoisted_grid_allocation(nxdirty, nydirty, nrow, nchan, epsilon):
assert grid.dtype == cplx_grid.dtype == grid2.dtype
assert id(grid2) == id(cplx_grid) # Same grid object
cplx_grid = np.zeros((gconf.Nu(), gconf.Nv()), dtype=np.complex128)
grid = ng.ms2grid_c_wgt(baselines, gconf, idx, ms,
weights, grid_in=None)
grid2 = ng.ms2grid_c_wgt(baselines, gconf, idx, ms,
weights, grid_in=cplx_grid)
# Almost same result
assert_array_almost_equal(grid, grid2)
assert grid.dtype == cplx_grid.dtype == grid2.dtype
assert id(grid2) == id(cplx_grid) # Same grid object
# ----------------------------------
# Test complex grid case (vis2grid_c)
# ----------------------------------
......
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