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
9c1f1eed
Commit
9c1f1eed
authored
Jul 22, 2016
by
theos
Browse files
PowerSpace is now (more or less) stable.
parent
23f4e962
Changes
6
Hide whitespace changes
Inline
Side-by-side
__init__.py
View file @
9c1f1eed
...
...
@@ -92,4 +92,10 @@ from demos import get_demo_dir
from
pickling
import
_pickle_method
,
_unpickle_method
#import pyximport; pyximport.install(pyimport = True)
from
transformations
import
tf
as
transformator
from
transformations
import
TransformationFactory
,
\
GLLMTransformation
,
\
HPLMTransformation
,
\
LMGLTransformation
,
\
LMHPTransformation
,
\
RGRGTransformation
nifty_paradict.py
View file @
9c1f1eed
...
...
@@ -193,14 +193,11 @@ class hp_space_paradict(space_paradict):
class
power_space_paradict
(
space_paradict
):
def
__init__
(
self
,
pindex
,
kindex
,
rho
,
pundex
,
k_array
,
config
,
harmonic_domain
):
def
__init__
(
self
,
pindex
,
kindex
,
rho
,
config
,
harmonic_domain
):
space_paradict
.
__init__
(
self
,
pindex
=
pindex
,
kindex
=
kindex
,
rho
=
rho
,
pundex
=
pundex
,
k_array
=
k_array
,
config
=
config
,
harmonic_domain
=
harmonic_domain
)
...
...
@@ -221,4 +218,4 @@ class power_space_paradict(space_paradict):
def
__hash__
(
self
):
return
(
hash
(
frozenset
(
self
.
parameters
[
'config'
].
items
()))
^
(
hash
(
self
.
parameters
[
'domain'
])
/
131
))
(
hash
(
self
.
parameters
[
'
harmonic_
domain'
])
/
131
))
power/power_space.py
View file @
9c1f1eed
...
...
@@ -3,8 +3,10 @@
import
numpy
as
np
from
d2o
import
STRATEGIES
from
nifty.config
import
about
from
nifty.space
import
Space
from
nifty.nifty_paradict
import
power_space_paradict
from
nifty.nifty_utilities
import
cast_axis_to_tuple
class
PowerSpace
(
Space
):
...
...
@@ -24,6 +26,37 @@ class PowerSpace(Space):
def
shape
(
self
):
return
self
.
paradict
[
'kindex'
].
shape
@
property
def
dim
(
self
):
return
self
.
shape
[
0
]
@
property
def
total_volume
(
self
):
# every power-pixel has a volume of 1
return
reduce
(
lambda
x
,
y
:
x
*
y
,
self
.
paradict
[
'pindex'
].
shape
)
def
weight
(
self
,
x
,
power
=
1
,
axes
=
None
):
total_shape
=
x
.
shape
axes
=
cast_axis_to_tuple
(
axes
,
len
(
total_shape
))
if
len
(
axes
)
!=
1
:
raise
ValueError
(
about
.
_errors
.
cstring
(
"ERROR: axes must be of length 1."
))
reshaper
=
[
1
,
]
*
len
(
total_shape
)
reshaper
[
axes
[
0
]]
=
self
.
shape
[
0
]
weight
=
self
.
paradict
[
'rho'
].
reshape
(
reshaper
)
if
power
!=
1
:
weight
=
weight
**
power
result_x
=
x
*
weight
return
result_x
def
compute_k_array
(
self
,
distribution_strategy
):
raise
NotImplementedError
(
about
.
_errors
.
cstring
(
"ERROR: There is no k_array implementation for PowerSpace."
))
def
calculate_power_spectrum
(
self
,
x
,
axes
=
None
):
fieldabs
=
abs
(
x
)
**
2
pindex
=
self
.
paradict
[
'pindex'
]
...
...
space.py
View file @
9c1f1eed
...
...
@@ -305,12 +305,8 @@ class Space(object):
"ERROR: There is no generic k_array for Space base class."
))
def
smooth
(
self
,
x
,
**
kwargs
):
"""
Raises an error since smoothing is ill-defined on an unstructured
space.
"""
raise
AttributeError
(
about
.
_errors
.
cstring
(
"ERROR:
smoothing ill-defined for (unstructured) point space
."
))
"ERROR:
There is no generic smoothing for Space base class
."
))
def
get_plot
(
self
,
x
,
title
=
""
,
vmin
=
None
,
vmax
=
None
,
unit
=
None
,
norm
=
None
,
other
=
None
,
legend
=
False
,
save
=
None
,
**
kwargs
):
...
...
transformations/__init__.py
View file @
9c1f1eed
from
rgrgtransformation
import
RGRGTransformation
from
gllmtransformation
import
GLLMTransformation
from
hplmtransformation
import
HPLMTransformation
from
lmgltransformation
import
LMGLTransformation
from
lmhptransformation
import
LMHPTransformation
from
transformation_factory
import
TransformationFactory
tf
=
TransformationFactory
()
transformations/rgrgtransformation.py
View file @
9c1f1eed
...
...
@@ -67,7 +67,7 @@ class RGRGTransformation(Transformation):
else
:
temp
=
np
.
empty_like
(
domain
.
paradict
[
'zerocenter'
])
temp
[:]
=
zerocenter
zerocenter
=
temp
zerocenter
=
temp
# calculate the initialization parameters
distances
=
1
/
(
np
.
array
(
domain
.
paradict
[
'shape'
])
*
...
...
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