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
27b65d45
Commit
27b65d45
authored
Jun 03, 2017
by
Martin Reinecke
Browse files
cleanups
parent
2450982f
Changes
2
Show whitespace changes
Inline
Side-by-side
nifty/field.py
View file @
27b65d45
...
...
@@ -292,7 +292,8 @@ class Field(Loggable, Versionable, object):
if nbin==None : maximum number of bins is used
binbounds : array-like *optional*
Inner bounds of the bins (default : None).
if binbounds==None : bins are inferred. Overwrites nbins and log
Overrides nbin and logarithmic.
if binbounds==None : bins are inferred.
keep_phase_information : boolean, *optional*
If False, return a real-valued result containing the power spectrum
of the input Field.
...
...
@@ -401,8 +402,7 @@ class Field(Loggable, Versionable, object):
power_spectrum
=
cls
.
_calculate_power_spectrum
(
field_val
=
work_field
.
val
,
pindex
=
pindex
,
rho
=
rho
,
pdomain
=
power_domain
,
axes
=
work_field
.
domain_axes
[
space_index
])
# create the result field and put power_spectrum into it
...
...
@@ -419,8 +419,9 @@ class Field(Loggable, Versionable, object):
return
result_field
@
classmethod
def
_calculate_power_spectrum
(
cls
,
field_val
,
p
index
,
rho
,
axes
=
None
):
def
_calculate_power_spectrum
(
cls
,
field_val
,
p
domain
,
axes
=
None
):
pindex
=
pdomain
.
pindex
if
axes
is
not
None
:
pindex
=
cls
.
_shape_up_pindex
(
pindex
=
pindex
,
...
...
@@ -429,6 +430,7 @@ class Field(Loggable, Versionable, object):
axes
=
axes
)
power_spectrum
=
pindex
.
bincount
(
weights
=
field_val
,
axis
=
axes
)
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 @
27b65d45
...
...
@@ -42,7 +42,8 @@ class PowerSpace(Space):
if nbin == None, then nbin is set to the length of kindex.
binbounds : {list, array-like} *optional*
Boundaries between the power spectrum bins.
(If binbounds has n entries, there will be n+1 bins.)
(If binbounds has n entries, there will be n+1 bins, the first bin
starting at -inf, the last bin ending at +inf.)
(default : None)
if binbounds == None :
Calculates the bounds from the kindex while applying the
...
...
@@ -253,15 +254,16 @@ class PowerSpace(Space):
def
_do_binning
(
self
):
""" Computes pindex, kindex and rho according to self._binbounds.
"""
# if no binning is requested, compute the "natural" binning, i.e. there
# is one bin for every distinct k-vector length
if
self
.
_binbounds
is
None
:
self
.
_kindex
=
self
.
_k_array
.
unique
()
# prepare the distributed_data_object
# prepare the pindex object
self
.
_pindex
=
distributed_data_object
(
global_shape
=
self
.
_k_array
.
shape
,
dtype
=
np
.
int
,
distribution_strategy
=
self
.
_k_array
.
distribution_strategy
)
# if no binning is requested, compute the "natural" binning, i.e. there
# is one bin for every distinct k-vector length
if
self
.
_binbounds
is
None
:
self
.
_kindex
=
self
.
_k_array
.
unique
()
# store the local pindex data in the global_pindex d2o
self
.
_pindex
.
set_local_data
(
np
.
searchsorted
(
self
.
_kindex
,
self
.
_k_array
.
get_local_data
()))
...
...
@@ -269,10 +271,6 @@ class PowerSpace(Space):
# use the provided binbounds
else
:
self
.
_pindex
=
distributed_data_object
(
global_shape
=
self
.
_k_array
.
shape
,
dtype
=
np
.
int
,
distribution_strategy
=
self
.
_k_array
.
distribution_strategy
)
self
.
_pindex
.
set_local_data
(
np
.
searchsorted
(
self
.
_binbounds
,
self
.
_k_array
.
get_local_data
()))
self
.
_rho
=
self
.
_pindex
.
bincount
().
get_full_data
()
...
...
Write
Preview
Supports
Markdown
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