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
ift
NIFTy
Commits
13a563de
Commit
13a563de
authored
Sep 21, 2016
by
Jait Dixit
Browse files
WIP: Update lm_space distance_array method
- Remove mmax. Now, lmax == mmax - Create index and l-number on the fly
parent
6218e99b
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty/spaces/lm_space/lm_helper.pyx
View file @
13a563de
import
numpy
as
np
import
numpy
as
np
cimport
numpy
as
np
cimport
numpy
as
np
cpdef
_distance_array_helper
(
np
.
int_t
x
,
np
.
ndarray
[
np
.
int_t
]
l
,
cpdef
_distance_array_helper
(
np
.
ndarray
[
np
.
int_t
]
index_array
,
np
.
int_t
lmax
):
np
.
int_t
original_size
,
np
.
int_t
lmax
):
cdef
np
.
int
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
cdef
np
.
int
size
=
(
lmax
+
1
)
*
(
lmax
+
1
)
cdef
np
.
ndarray
res
=
np
.
zeros
([
size
],
dtype
=
np
.
float128
)
cdef
np
.
ndarray
res
=
np
.
zeros
([
len
(
index_array
)],
dtype
=
np
.
float128
)
res
[
0
:
lmax
+
1
]
=
np
.
arange
(
lmax
+
1
)
for
i
in
xrange
(
original_size
-
lmax
-
1
):
for
idx
,
index_full
in
enumerate
(
index_array
):
res
[
i
*
2
+
lmax
+
1
]
=
l
[
i
+
lmax
+
1
]
if
index_full
<=
lmax
:
res
[
i
*
2
+
lmax
+
1
]
=
l
[
i
+
lmax
+
1
]
index_half
=
index_full
else
:
index_half
=
(
index_full
+
lmax
+
1
)
/
2
;
m
=
(
np
.
ceil
(((
2
*
lmax
+
1
)
-
np
.
sqrt
((
2
*
lmax
+
1
)
**
2
-
8
*
(
index_half
-
lmax
)))
/
2
)).
astype
(
int
)
res
[
idx
]
=
index_half
-
m
*
(
2
*
lmax
+
1
-
m
)
//
2
return
res
[
x
]
return
res
nifty/spaces/lm_space/lm_space.py
View file @
13a563de
...
@@ -75,7 +75,7 @@ class LMSpace(Space):
...
@@ -75,7 +75,7 @@ class LMSpace(Space):
Pixel volume of the :py:class:`lm_space`, which is always 1.
Pixel volume of the :py:class:`lm_space`, which is always 1.
"""
"""
def
__init__
(
self
,
lmax
,
mmax
=
None
,
dtype
=
np
.
dtype
(
'complex128'
)):
def
__init__
(
self
,
lmax
,
dtype
=
np
.
dtype
(
'complex128'
)):
"""
"""
Sets the attributes for an lm_space class instance.
Sets the attributes for an lm_space class instance.
...
@@ -111,7 +111,6 @@ class LMSpace(Space):
...
@@ -111,7 +111,6 @@ class LMSpace(Space):
super
(
LMSpace
,
self
).
__init__
(
dtype
)
super
(
LMSpace
,
self
).
__init__
(
dtype
)
self
.
_lmax
=
self
.
_parse_lmax
(
lmax
)
self
.
_lmax
=
self
.
_parse_lmax
(
lmax
)
self
.
_mmax
=
self
.
_parse_mmax
(
mmax
)
def
distance_array
(
self
,
distribution_strategy
):
def
distance_array
(
self
,
distribution_strategy
):
dists
=
arange
(
dists
=
arange
(
...
@@ -122,7 +121,7 @@ class LMSpace(Space):
...
@@ -122,7 +121,7 @@ class LMSpace(Space):
l
=
hp
.
Alm
.
getlm
(
lmax
=
self
.
lmax
)[
0
]
l
=
hp
.
Alm
.
getlm
(
lmax
=
self
.
lmax
)[
0
]
dists
=
dists
.
apply_scalar_function
(
dists
=
dists
.
apply_scalar_function
(
lambda
x
:
_distance_array_helper
(
lambda
x
:
_distance_array_helper
(
int
(
x
),
l
,
hp
.
Alm
.
getsize
(
self
.
lmax
)
,
self
.
lmax
x
,
self
.
lmax
)
)
)
)
...
@@ -177,7 +176,7 @@ class LMSpace(Space):
...
@@ -177,7 +176,7 @@ class LMSpace(Space):
@
property
@
property
def
mmax
(
self
):
def
mmax
(
self
):
return
self
.
_
m
max
return
self
.
_
l
max
def
_parse_lmax
(
self
,
lmax
):
def
_parse_lmax
(
self
,
lmax
):
lmax
=
np
.
int
(
lmax
)
lmax
=
np
.
int
(
lmax
)
...
@@ -189,20 +188,3 @@ class LMSpace(Space):
...
@@ -189,20 +188,3 @@ class LMSpace(Space):
about
.
warnings
.
cprint
(
about
.
warnings
.
cprint
(
"WARNING: unrecommended parameter (lmax <> 2*n+1)."
)
"WARNING: unrecommended parameter (lmax <> 2*n+1)."
)
return
lmax
return
lmax
def
_parse_mmax
(
self
,
mmax
):
if
mmax
is
None
:
mmax
=
self
.
lmax
else
:
mmax
=
int
(
mmax
)
if
mmax
<
1
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: mmax < 1 is not allowed."
))
if
mmax
>
self
.
lmax
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: mmax > lmax is not allowed."
))
if
mmax
!=
self
.
lmax
:
about
.
warnings
.
cprint
(
"WARNING: unrecommended parameter combination (mmax <> lmax)."
)
return
mmax
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