Skip to content
Snippets Groups Projects
Commit b70bd6d4 authored by Landman Bester's avatar Landman Bester
Browse files

Added detapering and explanation in comments

parent f5c4261f
Branches
No related tags found
No related merge requests found
...@@ -23,16 +23,40 @@ idx = ng.getIndices(baselines, conf, flags) ...@@ -23,16 +23,40 @@ idx = ng.getIndices(baselines, conf, flags)
data = np.random.randn(nrow, nchan) + 1.0j*np.random.randn(nrow, nchan) data = np.random.randn(nrow, nchan) + 1.0j*np.random.randn(nrow, nchan)
# get dirty # get dirty ID = T.H Z.H F.H G.H V where
# T = taper
# Z = zero padding
# F = FFT
# G = degridding operator
# V = data
dirty = ng.ms2dirty(uvw=uvw, freq=freq, ms=data.copy(), npix_x=npix, npix_y=npix, dirty = ng.ms2dirty(uvw=uvw, freq=freq, ms=data.copy(), npix_x=npix, npix_y=npix,
pixsize_x=pixsize, pixsize_y=pixsize, epsilon=eps, pixsize_x=pixsize, pixsize_y=pixsize, epsilon=eps,
do_wstacking=False, nthreads=1, verbosity=1) do_wstacking=False, nthreads=1, verbosity=1)
# convert to gridded data # we want to convert to gridded data (i.e. G.H V) so we need
grid = conf.dirty2grid_c(dirty.astype(data.dtype)) # F Z T^{-1} ID
# Since dirty2grid = F Z T we can obtain gridded data as
# G.H V = dirty2grid T^{-2} ID
# check that T^2 is invertible
taper = conf.apply_taper(np.ones_like(dirty))
if (1.0/taper**2).min() < eps:
raise RuntimeError("Taper not invertible at required precision")
# detaper dirty (same result as dividing by T^2)
dirtyc = conf.apply_taper(dirty, divide=True)
dirtycc = conf.apply_taper(dirtyc, divide=True)
# get gridded data
grid = conf.dirty2grid_c(dirtycc.astype(data.dtype))
# get gridded data directly from ms # get gridded data directly from ms
grid2 = ng.ms2grid_c(baselines=baselines, gconf=conf, idx=idx, ms=data) grid2 = ng.ms2grid_c(baselines=baselines, gconf=conf, idx=idx, ms=data)
# normalise in case its a scaling issue
grid /= np.abs(grid).max()
grid2 /= np.abs(grid2).max()
# result should match to withon gridding accuracy # result should match to withon gridding accuracy
np.testing.assert_array_almost_equal(grid, grid2, decimal=6) np.testing.assert_array_almost_equal(grid, grid2, decimal=6)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment