Skip to content
Snippets Groups Projects
Commit 28c6c7b6 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

switch to better_params branch

parent 3be21948
No related branches found
No related tags found
1 merge request!327Power grid
Pipeline #50926 passed
...@@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y \ ...@@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y \
python3-mpi4py python3-matplotlib \ python3-mpi4py python3-matplotlib \
# more optional NIFTy dependencies # more optional NIFTy dependencies
&& pip3 install git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git \ && pip3 install git+https://gitlab.mpcdf.mpg.de/ift/pyHealpix.git \
&& pip3 install git+https://gitlab.mpcdf.mpg.de/ift/nifty_gridder.git@powergrid \ && pip3 install git+https://gitlab.mpcdf.mpg.de/ift/nifty_gridder.git@better_params \
&& pip3 install git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft.git \ && pip3 install git+https://gitlab.mpcdf.mpg.de/mtr/pypocketfft.git \
&& pip3 install jupyter \ && pip3 install jupyter \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
......
...@@ -10,13 +10,15 @@ np.random.seed(40) ...@@ -10,13 +10,15 @@ np.random.seed(40)
N0s, a0s, b0s, c0s = [], [], [], [] N0s, a0s, b0s, c0s = [], [], [], []
for ii in range(10, 26): for ii in range(10, 26):
fovx = 0.0001
fovy = 0.0002
nu = 1024 nu = 1024
nv = 1024 nv = 1024
N = int(2**ii) N = int(2**ii)
print('N = {}'.format(N)) print('N = {}'.format(N))
nchan=16 nchan=16
nrow=N//nchan nrow=N//nchan
fct = 1.+0.00001*np.arange(nchan) freq = 1e9+1e6*np.arange(nchan)
uvw = np.random.rand(nrow, 3) - 0.5 uvw = np.random.rand(nrow, 3) - 0.5
vis = (np.random.randn(N) + 1j*np.random.randn(N)).reshape((nrow,nchan)) vis = (np.random.randn(N) + 1j*np.random.randn(N)).reshape((nrow,nchan))
...@@ -30,7 +32,7 @@ for ii in range(10, 26): ...@@ -30,7 +32,7 @@ for ii in range(10, 26):
t0 = time() t0 = time()
GM = ift.GridderMaker(uvspace, eps=1e-7, uvw=uvw, GM = ift.GridderMaker(uvspace, eps=1e-7, uvw=uvw,
channel_fact=fct, freq=freq, fovx=fovx, fovy=fovy,
flags=np.zeros((N//nchan, nchan), dtype=np.bool)) flags=np.zeros((N//nchan, nchan), dtype=np.bool))
vis = ift.from_global_data(visspace, vis) vis = ift.from_global_data(visspace, vis)
op = GM.getFull().adjoint op = GM.getFull().adjoint
......
...@@ -24,17 +24,17 @@ import numpy as np ...@@ -24,17 +24,17 @@ import numpy as np
class GridderMaker(object): class GridderMaker(object):
def __init__(self, dirty_domain, uvw, channel_fact, flags, eps=2e-13): def __init__(self, dirty_domain, uvw, freq, fovx, fovy, flags, eps=2e-13):
import nifty_gridder import nifty_gridder
dirty_domain = makeDomain(dirty_domain) dirty_domain = makeDomain(dirty_domain)
if (len(dirty_domain) != 1 or not isinstance(dirty_domain[0], RGSpace) if (len(dirty_domain) != 1 or not isinstance(dirty_domain[0], RGSpace)
or not len(dirty_domain.shape) == 2): or not len(dirty_domain.shape) == 2):
raise ValueError("need dirty_domain with exactly one 2D RGSpace") raise ValueError("need dirty_domain with exactly one 2D RGSpace")
if channel_fact.ndim != 1: if freq.ndim != 1:
raise ValueError("channel_fact must be a 1D array") raise ValueError("freq must be a 1D array")
bl = nifty_gridder.Baselines(uvw, channel_fact) bl = nifty_gridder.Baselines(uvw, freq)
nxdirty, nydirty = dirty_domain.shape nxdirty, nydirty = dirty_domain.shape
gconf = nifty_gridder.GridderConfig(nxdirty, nydirty, eps, 1., 1.) gconf = nifty_gridder.GridderConfig(nxdirty, nydirty, eps, fovx, fovy)
nu = gconf.Nu() nu = gconf.Nu()
nv = gconf.Nv() nv = gconf.Nv()
self._idx = nifty_gridder.getIndices(bl, gconf, flags) self._idx = nifty_gridder.getIndices(bl, gconf, flags)
......
...@@ -29,19 +29,24 @@ pmp = pytest.mark.parametrize ...@@ -29,19 +29,24 @@ pmp = pytest.mark.parametrize
def _l2error(a, b): def _l2error(a, b):
return np.sqrt(np.sum(np.abs(a-b)**2)/np.sum(np.abs(a)**2)) return np.sqrt(np.sum(np.abs(a-b)**2)/np.sum(np.abs(a)**2))
speedOfLight = 299792458.
@pmp('eps', [1e-2, 1e-4, 1e-7, 1e-10, 1e-11, 1e-12, 2e-13]) @pmp('eps', [1e-2, 1e-4, 1e-7, 1e-10, 1e-11, 1e-12, 2e-13])
@pmp('nu', [12, 128]) @pmp('nu', [12, 128])
@pmp('nv', [4, 12, 128]) @pmp('nv', [4, 12, 128])
@pmp('N', [1, 10, 100]) @pmp('N', [1, 10, 100])
@pmp('channel_fact', [1, 1.2]) @pmp('freq', [1e9])
def test_gridding(nu, nv, N, eps, channel_fact): def test_gridding(nu, nv, N, eps, freq):
uvw = np.random.rand(N, 3) - 0.5 fovx = 0.0001
fovy = 0.0002
uvw = (np.random.rand(N, 3) - 0.5)
uvw[:,0] /= fovx*freq/speedOfLight
uvw[:,1] /= fovy*freq/speedOfLight
vis = (np.random.randn(N) + 1j*np.random.randn(N)).reshape((-1,1)) vis = (np.random.randn(N) + 1j*np.random.randn(N)).reshape((-1,1))
# Nifty # Nifty
GM = ift.GridderMaker(ift.RGSpace((nu, nv)), uvw=uvw, GM = ift.GridderMaker(ift.RGSpace((nu, nv)), uvw=uvw,
channel_fact=np.array([channel_fact]), eps=eps, freq=np.array([freq]), eps=eps, fovx=fovx, fovy=fovy,
flags=np.zeros((N, 1), dtype=np.bool)) flags=np.zeros((N, 1), dtype=np.bool))
vis2 = ift.from_global_data(ift.UnstructuredDomain(vis.shape), vis) vis2 = ift.from_global_data(ift.UnstructuredDomain(vis.shape), vis)
...@@ -50,9 +55,11 @@ def test_gridding(nu, nv, N, eps, channel_fact): ...@@ -50,9 +55,11 @@ def test_gridding(nu, nv, N, eps, channel_fact):
# DFT # DFT
x, y = np.meshgrid( x, y = np.meshgrid(
*[-ss/2 + np.arange(ss) for ss in [nu, nv]], indexing='ij') *[-ss/2 + np.arange(ss) for ss in [nu, nv]], indexing='ij')
x *= fovx*freq/speedOfLight
y *= fovy*freq/speedOfLight
dft = pynu*0. dft = pynu*0.
for i in range(N): for i in range(N):
dft += (vis[i]*np.exp(2j*np.pi*(x*uvw[i, 0] + y*uvw[i, 1])*channel_fact)).real dft += (vis[i]*np.exp(2j*np.pi*(x*uvw[i, 0] + y*uvw[i, 1]))).real
assert_(_l2error(dft, pynu) < eps) assert_(_l2error(dft, pynu) < eps)
...@@ -60,14 +67,15 @@ def test_gridding(nu, nv, N, eps, channel_fact): ...@@ -60,14 +67,15 @@ def test_gridding(nu, nv, N, eps, channel_fact):
@pmp('nu', [12, 128]) @pmp('nu', [12, 128])
@pmp('nv', [4, 12, 128]) @pmp('nv', [4, 12, 128])
@pmp('N', [1, 10, 100]) @pmp('N', [1, 10, 100])
@pmp('cfact', [np.array([1.]), np.array([0.3, 0.5, 2.3])]) @pmp('freq', [np.array([1e9]), np.array([1e9, 2e9, 2.5e9])])
def test_build(nu, nv, N, eps, cfact): def test_build(nu, nv, N, eps, freq):
dom = ift.RGSpace([nu, nv]) dom = ift.RGSpace([nu, nv])
fov = np.pi/180/60
uvw = np.random.rand(N, 3) - 0.5 uvw = np.random.rand(N, 3) - 0.5
flags=np.zeros((N, cfact.shape[0]), dtype=np.bool) flags=np.zeros((N, freq.shape[0]), dtype=np.bool)
flags[0,0]=True flags[0,0]=True
GM = ift.GridderMaker(dom, uvw=uvw, channel_fact=cfact, eps=eps, GM = ift.GridderMaker(dom, uvw=uvw, freq=freq, eps=eps,
flags=flags) flags=flags, fovx=fov, fovy=fov)
R0 = GM.getGridder() R0 = GM.getGridder()
R1 = GM.getRest() R1 = GM.getRest()
R = R1@R0 R = R1@R0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment