Skip to content
GitLab
Menu
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
11c94b91
Commit
11c94b91
authored
Jun 04, 2017
by
Martin Reinecke
Browse files
PEP8
parent
180eefc6
Pipeline
#13325
passed with stage
in 5 minutes and 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/field.py
View file @
11c94b91
...
...
@@ -418,6 +418,8 @@ class Field(Loggable, Versionable, object):
def
_calculate_power_spectrum
(
cls
,
field_val
,
pdomain
,
axes
=
None
):
pindex
=
pdomain
.
pindex
# MR FIXME: how about iterating over slices, instead of replicating
# pindex? Would save memory and probably isn't slower.
if
axes
is
not
None
:
pindex
=
cls
.
_shape_up_pindex
(
pindex
=
pindex
,
...
...
@@ -426,7 +428,7 @@ class Field(Loggable, Versionable, object):
axes
=
axes
)
power_spectrum
=
pindex
.
bincount
(
weights
=
field_val
,
axis
=
axes
)
rho
=
pdomain
.
rho
rho
=
pdomain
.
rho
if
axes
is
not
None
:
new_rho_shape
=
[
1
,
]
*
len
(
power_spectrum
.
shape
)
new_rho_shape
[
axes
[
0
]]
=
len
(
rho
)
...
...
nifty/spaces/power_space/power_space.py
View file @
11c94b91
...
...
@@ -85,12 +85,13 @@ class PowerSpace(Space):
super
(
PowerSpace
,
self
).
__init__
()
self
.
_ignore_for_hash
+=
[
'_pindex'
,
'_kindex'
,
'_rho'
]
if
not
(
isinstance
(
harmonic_partner
,
Space
)
and
\
if
not
(
isinstance
(
harmonic_partner
,
Space
)
and
harmonic_partner
.
harmonic
):
raise
ValueError
(
"harmonic_partner must be a harmonic space."
)
self
.
_harmonic_partner
=
harmonic_partner
dists
=
self
.
_harmonic_partner
.
get_distance_array
(
distribution_strategy
)
dists
=
self
.
_harmonic_partner
.
get_distance_array
(
distribution_strategy
)
self
.
_binbounds
=
None
if
logarithmic
is
None
and
nbin
is
None
and
binbounds
is
None
:
...
...
@@ -102,7 +103,7 @@ class PowerSpace(Space):
# neighbors.
# I'm appending the last value*2 to the array to treat the
# rightmost point correctly.
tmp
=
tmp
[
np
.
diff
(
np
.
append
(
tmp
,
2
*
tmp
[
-
1
]
))
>
tol
]
#FIXME: np.r_ ??
tmp
=
tmp
[
np
.
diff
(
np
.
r_
[
tmp
,
2
*
tmp
[
-
1
]
])
>
tol
]
bb
=
tmp
[
0
:
-
1
]
+
0.5
*
np
.
diff
(
tmp
)
else
:
if
binbounds
is
not
None
:
...
...
@@ -129,7 +130,7 @@ class PowerSpace(Space):
(
k
[
-
1
]
-
0.5
*
(
k
[
2
]
+
k
[
1
]))
/
dk
+
2.5
))
dk
=
(
k
[
-
1
]
-
0.5
*
(
k
[
2
]
+
k
[
1
]))
/
(
nbin
-
2.5
)
bb
=
np
.
r_
[
0.5
*
(
3
*
k
[
1
]
-
k
[
2
]),
0.5
*
(
k
[
1
]
+
k
[
2
])
+
dk
*
np
.
arange
(
nbin
-
2
)]
0.5
*
(
k
[
1
]
+
k
[
2
])
+
dk
*
np
.
arange
(
nbin
-
2
)]
if
(
logarithmic
):
bb
=
np
.
exp
(
bb
)
self
.
_binbounds
=
tuple
(
bb
)
...
...
@@ -263,7 +264,8 @@ class PowerSpace(Space):
def
_to_hdf5
(
self
,
hdf5_group
):
hdf5_group
.
attrs
[
'binbounds'
]
=
str
(
self
.
_binbounds
)
hdf5_group
.
attrs
[
'distribution_strategy'
]
=
self
.
_pindex
.
distribution_strategy
hdf5_group
.
attrs
[
'distribution_strategy'
]
=
\
self
.
_pindex
.
distribution_strategy
return
{
'harmonic_partner'
:
self
.
harmonic_partner
,
...
...
@@ -274,4 +276,4 @@ class PowerSpace(Space):
hp
=
repository
.
get
(
'harmonic_partner'
,
hdf5_group
)
exec
(
"bb = "
+
hdf5_group
.
attrs
[
'binbounds'
])
ds
=
hdf5_group
.
attrs
[
'distribution_strategy'
]
return
PowerSpace
(
hp
,
ds
,
binbounds
=
bb
)
return
PowerSpace
(
hp
,
ds
,
binbounds
=
bb
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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