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
Neel Shah
NIFTy
Commits
a6a8de75
Commit
a6a8de75
authored
Oct 06, 2017
by
Theo Steininger
Browse files
Set PowerSpace.weight to bin-volume.
parent
fe8f6318
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty/spaces/power_space/power_space.py
View file @
a6a8de75
...
...
@@ -85,10 +85,9 @@ class PowerSpace(Space):
# ---Overwritten properties and methods---
def
__init__
(
self
,
harmonic_partner
,
distribution_strategy
=
None
,
volume_type
=
'rho'
,
binbounds
=
None
):
binbounds
=
None
):
super
(
PowerSpace
,
self
).
__init__
()
self
.
_needed_for_hash
+=
[
'_harmonic_partner'
,
'_binbounds'
,
'volume_type'
]
self
.
_needed_for_hash
+=
[
'_harmonic_partner'
,
'_binbounds'
]
if
distribution_strategy
is
None
:
distribution_strategy
=
gc
[
'default_distribution_strategy'
]
...
...
@@ -127,8 +126,6 @@ class PowerSpace(Space):
(
self
.
_binbounds
,
self
.
_pindex
,
self
.
_kindex
,
self
.
_rho
)
=
\
self
.
_powerIndexCache
[
key
]
self
.
volume_type
=
str
(
volume_type
)
@
staticmethod
def
_compute_pindex
(
harmonic_partner
,
distance_array
,
binbounds
,
distribution_strategy
):
...
...
@@ -201,25 +198,14 @@ class PowerSpace(Space):
binbounds
=
self
.
_binbounds
)
def
weight
(
self
,
x
,
power
,
axes
,
inplace
=
False
):
if
self
.
volume_type
==
'unit'
:
if
inplace
:
return
x
else
:
return
x
.
copy
()
if
self
.
volume_type
==
'rho'
:
weight
=
self
.
rho
elif
self
.
volume_type
==
'volume'
:
try
:
weight
=
self
.
_volume_weight
except
AttributeError
:
k
=
self
.
kindex
weight
=
np
.
empty_like
(
k
)
weight
[
1
:
-
1
]
=
(
k
[
2
:]
-
k
[:
-
2
])
/
2
weight
[
0
]
=
k
[
1
]
-
k
[
0
]
weight
[
-
1
]
=
k
[
-
1
]
-
k
[
-
2
]
self
.
_volume_weight
=
weight
try
:
weight
=
self
.
_volume_weight
except
AttributeError
:
from
...field
import
Field
weight_field
=
Field
(
domain
=
self
.
harmonic_partner
,
val
=
1
).
weight
()
self
.
_volume_weight
=
\
self
.
pindex
.
bincount
(
weights
=
weight_field
.
val
).
get_full_data
()
weight
=
self
.
_volume_weight
reshaper
=
[
1
,
]
*
len
(
x
.
shape
)
# we know len(axes) is always 1
...
...
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