diff --git a/nifty5/library/gridder.py b/nifty5/library/gridder.py index aff1b7c44442471f59492e435a845d068d8f64c4..e01ef6b36486653bbdffa294cd0fc71532bc6da7 100644 --- a/nifty5/library/gridder.py +++ b/nifty5/library/gridder.py @@ -34,10 +34,14 @@ class GridderMaker(object): raise ValueError("uv must be a 2D array") if uv.shape[1] != 2: raise ValueError("second dimension of uv must have length 2") + dstx, dsty = dirty_domain[0].distances # wasteful hack to adjust to shape required by nifty_gridder uvw = np.empty((uv.shape[0],3), dtype=np.float64) uvw[:,0:2] = uv uvw[:,2] = 0. + # Scale uv such that 0<uv<=1 which is assmued by nifty_gridder + uvw[:, 0] = uvw[:,0]*dstx + uvw[:, 1] = uvw[:,1]*dsty speedOfLight = 299792458. bl = nifty_gridder.Baselines(uvw, np.array([speedOfLight])) nxdirty, nydirty = dirty_domain.shape diff --git a/test/test_operators/test_nft.py b/test/test_operators/test_nft.py index 114675bb19cb3649afd51d2802a934e7164e483e..822792a248e273471ed53a6e28c747c06a7739e3 100644 --- a/test/test_operators/test_nft.py +++ b/test/test_operators/test_nft.py @@ -39,20 +39,21 @@ def test_gridding(nu, nv, N, eps): vis = np.random.randn(N) + 1j*np.random.randn(N) # Nifty - GM = ift.GridderMaker(ift.RGSpace((nu, nv)), uv=uv, eps=eps) + dom = ift.RGSpace((nu, nv), distances=(0.2, 1.12)) + dstx, dsty = dom.distances + uv[:,0] = uv[:,0]/dstx + uv[:,1] = uv[:,1]/dsty + GM = ift.GridderMaker(dom, uv=uv, eps=eps) vis2 = ift.from_global_data(ift.UnstructuredDomain(vis.shape), vis) Op = GM.getFull() pynu = Op(vis2).to_global_data() - import matplotlib.pyplot as plt - plt.imshow(pynu) - plt.show() # DFT x, y = np.meshgrid( *[-ss/2 + np.arange(ss) for ss in [nu, nv]], indexing='ij') dft = pynu*0. for i in range(N): - dft += (vis[i]*np.exp(2j*np.pi*(x*uv[i, 0] + y*uv[i, 1]))).real + dft += (vis[i]*np.exp(2j*np.pi*(x*uv[i, 0]*dstx + y*uv[i, 1]*dsty))).real assert_(_l2error(dft, pynu) < eps)