Commit 2a78a9ef authored by Philipp Arras's avatar Philipp Arras
Browse files

Fixups in w-stacking tests

parent 3909e1f7
......@@ -261,16 +261,15 @@ def test_against_dft(nxdirty, nydirty, epsilon, nchan, nrow):
assert_(_l2error(res0, res1) < epsilon)
@pmp('epsilon', [1e-7])
@pmp('nxdirty', [12, 64])
@pmp('nxdirty', [16, 64])
@pmp('nydirty', [64])
@pmp("nrow", (10, 100, 1000, 10000))
@pmp("nchan", (1,))
def test_against_wdft(nxdirty, nydirty, epsilon, nchan, nrow):
@pmp("nrow", (10, 100, 1000))
@pmp("nchan", (1, 10))
@pmp("fov", (1,))
def test_against_wdft(nxdirty, nydirty, nchan, nrow, fov):
epsilon = 1e-7
np.random.seed(40)
pixsize = np.pi/180/nxdirty
pixsize = fov*np.pi/180/nxdirty
conf = ng.GridderConfig(nxdirty=nxdirty,
nydirty=nydirty,
epsilon=epsilon,
......@@ -288,15 +287,18 @@ def test_against_wdft(nxdirty, nydirty, epsilon, nchan, nrow):
res0 = np.zeros((nxdirty, nydirty))
mi, ma = np.min(uvw[:, 2]), np.max(uvw[:, 2])
ws = np.linspace(mi, ma, 2)
delta = (ma-mi)/10000
ws = np.arange(mi, ma, delta)
for ww in ws:
jj = ng.getIndices(bl, conf, flags, wmin=ww, wmax=ww+delta)
nplanes = 10000
ws = mi + np.arange(nplanes)*(ma-mi)/(nplanes-1)
for ii in range(len(ws)-1):
wkp1 = ws[ii+1]
if ii == nplanes-2:
wkp1 += abs(wkp1)
jj = ng.getIndices(bl, conf, flags, wmin=ws[ii], wmax=wkp1)
if len(jj) == 0:
continue
dd = conf.grid2dirty_c(ng.vis2grid_c(bl, conf, jj, bl.ms2vis(ms, jj)))
res0 += conf.apply_wscreen(dd, ww, adjoint=False).real
wforplane = 0.5*(ws[ii+1]+ws[ii])
res0 += conf.apply_wscreen(dd, wforplane, adjoint=False).real
# Compute dft with w term
x, y = np.meshgrid(*[-ss/2 + np.arange(ss) for ss in [nxdirty, nydirty]],
......@@ -313,31 +315,4 @@ def test_against_wdft(nxdirty, nydirty, epsilon, nchan, nrow):
phase = x*uvw[ii, 0] + y*uvw[ii, 1] + uvw[ii, 2]*nm1
res1 += (vis[ii]*np.exp(2j*np.pi*phase)).real
res1 /= n
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(2, 2, 1)
ax.set_title('wstacking')
im = ax.imshow(res0)
fig.colorbar(im, ax=ax)
ax = fig.add_subplot(2, 2, 2)
ax.set_title('ground truth')
im = ax.imshow(res1)
fig.colorbar(im, ax=ax)
ax = fig.add_subplot(2, 2, 3)
ax.set_title('relative error')
im = ax.imshow(np.abs(res1-res0)/np.max([ np.abs(res0), np.abs(res1) ]))
fig.colorbar(im, ax=ax)
ax = fig.add_subplot(2, 2, 4)
ax.set_title('error, l2 = {}'.format(_l2error(res0, res1)))
im = ax.imshow(res1-res0)
fig.colorbar(im, ax=ax)
plt.savefig('nx{}_ny{}_nchan{}_nrow{}_eps{}.png'.format(nxdirty, nydirty, nchan, nrow, epsilon))
plt.close()
assert_(_l2error(res0, res1) < epsilon)
assert_(_l2error(res0, res1) < 1e-4)
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