Commit 97a1274f authored by Martin Reinecke's avatar Martin Reinecke

Merge branch 'NIFTy_7' into fix_operator_test

parents 0a3f3885 42f529af
Pipeline #82415 passed with stages
in 13 minutes and 33 seconds
......@@ -51,15 +51,14 @@ class Gridder(LinearOperator):
freq = np.array([speedOfLight])
x = x.val
nxdirty, nydirty = self._target[0].shape
nu, nv = max(2*nxdirty, 16), max(2*nydirty, 16)
dstx, dsty = self._target[0].distances
from ducc0.wgridder import ms2dirty, dirty2ms
if mode == self.TIMES:
res = ms2dirty(self._uvw, freq, x.reshape((-1,1)), None, nxdirty,
nydirty, dstx, dsty, nu, nv,
nydirty, dstx, dsty, 0, 0,
self._eps, False, self._nthreads, 0)
else:
res = dirty2ms(self._uvw, freq, x, None, dstx, dsty, nu, nv,
res = dirty2ms(self._uvw, freq, x, None, dstx, dsty, 0, 0,
self._eps, False, self._nthreads, 0)
res = res.reshape((-1,))
return makeField(self._tgt(mode), res)
......@@ -30,10 +30,10 @@ def _l2error(a, b):
@pmp('eps', [1e-2, 1e-4, 1e-7, 1e-10, 1e-11, 1e-12, 2e-13])
@pmp('nu', [12, 128])
@pmp('nv', [4, 12, 128])
@pmp('nxdirty', [32, 128])
@pmp('nydirty', [32, 48, 128])
@pmp('N', [1, 10, 100])
def test_gridding(nu, nv, N, eps):
def test_gridding(nxdirty, nydirty, N, eps):
uv = ift.random.current_rng().random((N, 2)) - 0.5
vis = (ift.random.current_rng().standard_normal(N)
+ 1j*ift.random.current_rng().standard_normal(N))
......@@ -42,7 +42,7 @@ def test_gridding(nu, nv, N, eps):
uv[-1] = 0
uv[-2] = 1e-5
# Nifty
dom = ift.RGSpace((nu, nv), distances=(0.2, 1.12))
dom = ift.RGSpace((nxdirty, nydirty), distances=(0.2, 1.12))
dstx, dsty = dom.distances
uv[:, 0] = uv[:, 0]/dstx
uv[:, 1] = uv[:, 1]/dsty
......@@ -52,7 +52,7 @@ def test_gridding(nu, nv, N, eps):
pynu = Op(vis2).val
# DFT
x, y = np.meshgrid(
*[-ss/2 + np.arange(ss) for ss in [nu, nv]], indexing='ij')
*[-ss/2 + np.arange(ss) for ss in [nxdirty, nydirty]], indexing='ij')
dft = pynu*0.
for i in range(N):
dft += (
......@@ -61,7 +61,7 @@ def test_gridding(nu, nv, N, eps):
def test_cartesian():
nx, ny = 2, 6
nx, ny = 32, 42
dstx, dsty = 0.3, 0.2
dom = ift.RGSpace((nx, ny), (dstx, dsty))
......@@ -87,15 +87,17 @@ def test_cartesian():
@pmp('eps', [1e-2, 1e-6, 2e-13])
@pmp('nu', [12, 128])
@pmp('nv', [4, 12, 128])
@pmp('nxdirty', [32, 128])
@pmp('nydirty', [32, 48, 128])
@pmp('N', [1, 10, 100])
def test_build(nu, nv, N, eps):
dom = ift.RGSpace([nu, nv])
def test_build(nxdirty, nydirty, N, eps):
dom = ift.RGSpace([nxdirty, nydirty])
uv = ift.random.current_rng().random((N, 2)) - 0.5
RF = ift.Gridder(dom, uv=uv, eps=eps)
# Consistency checks
flt = np.float64
cmplx = np.complex128
ift.extra.check_linear_operator(RF, cmplx, flt, only_r_linear=True)
# We set rtol=eps here, because the gridder operator only guarantees
# adjointness to this accuracy.
ift.extra.check_linear_operator(RF, cmplx, flt, only_r_linear=True, rtol=eps)
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