Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon Perkins
ducc
Commits
f5a8759a
Commit
f5a8759a
authored
Jun 03, 2020
by
Martin Reinecke
Browse files
more renaming
parent
1164fa5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
pyinterpol_ng/demo.py
View file @
f5a8759a
import
ducc_0_1.
pyinterpol_ng
as
pyinterpol_ng
import
ducc_0_1.
totalconvolve
as
totalconvolve
import
numpy
as
np
import
time
...
...
@@ -49,7 +49,7 @@ blm = random_alm(lmax, kmax, ncomp)
t0
=
time
.
time
()
# build interpolator object for slm and blm
foo
=
pyinterpol_ng
.
PyInterpolator
(
slm
,
blm
,
separate
,
lmax
,
kmax
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
foo
=
totalconvolve
.
PyInterpolator
(
slm
,
blm
,
separate
,
lmax
,
kmax
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
t1
=
time
.
time
()
-
t0
print
(
"Convolving sky and beam with lmax=mmax={}, kmax={}"
.
format
(
lmax
,
kmax
))
...
...
@@ -79,7 +79,7 @@ del foo
print
(
"Interpolating {} random angle triplets: {}s"
.
format
(
nptg
,
time
.
time
()
-
t0
))
t0
=
time
.
time
()
fake
=
np
.
random
.
uniform
(
0.
,
1.
,
(
ptg
.
shape
[
0
],
ncomp2
))
foo2
=
pyinterpol_ng
.
PyInterpolator
(
lmax
,
kmax
,
ncomp2
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
foo2
=
totalconvolve
.
PyInterpolator
(
lmax
,
kmax
,
ncomp2
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
t0
=
time
.
time
()
foo2
.
deinterpol
(
ptg
.
reshape
((
-
1
,
3
)),
fake
)
print
(
"Adjoint interpolation: {}s"
.
format
(
time
.
time
()
-
t0
))
...
...
@@ -93,7 +93,7 @@ print("Adjointness error: {}".format(v1/v2-1.))
# build interpolator object for slm and blm
t0
=
time
.
time
()
foo_f
=
pyinterpol_ng
.
PyInterpolator_f
(
slm
.
astype
(
np
.
complex64
),
blm
.
astype
(
np
.
complex64
),
separate
,
lmax
,
kmax
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
foo_f
=
totalconvolve
.
PyInterpolator_f
(
slm
.
astype
(
np
.
complex64
),
blm
.
astype
(
np
.
complex64
),
separate
,
lmax
,
kmax
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
print
(
"
\n
Single precision convolution/interpolation:"
)
print
(
"preparation of interpolation grid: {}s"
.
format
(
time
.
time
()
-
t0
))
...
...
@@ -105,7 +105,7 @@ t0=time.time()
bar_f
=
foo_f
.
interpol
(
ptgf
)
del
foo_f
print
(
"Interpolating {} random angle triplets: {}s"
.
format
(
nptg
,
time
.
time
()
-
t0
))
foo2_f
=
pyinterpol_ng
.
PyInterpolator_f
(
lmax
,
kmax
,
ncomp2
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
foo2_f
=
totalconvolve
.
PyInterpolator_f
(
lmax
,
kmax
,
ncomp2
,
epsilon
=
epsilon
,
ofactor
=
ofactor
,
nthreads
=
nthreads
)
t0
=
time
.
time
()
foo2_f
.
deinterpol
(
ptgf
.
reshape
((
-
1
,
3
)),
fake_f
)
print
(
"Adjoint interpolation: {}s"
.
format
(
time
.
time
()
-
t0
))
...
...
pyinterpol_ng/pyinterpol_ng.cc
View file @
f5a8759a
...
...
@@ -237,7 +237,7 @@ Notes
void
add_pyinterpol_ng
(
py
::
module
&
msup
)
{
using
namespace
pybind11
::
literals
;
auto
m
=
msup
.
def_submodule
(
"
pyinterpol_ng
"
);
auto
m
=
msup
.
def_submodule
(
"
totalconvolve
"
);
m
.
doc
()
=
pyinterpol_ng_DS
;
...
...
pyinterpol_ng/test/test_interpol_ng.py
View file @
f5a8759a
import
numpy
as
np
import
pytest
from
numpy.testing
import
assert_
import
ducc_0_1.
pyinterpol_ng
as
pyinterpol_ng
import
ducc_0_1.
totalconvolve
as
totalconvolve
import
ducc_0_1.sht
as
sht
pmp
=
pytest
.
mark
.
parametrize
...
...
@@ -59,7 +59,7 @@ def test_against_convolution(lkmax, ncomp, separate):
slm
=
random_alm
(
lmax
,
lmax
,
ncomp
)
blm
=
random_alm
(
lmax
,
kmax
,
ncomp
)
inter
=
pyinterpol_ng
.
PyInterpolator
(
slm
,
blm
,
separate
,
lmax
,
kmax
,
inter
=
totalconvolve
.
PyInterpolator
(
slm
,
blm
,
separate
,
lmax
,
kmax
,
epsilon
=
1e-8
,
nthreads
=
2
)
nptg
=
50
ptg
=
np
.
zeros
((
nptg
,
3
))
...
...
@@ -74,7 +74,7 @@ def test_against_convolution(lkmax, ncomp, separate):
res2
=
np
.
zeros
((
nptg
,
ncomp
))
for
c
in
range
(
ncomp
):
for
i
in
range
(
nptg
):
rbeam
=
pyinterpol_ng
.
rotate_alm
(
blm2
[:,
c
],
lmax
,
ptg
[
i
,
2
],
ptg
[
i
,
0
],
ptg
[
i
,
1
])
rbeam
=
totalconvolve
.
rotate_alm
(
blm2
[:,
c
],
lmax
,
ptg
[
i
,
2
],
ptg
[
i
,
0
],
ptg
[
i
,
1
])
res2
[
i
,
c
]
=
convolve
(
slm
[:,
c
],
rbeam
,
lmax
).
real
if
separate
:
_assert_close
(
res1
,
res2
,
1e-7
)
...
...
@@ -93,11 +93,11 @@ def test_adjointness(lkmax, ncomp, separate):
ptg
[:,
0
]
*=
np
.
pi
ptg
[:,
1
]
*=
2
*
np
.
pi
ptg
[:,
2
]
*=
2
*
np
.
pi
foo
=
pyinterpol_ng
.
PyInterpolator
(
slm
,
blm
,
separate
,
lmax
,
kmax
,
epsilon
=
1e-6
,
nthreads
=
2
)
foo
=
totalconvolve
.
PyInterpolator
(
slm
,
blm
,
separate
,
lmax
,
kmax
,
epsilon
=
1e-6
,
nthreads
=
2
)
inter1
=
foo
.
interpol
(
ptg
)
ncomp2
=
inter1
.
shape
[
1
]
fake
=
np
.
random
.
uniform
(
0.
,
1.
,
(
ptg
.
shape
[
0
],
ncomp2
))
foo2
=
pyinterpol_ng
.
PyInterpolator
(
lmax
,
kmax
,
ncomp2
,
epsilon
=
1e-6
,
nthreads
=
2
)
foo2
=
totalconvolve
.
PyInterpolator
(
lmax
,
kmax
,
ncomp2
,
epsilon
=
1e-6
,
nthreads
=
2
)
foo2
.
deinterpol
(
ptg
.
reshape
((
-
1
,
3
)),
fake
)
bla
=
foo2
.
getSlm
(
blm
)
v1
=
np
.
sum
([
myalmdot
(
slm
[:,
c
],
bla
[:,
c
],
lmax
,
lmax
,
0
)
for
c
in
range
(
ncomp
)])
...
...
pyinterpol_ng/usage.py
View file @
f5a8759a
# Short usage demo for the interpol_ng module
import
pyinterpol_ng
import
ducc_0_1.totalconvolve
as
totalconvolve
import
numpy
as
np
...
...
@@ -44,7 +44,7 @@ ptg[:,2]*=2*np.pi # psi
# so we set `separate` to `False`
print
(
"classic interpolator setup..."
)
inter_classic
=
pyinterpol_ng
.
PyInterpolator
(
inter_classic
=
totalconvolve
.
PyInterpolator
(
slm
,
blm
,
separate
=
False
,
lmax
=
lmax
,
kmax
=
kmax
,
epsilon
=
1e-4
,
nthreads
=
2
)
print
(
"...done"
)
...
...
@@ -66,7 +66,7 @@ del inter_classic
separate
=
True
print
(
"HWP interpolator setup..."
)
inter_hwp
=
pyinterpol_ng
.
PyInterpolator
(
inter_hwp
=
totalconvolve
.
PyInterpolator
(
slm
,
blm
,
separate
=
True
,
lmax
=
lmax
,
kmax
=
kmax
,
epsilon
=
1e-4
,
nthreads
=
2
)
print
(
"...done"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment