Commit ff944a23 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

cleanup

parent 73edbd97
Pipeline #76448 passed with stages
in 12 minutes and 59 seconds
...@@ -57,7 +57,7 @@ blm = random_alm(lmax, kmax, ncomp) ...@@ -57,7 +57,7 @@ blm = random_alm(lmax, kmax, ncomp)
t0 = time.time() t0 = time.time()
# build interpolator object for slm and blm # build interpolator object for slm and blm
foo = totalconvolve.PyInterpolator(slm, blm, separate, lmax, kmax, epsilon=1e-4, nthreads=2) foo = totalconvolve.Interpolator(slm, blm, separate, lmax, kmax, epsilon=1e-4, nthreads=2)
print("setup time: ", time.time()-t0) print("setup time: ", time.time()-t0)
nth = lmax+1 nth = lmax+1
nph = 2*lmax+1 nph = 2*lmax+1
......
...@@ -50,9 +50,9 @@ blm = random_alm(lmax, kmax, ncomp) ...@@ -50,9 +50,9 @@ blm = random_alm(lmax, kmax, ncomp)
t0 = time.time() t0 = time.time()
# build interpolator object for slm and blm # build interpolator object for slm and blm
foo = totalconvolve.PyInterpolator(slm, blm, separate, lmax, kmax, foo = totalconvolve.Interpolator(slm, blm, separate, lmax, kmax,
epsilon=epsilon, ofactor=ofactor, epsilon=epsilon, ofactor=ofactor,
nthreads=nthreads) nthreads=nthreads)
t1 = time.time()-t0 t1 = time.time()-t0
print("Convolving sky and beam with lmax=mmax={}, kmax={}".format(lmax, kmax)) print("Convolving sky and beam with lmax=mmax={}, kmax={}".format(lmax, kmax))
...@@ -82,7 +82,7 @@ del foo ...@@ -82,7 +82,7 @@ del foo
print("Interpolating {} random angle triplets: {}s".format(nptg, time.time()-t0)) print("Interpolating {} random angle triplets: {}s".format(nptg, time.time()-t0))
t0 = time.time() t0 = time.time()
fake = rng.uniform(0., 1., (ptg.shape[0], ncomp2)) fake = rng.uniform(0., 1., (ptg.shape[0], ncomp2))
foo2 = totalconvolve.PyInterpolator(lmax, kmax, ncomp2, epsilon=epsilon, ofactor=ofactor, nthreads=nthreads) foo2 = totalconvolve.Interpolator(lmax, kmax, ncomp2, epsilon=epsilon, ofactor=ofactor, nthreads=nthreads)
t0 = time.time() t0 = time.time()
foo2.deinterpol(ptg.reshape((-1, 3)), fake) foo2.deinterpol(ptg.reshape((-1, 3)), fake)
print("Adjoint interpolation: {}s".format(time.time()-t0)) print("Adjoint interpolation: {}s".format(time.time()-t0))
...@@ -96,7 +96,7 @@ print("Adjointness error: {}".format(v1/v2-1.)) ...@@ -96,7 +96,7 @@ print("Adjointness error: {}".format(v1/v2-1.))
# build interpolator object for slm and blm # build interpolator object for slm and blm
t0 = time.time() t0 = time.time()
foo_f = totalconvolve.PyInterpolator_f(slm.astype(np.complex64), blm.astype(np.complex64), separate, lmax, kmax, epsilon=epsilon, ofactor=ofactor, nthreads=nthreads) foo_f = totalconvolve.Interpolator_f(slm.astype(np.complex64), blm.astype(np.complex64), separate, lmax, kmax, epsilon=epsilon, ofactor=ofactor, nthreads=nthreads)
print("\nSingle precision convolution/interpolation:") print("\nSingle precision convolution/interpolation:")
print("preparation of interpolation grid: {}s".format(time.time()-t0)) print("preparation of interpolation grid: {}s".format(time.time()-t0))
...@@ -108,7 +108,7 @@ t0 = time.time() ...@@ -108,7 +108,7 @@ t0 = time.time()
bar_f = foo_f.interpol(ptgf) bar_f = foo_f.interpol(ptgf)
del foo_f del foo_f
print("Interpolating {} random angle triplets: {}s".format(nptg, time.time()-t0)) print("Interpolating {} random angle triplets: {}s".format(nptg, time.time()-t0))
foo2_f = totalconvolve.PyInterpolator_f(lmax, kmax, ncomp2, epsilon=epsilon, ofactor=ofactor, nthreads=nthreads) foo2_f = totalconvolve.Interpolator_f(lmax, kmax, ncomp2, epsilon=epsilon, ofactor=ofactor, nthreads=nthreads)
t0 = time.time() t0 = time.time()
foo2_f.deinterpol(ptgf.reshape((-1, 3)), fake_f) foo2_f.deinterpol(ptgf.reshape((-1, 3)), fake_f)
print("Adjoint interpolation: {}s".format(time.time()-t0)) print("Adjoint interpolation: {}s".format(time.time()-t0))
......
...@@ -44,7 +44,7 @@ ptg[:, 2] *= 2*np.pi # psi ...@@ -44,7 +44,7 @@ ptg[:, 2] *= 2*np.pi # psi
# so we set `separate` to `False` # so we set `separate` to `False`
print("classic interpolator setup...") print("classic interpolator setup...")
inter_classic = totalconvolve.PyInterpolator( inter_classic = totalconvolve.Interpolator(
slm, blm, separate=False, lmax=lmax, kmax=kmax, epsilon=1e-4, nthreads=2) slm, blm, separate=False, lmax=lmax, kmax=kmax, epsilon=1e-4, nthreads=2)
print("...done") print("...done")
...@@ -66,7 +66,7 @@ del inter_classic ...@@ -66,7 +66,7 @@ del inter_classic
separate = True separate = True
print("HWP interpolator setup...") print("HWP interpolator setup...")
inter_hwp = totalconvolve.PyInterpolator( inter_hwp = totalconvolve.Interpolator(
slm, blm, separate=True, lmax=lmax, kmax=kmax, epsilon=1e-4, nthreads=2) slm, blm, separate=True, lmax=lmax, kmax=kmax, epsilon=1e-4, nthreads=2)
print("...done") print("...done")
......
...@@ -61,8 +61,8 @@ def test_against_convolution(lkmax, ncomp, separate): ...@@ -61,8 +61,8 @@ def test_against_convolution(lkmax, ncomp, separate):
slm = random_alm(rng, lmax, lmax, ncomp) slm = random_alm(rng, lmax, lmax, ncomp)
blm = random_alm(rng, lmax, kmax, ncomp) blm = random_alm(rng, lmax, kmax, ncomp)
inter = totalconvolve.PyInterpolator(slm, blm, separate, lmax, kmax, inter = totalconvolve.Interpolator(slm, blm, separate, lmax, kmax,
epsilon=1e-8, nthreads=2) epsilon=1e-8, nthreads=2)
nptg = 50 nptg = 50
ptg = np.zeros((nptg, 3)) ptg = np.zeros((nptg, 3))
ptg[:, 0] = rng.uniform(0, np.pi, nptg) ptg[:, 0] = rng.uniform(0, np.pi, nptg)
...@@ -98,11 +98,11 @@ def test_adjointness(lkmax, ncomp, separate): ...@@ -98,11 +98,11 @@ def test_adjointness(lkmax, ncomp, separate):
ptg[:, 0] *= np.pi ptg[:, 0] *= np.pi
ptg[:, 1] *= 2*np.pi ptg[:, 1] *= 2*np.pi
ptg[:, 2] *= 2*np.pi ptg[:, 2] *= 2*np.pi
foo = totalconvolve.PyInterpolator(slm, blm, separate, lmax, kmax, epsilon=1e-6, nthreads=2) foo = totalconvolve.Interpolator(slm, blm, separate, lmax, kmax, epsilon=1e-6, nthreads=2)
inter1 = foo.interpol(ptg) inter1 = foo.interpol(ptg)
ncomp2 = inter1.shape[1] ncomp2 = inter1.shape[1]
fake = rng.uniform(0., 1., (ptg.shape[0], ncomp2)) fake = rng.uniform(0., 1., (ptg.shape[0], ncomp2))
foo2 = totalconvolve.PyInterpolator(lmax, kmax, ncomp2, epsilon=1e-6, nthreads=2) foo2 = totalconvolve.Interpolator(lmax, kmax, ncomp2, epsilon=1e-6, nthreads=2)
foo2.deinterpol(ptg.reshape((-1, 3)), fake) foo2.deinterpol(ptg.reshape((-1, 3)), fake)
bla = foo2.getSlm(blm) bla = foo2.getSlm(blm)
v1 = np.sum([myalmdot(slm[:, c], bla[:, c], lmax, lmax, 0) for c in range(ncomp)]) v1 = np.sum([myalmdot(slm[:, c], bla[:, c], lmax, lmax, 0) for c in range(ncomp)])
......
...@@ -227,7 +227,7 @@ void add_totalconvolve(py::module &msup) ...@@ -227,7 +227,7 @@ void add_totalconvolve(py::module &msup)
m.doc() = totalconvolve_DS; m.doc() = totalconvolve_DS;
using inter_d = PyInterpolator<double>; using inter_d = PyInterpolator<double>;
py::class_<inter_d> (m, "PyInterpolator", py::module_local(), pyinterpolator_DS) py::class_<inter_d> (m, "Interpolator", py::module_local(), pyinterpolator_DS)
.def(py::init<const py::array &, const py::array &, bool, int64_t, int64_t, double, double, int>(), .def(py::init<const py::array &, const py::array &, bool, int64_t, int64_t, double, double, int>(),
initnormal_DS, "sky"_a, "beam"_a, "separate"_a, "lmax"_a, "kmax"_a, "epsilon"_a, "ofactor"_a=1.5, initnormal_DS, "sky"_a, "beam"_a, "separate"_a, "lmax"_a, "kmax"_a, "epsilon"_a, "ofactor"_a=1.5,
"nthreads"_a=0) "nthreads"_a=0)
...@@ -238,7 +238,7 @@ void add_totalconvolve(py::module &msup) ...@@ -238,7 +238,7 @@ void add_totalconvolve(py::module &msup)
.def ("getSlm", &inter_d::pygetSlm, getSlm_DS, "beam"_a) .def ("getSlm", &inter_d::pygetSlm, getSlm_DS, "beam"_a)
.def ("support", &inter_d::support); .def ("support", &inter_d::support);
using inter_f = PyInterpolator<float>; using inter_f = PyInterpolator<float>;
py::class_<inter_f> (m, "PyInterpolator_f", py::module_local(), pyinterpolator_DS) py::class_<inter_f> (m, "Interpolator_f", py::module_local(), pyinterpolator_DS)
.def(py::init<const py::array &, const py::array &, bool, int64_t, int64_t, float, float, int>(), .def(py::init<const py::array &, const py::array &, bool, int64_t, int64_t, float, float, int>(),
initnormal_DS, "sky"_a, "beam"_a, "separate"_a, "lmax"_a, "kmax"_a, "epsilon"_a, "ofactor"_a=1.5f, initnormal_DS, "sky"_a, "beam"_a, "separate"_a, "lmax"_a, "kmax"_a, "epsilon"_a, "ofactor"_a=1.5f,
"nthreads"_a=0) "nthreads"_a=0)
......
...@@ -9,6 +9,7 @@ import pybind11 ...@@ -9,6 +9,7 @@ import pybind11
pkgname = 'ducc0' pkgname = 'ducc0'
version = '0.1.0' version = '0.1.0'
def _get_files_by_suffix(directory, suffix): def _get_files_by_suffix(directory, suffix):
path = directory path = directory
iterable_sources = (iglob(os.path.join(root, '*.'+suffix)) iterable_sources = (iglob(os.path.join(root, '*.'+suffix))
......
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