Commit dfbf36f5 authored by Philipp Arras's avatar Philipp Arras
Browse files

Cleanup and renaming

parent fc1b38de
......@@ -413,7 +413,7 @@ template<typename T> class Baselines
The visibility data for the index array
)""";
pyarr_c<T> ind2effectiveuvw(const pyarr_c<uint32_t> &idx_) const
pyarr_c<T> effectiveuvw(const pyarr_c<uint32_t> &idx_) const
{
checkArray(idx_, "idx", {0});
size_t nvis = size_t(idx_.shape(0));
......@@ -1546,7 +1546,7 @@ PYBIND11_MODULE(nifty_gridder, m)
.def ("Nchannels",&Baselines<double>::Nchannels)
.def ("ms2vis",&Baselines<double>::ms2vis<complex<double>>,
Baselines<double>::ms2vis_DS, "ms"_a, "idx"_a)
.def ("ind2effectiveuvw",&Baselines<double>::ind2effectiveuvw, "idx"_a)
.def ("effectiveuvw",&Baselines<double>::effectiveuvw, "idx"_a)
.def ("vis2ms",&Baselines<double>::vis2ms<complex<double>>,
Baselines<double>::vis2ms_DS, "vis"_a, "idx"_a, "ms_in"_a=None);
py::class_<GridderConfig<double>> (m, "GridderConfig", GridderConfig_DS)
......
import nifty_gridder as ng
from time import time
import numpy as np
def _wscreen(npix, dst, w):
dc = (np.linspace(start=-npix/2, stop=npix/2 - 1, num=npix)*dst)**2
ls = np.broadcast_to(dc, (dc.shape[0],)*2)
theta = np.sqrt(ls + ls.T)
n = np.cos(theta)
wscreen = np.exp(2*np.pi*1j*w*(n - 1))/n
return wscreen
def time_op(func, x, ntries=5):
t0 = time()
for ii in range(ntries):
print(ii)
func(x)
return (time() - t0)/ntries
if __name__ == '__main__':
ng.set_nthreads(4)
ntries = 20
nx = 2048
dx = 12
w = 1000.2
ny, dy = nx, dx
conf = ng.GridderConfig(nx, ny, 1e-7, dx, dy)
x, y = conf.Nxdirty(), conf.Nydirty()
fld = np.random.randn(x, y) + 1j*np.random.randn(x, y)
func0 = lambda x: _wscreen(nx, dy, w).conjugate()*x
func1 = lambda x: conf.apply_wscreen(x, w, True)
print(time_op(func0, fld), time_op(func1, fld))
fld = np.random.randn(nx, ny)
func0 = lambda x: _wscreen(nx, dx, w)*x.real
func1 = lambda x: conf.apply_wscreen(x, w, False)
print(time_op(func0, fld), time_op(func1, fld))
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