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
3c771b2f
Commit
3c771b2f
authored
Aug 23, 2017
by
Theo Steininger
Browse files
Merge branch 'master' of gitlab.mpcdf.mpg.de:ift/NIFTy
parents
9ee541a0
1c1b6377
Pipeline
#17228
passed with stages
in 25 minutes and 7 seconds
Changes
141
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/operators/invertible_operator_mixin/invertible_operator_mixin.py
View file @
3c771b2f
...
...
@@ -16,9 +16,9 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
nifty.minimization
import
ConjugateGradien
t
from
nifty
.field
import
Field
from
builtins
import
objec
t
from
...minimization
import
ConjugateGradient
from
..
.field
import
Field
class
InvertibleOperatorMixin
(
object
):
...
...
nifty/operators/laplace_operator/__init__.py
View file @
3c771b2f
# -*- coding: utf-8 -*-
from
laplace_operator
import
LaplaceOperator
from
.
laplace_operator
import
LaplaceOperator
nifty/operators/laplace_operator/laplace_operator.py
View file @
3c771b2f
...
...
@@ -17,11 +17,11 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import
numpy
as
np
from
nifty
.field
import
Field
from
nifty
.spaces.power_space
import
PowerSpace
from
nifty.operators
.endomorphic_operator
import
EndomorphicOperator
from
nifty
import
sqrt
import
nifty.
nifty_utilities
as
utilities
from
..
.field
import
Field
from
..
.spaces.power_space
import
PowerSpace
from
.
.endomorphic_operator
import
EndomorphicOperator
from
...
import
sqrt
from
...
import
nifty_utilities
as
utilities
class
LaplaceOperator
(
EndomorphicOperator
):
...
...
nifty/operators/linear_operator/__init__.py
View file @
3c771b2f
...
...
@@ -16,4 +16,4 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
linear_operator
import
LinearOperator
from
.
linear_operator
import
LinearOperator
nifty/operators/linear_operator/linear_operator.py
View file @
3c771b2f
...
...
@@ -16,15 +16,17 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
builtins
import
str
import
abc
from
nifty
.nifty_meta
import
NiftyMeta
from
..
.nifty_meta
import
NiftyMeta
from
keepers
import
Loggable
from
nifty.field
import
Field
import
nifty.nifty_utilities
as
utilities
from
...field
import
Field
from
...
import
nifty_utilities
as
utilities
from
future.utils
import
with_metaclass
class
LinearOperator
(
Loggable
,
object
):
class
LinearOperator
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
Loggable
,
object
)
,
{})))
:
"""NIFTY base class for linear operators.
The base NIFTY operator class is an abstract class from which
...
...
@@ -70,8 +72,6 @@ class LinearOperator(Loggable, object):
"""
__metaclass__
=
NiftyMeta
def
__init__
(
self
,
default_spaces
=
None
):
self
.
_default_spaces
=
default_spaces
...
...
nifty/operators/projection_operator/__init__.py
View file @
3c771b2f
...
...
@@ -16,4 +16,4 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
projection_operator
import
ProjectionOperator
from
.
projection_operator
import
ProjectionOperator
nifty/operators/projection_operator/projection_operator.py
View file @
3c771b2f
...
...
@@ -16,11 +16,11 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
builtins
import
range
import
numpy
as
np
from
nifty.field
import
Field
from
nifty.operators.endomorphic_operator
import
EndomorphicOperator
from
...field
import
Field
from
..endomorphic_operator
import
EndomorphicOperator
class
ProjectionOperator
(
EndomorphicOperator
):
...
...
@@ -99,7 +99,7 @@ class ProjectionOperator(EndomorphicOperator):
# the one of x, reshape the local data of self and apply it directly
active_axes
=
[]
if
spaces
is
None
:
active_axes
=
range
(
len
(
x
.
shape
))
active_axes
=
list
(
range
(
len
(
x
.
shape
))
)
else
:
for
space_index
in
spaces
:
active_axes
+=
x
.
domain_axes
[
space_index
]
...
...
@@ -124,10 +124,10 @@ class ProjectionOperator(EndomorphicOperator):
local_x
=
x
.
val
.
get_local_data
(
copy
=
False
)
l
=
len
(
local_projection_vector
.
shape
)
sublist_projector
=
range
(
l
)
sublist_projector
=
list
(
range
(
l
)
)
sublist_x
=
np
.
arange
(
len
(
local_x
.
shape
))
+
l
for
i
in
x
range
(
l
):
for
i
in
range
(
l
):
a
=
active_axes
[
i
]
sublist_x
[
a
]
=
i
...
...
nifty/operators/response_operator/__init__.py
View file @
3c771b2f
from
response_operator
import
ResponseOperator
from
.
response_operator
import
ResponseOperator
nifty/operators/response_operator/response_operator.py
View file @
3c771b2f
from
builtins
import
range
import
numpy
as
np
from
nifty
import
Field
,
\
FieldArray
from
nifty.operators
.linear_operator
import
LinearOperator
from
nifty.operators
.smoothing_operator
import
SmoothingOperator
from
nifty.operators
.composed_operator
import
ComposedOperator
from
nifty.operators
.diagonal_operator
import
DiagonalOperator
from
...
import
Field
,
\
FieldArray
from
.
.linear_operator
import
LinearOperator
from
.
.smoothing_operator
import
SmoothingOperator
from
.
.composed_operator
import
ComposedOperator
from
.
.diagonal_operator
import
DiagonalOperator
class
ResponseOperator
(
LinearOperator
):
...
...
@@ -79,8 +80,8 @@ class ResponseOperator(LinearOperator):
raise
ValueError
(
"Length of smoothing kernel and length of"
"exposure do not match"
)
for
ii
in
x
range
(
len
(
kernel_smoothing
)):
kernel_smoothing
[
ii
]
=
SmoothingOperator
(
self
.
_domain
[
ii
],
for
ii
in
range
(
len
(
kernel_smoothing
)):
kernel_smoothing
[
ii
]
=
SmoothingOperator
.
make
(
self
.
_domain
[
ii
],
sigma
=
sigma
[
ii
])
kernel_exposure
[
ii
]
=
DiagonalOperator
(
self
.
_domain
[
ii
],
diagonal
=
exposure
[
ii
])
...
...
nifty/operators/smoothing_operator/direct_smoothing_operator.py
View file @
3c771b2f
# -*- coding: utf8 -*-
from
__future__
import
division
from
builtins
import
range
import
numpy
as
np
from
d2o
import
STRATEGIES
...
...
@@ -71,7 +73,7 @@ class DirectSmoothingOperator(SmoothingOperator):
return
power
[
startindex
:
endindex
]
p_smooth
=
np
.
zeros
(
endindex
-
startindex
,
dtype
=
power
.
dtype
)
for
i
in
x
range
(
startindex
,
endindex
):
for
i
in
range
(
startindex
,
endindex
):
imin
=
max
(
startindex
,
ibegin
[
i
])
imax
=
min
(
endindex
,
ibegin
[
i
]
+
nval
[
i
])
p_smooth
[
imin
:
imax
]
+=
(
power
[
i
]
*
...
...
@@ -95,7 +97,7 @@ class DirectSmoothingOperator(SmoothingOperator):
ind
=
np
.
zeros
(
nd
-
1
,
dtype
=
np
.
int
)
i
=
np
.
zeros
(
nd
,
dtype
=
object
)
shape
=
arr
.
shape
indlist
=
np
.
asarray
(
range
(
nd
))
indlist
=
np
.
asarray
(
list
(
range
(
nd
))
)
indlist
=
np
.
delete
(
indlist
,
axis
)
i
[
axis
]
=
slice
(
None
,
None
)
outshape
=
np
.
asarray
(
shape
).
take
(
indlist
)
...
...
nifty/operators/smoothing_operator/fft_smoothing_operator.py
View file @
3c771b2f
# -*- coding: utf-8 -*-
from
builtins
import
range
import
numpy
as
np
from
nifty.operators.fft_operator
import
FFTOperator
...
...
@@ -47,7 +49,7 @@ class FFTSmoothingOperator(SmoothingOperator):
local_kernel
=
kernel
.
get_local_data
(
copy
=
False
)
reshaper
=
[
local_transformed_x
.
shape
[
i
]
if
i
in
coaxes
else
1
for
i
in
x
range
(
len
(
transformed_x
.
shape
))]
for
i
in
range
(
len
(
transformed_x
.
shape
))]
local_kernel
=
np
.
reshape
(
local_kernel
,
reshaper
)
# apply the kernel
...
...
nifty/operators/smoothing_operator/smoothing_operator.py
View file @
3c771b2f
...
...
@@ -89,51 +89,44 @@ class SmoothingOperator(EndomorphicOperator):
"""
_fft_smoothing_spaces
=
[
RGSpace
,
GLSpace
,
HPSpace
]
_direct_smoothing_spaces
=
[
PowerSpace
]
def
__new__
(
cls
,
domain
,
*
args
,
**
kwargs
):
if
cls
is
SmoothingOperator
:
domain
=
cls
.
_parse_domain
(
domain
)
if
len
(
domain
)
!=
1
:
raise
ValueError
(
"SmoothingOperator only accepts exactly one "
"space as input domain."
)
if
np
.
any
([
isinstance
(
domain
[
0
],
sp
)
for
sp
in
cls
.
_fft_smoothing_spaces
]):
from
.fft_smoothing_operator
import
FFTSmoothingOperator
return
super
(
SmoothingOperator
,
cls
).
__new__
(
FFTSmoothingOperator
,
domain
,
*
args
,
**
kwargs
)
elif
np
.
any
([
isinstance
(
domain
[
0
],
sp
)
for
sp
in
cls
.
_direct_smoothing_spaces
]):
from
.direct_smoothing_operator
import
DirectSmoothingOperator
return
super
(
SmoothingOperator
,
cls
).
__new__
(
DirectSmoothingOperator
,
domain
,
*
args
,
**
kwargs
)
else
:
raise
NotImplementedError
(
"For the given Space smoothing "
" is not available."
)
@
staticmethod
def
make
(
domain
,
sigma
,
log_distances
=
False
,
default_spaces
=
None
):
_fft_smoothing_spaces
=
[
RGSpace
,
GLSpace
,
HPSpace
]
_direct_smoothing_spaces
=
[
PowerSpace
]
domain
=
SmoothingOperator
.
_parse_domain
(
domain
)
if
len
(
domain
)
!=
1
:
raise
ValueError
(
"SmoothingOperator only accepts exactly one "
"space as input domain."
)
if
np
.
any
([
isinstance
(
domain
[
0
],
sp
)
for
sp
in
_fft_smoothing_spaces
]):
from
.fft_smoothing_operator
import
FFTSmoothingOperator
return
FFTSmoothingOperator
(
domain
,
sigma
,
log_distances
,
\
default_spaces
)
elif
np
.
any
([
isinstance
(
domain
[
0
],
sp
)
for
sp
in
_direct_smoothing_spaces
]):
from
.direct_smoothing_operator
import
DirectSmoothingOperator
return
DirectSmoothingOperator
(
domain
,
sigma
,
log_distances
,
\
default_spaces
)
else
:
return
super
(
SmoothingOperator
,
cls
).
__new__
(
cls
,
domain
,
*
args
,
**
kwargs
)
raise
NotImplementedError
(
"For the given Space smoothing "
" is not available."
)
# ---Overwritten properties and methods---
def
__init__
(
self
,
domain
,
sigma
,
log_distances
=
False
,
default_spaces
=
None
):
super
(
SmoothingOperator
,
self
).
__init__
(
default_spaces
)
# # the _parse_domain is already done in the __new__ method
# self._domain = self._parse_domain(domain)
# if len(self.domain) != 1:
# raise ValueError("SmoothingOperator only accepts exactly one "
# "space as input domain.")
self
.
_domain
=
self
.
_parse_domain
(
domain
)
if
len
(
self
.
_domain
)
!=
1
:
raise
ValueError
(
"SmoothingOperator only accepts exactly one "
"space as input domain."
)
self
.
_sigma
=
sigma
self
.
_log_distances
=
log_distances
...
...
nifty/operators/smoothness_operator/__init__.py
View file @
3c771b2f
# -*- coding: utf-8 -*-
from
smoothness_operator
import
SmoothnessOperator
from
.
smoothness_operator
import
SmoothnessOperator
nifty/operators/smoothness_operator/smoothness_operator.py
View file @
3c771b2f
from
nifty.spaces.power_space
import
PowerSpace
from
nifty.operators.endomorphic_operator
import
EndomorphicOperator
from
nifty.operators.laplace_operator
import
LaplaceOperator
from
...spaces.power_space
import
PowerSpace
from
..endomorphic_operator
import
EndomorphicOperator
from
..laplace_operator
import
LaplaceOperator
class
SmoothnessOperator
(
EndomorphicOperator
):
...
...
nifty/plotting/__init__.py
View file @
3c771b2f
from
descriptors
import
*
from
plots
import
*
from
figures
import
*
from
colormap
import
*
from
plotter
import
*
from
.
descriptors
import
*
from
.
plots
import
*
from
.
figures
import
*
from
.
colormap
import
*
from
.
plotter
import
*
nifty/plotting/colormap/__init__.py
View file @
3c771b2f
from
colormap
import
Colormap
import
colormaps
\ No newline at end of file
from
.colormap
import
Colormap
from
.
import
colormaps
nifty/plotting/colormap/colormap.py
View file @
3c771b2f
from
nifty.plotting.plotly_wrapper
import
PlotlyWrapper
from
__future__
import
division
from
builtins
import
str
from
..plotly_wrapper
import
PlotlyWrapper
class
Colormap
(
PlotlyWrapper
):
...
...
nifty/plotting/colormap/colormaps.py
View file @
3c771b2f
from
nifty.plotting
.colormap.colormap
import
Colormap
from
.
.colormap.colormap
import
Colormap
def
HighEnergyCmap
():
...
...
nifty/plotting/descriptors/__init__.py
View file @
3c771b2f
from
axis
import
Axis
from
line
import
Line
from
marker
import
Marker
from
.
axis
import
Axis
from
.
line
import
Line
from
.
marker
import
Marker
nifty/plotting/descriptors/axis.py
View file @
3c771b2f
# -*- coding: utf-8 -*-
from
nifty.plotting
.plotly_wrapper
import
PlotlyWrapper
from
.
.plotly_wrapper
import
PlotlyWrapper
class
Axis
(
PlotlyWrapper
):
...
...
Prev
1
2
3
4
5
6
7
8
Next
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