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
ff879f9c
Commit
ff879f9c
authored
Feb 18, 2018
by
Martin Reinecke
Browse files
lots of simplifications
parent
d4a9bd66
Pipeline
#25104
passed with stages
in 6 minutes and 43 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/critical_filtering.py
View file @
ff879f9c
...
...
@@ -28,10 +28,7 @@ if __name__ == "__main__":
sh
=
ift
.
power_synthesize
(
sp
,
real_signal
=
True
)
# Choose the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.01)
Instrument
=
ift
.
ScalingOperator
(
1.
,
s_space
)
# Instrument._diagonal.val[200:400, 200:400] = 0
# Instrument._diagonal.val[64:512-64, 64:512-64] = 0
# Add a harmonic transformation to the instrument
R
=
Instrument
*
HT
...
...
@@ -40,10 +37,7 @@ if __name__ == "__main__":
signal_to_noise
=
1.
noise_amplitude
=
noiseless_data
.
val
.
std
()
/
signal_to_noise
N
=
ift
.
ScalingOperator
(
noise_amplitude
**
2
,
s_space
)
n
=
ift
.
Field
.
from_random
(
domain
=
s_space
,
random_type
=
'normal'
,
std
=
noise_amplitude
,
mean
=
0
)
n
=
ift
.
Field
.
from_random
(
"normal"
,
s_space
,
std
=
noise_amplitude
,
mean
=
0
)
# Create mock data
d
=
noiseless_data
+
n
...
...
@@ -54,7 +48,6 @@ if __name__ == "__main__":
binbounds
=
p_space
.
binbounds
))
data_power
=
ift
.
log
(
ift
.
power_analyze
(
HT
.
adjoint_times
(
d
),
binbounds
=
p_space
.
binbounds
))
d_data
=
d
.
val
plotdict
=
{
"colormap"
:
"Planck-like"
}
ift
.
plot
(
d
,
name
=
"data.png"
,
**
plotdict
)
ift
.
plot
(
HT
(
sh
),
name
=
"mock_signal.png"
,
**
plotdict
)
...
...
demos/wiener_filter_via_hamiltonian.py
View file @
ff879f9c
...
...
@@ -34,7 +34,7 @@ if __name__ == "__main__":
else
:
raise
NotImplementedError
diag
=
ift
.
Field
.
from_global_data
(
s_space
,
diag
)
.
lock
()
diag
=
ift
.
Field
.
from_global_data
(
s_space
,
diag
)
Instrument
=
ift
.
DiagonalOperator
(
diag
)
# Add harmonic transformation to the instrument
...
...
nifty4/domains/domain.py
View file @
ff879f9c
...
...
@@ -17,13 +17,11 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import
abc
from
..utilities
import
NiftyMeta
from
future.utils
import
with_metaclass
from
..utilities
import
NiftyMetaBase
import
numpy
as
np
class
Domain
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))):
class
Domain
(
NiftyMetaBase
()):
"""The abstract class repesenting a (structured or unstructured) domain.
"""
...
...
nifty4/minimization/energy.py
View file @
ff879f9c
...
...
@@ -16,11 +16,10 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
..utilities
import
memo
,
NiftyMeta
from
future.utils
import
with_metaclass
from
..utilities
import
memo
,
NiftyMetaBase
class
Energy
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{})
)):
class
Energy
(
NiftyMetaBase
(
)):
""" Provides the functional used by minimization schemes.
The Energy object is an implementation of a scalar function including its
...
...
nifty4/minimization/iteration_controller.py
View file @
ff879f9c
...
...
@@ -18,12 +18,10 @@
from
builtins
import
range
import
abc
from
..utilities
import
NiftyMeta
from
future.utils
import
with_metaclass
from
..utilities
import
NiftyMetaBase
class
IterationController
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))):
class
IterationController
(
NiftyMetaBase
()):
"""The abstract base class for all iteration controllers.
An iteration controller is an object that monitors the progress of a
minimization iteration. At the begin of the minimization, its start()
...
...
nifty4/minimization/line_search.py
View file @
ff879f9c
...
...
@@ -17,13 +17,10 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import
abc
from
future
.utils
import
with_m
eta
cl
as
s
from
.
.util
itie
s
import
NiftyM
eta
B
as
e
class
LineSearch
(
with_metaclass
(
abc
.
ABCMeta
,
with_metaclass
(
abc
.
ABCMeta
,
type
(
'NewBase'
,
(
object
,),
{})))):
class
LineSearch
(
NiftyMetaBase
()):
"""Class for determining the optimal step size along some descent direction.
Initialize the line search procedure which can be used by a specific line
...
...
nifty4/minimization/minimizer.py
View file @
ff879f9c
...
...
@@ -17,11 +17,10 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import
abc
from
..utilities
import
NiftyMeta
from
future.utils
import
with_metaclass
from
..utilities
import
NiftyMetaBase
class
Minimizer
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{})
)):
class
Minimizer
(
NiftyMetaBase
(
)):
""" A base class used by all minimizers."""
@
abc
.
abstractmethod
...
...
nifty4/operators/inversion_enabler.py
View file @
ff879f9c
...
...
@@ -64,12 +64,10 @@ class InversionEnabler(LinearOperator):
if
self
.
_op
.
capability
&
mode
:
return
self
.
_op
.
apply
(
x
,
mode
)
tdom
=
self
.
_tgt
(
mode
)
x0
=
Field
.
zeros
(
tdom
,
dtype
=
x
.
dtype
)
def
func
(
x
):
return
self
.
_op
.
apply
(
x
,
self
.
_inverseMode
[
mode
])
x0
=
Field
.
zeros
(
self
.
_tgt
(
mode
),
dtype
=
x
.
dtype
)
energy
=
QuadraticEnergy
(
A
=
func
,
b
=
x
,
position
=
x0
)
r
,
stat
=
self
.
_inverter
(
energy
,
preconditioner
=
self
.
_preconditioner
)
if
stat
!=
IterationController
.
CONVERGED
:
...
...
nifty4/operators/linear_operator.py
View file @
ff879f9c
...
...
@@ -17,14 +17,12 @@
# and financially supported by the Studienstiftung des deutschen Volkes.
import
abc
from
..utilities
import
NiftyMeta
from
..utilities
import
NiftyMeta
Base
from
..field
import
Field
from
future.utils
import
with_metaclass
import
numpy
as
np
class
LinearOperator
(
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))):
class
LinearOperator
(
NiftyMetaBase
()):
"""NIFTY base class for linear operators.
The base NIFTY operator class is an abstract class from which
...
...
nifty4/utilities.py
View file @
ff879f9c
...
...
@@ -20,8 +20,12 @@ from builtins import next, range
import
numpy
as
np
from
itertools
import
product
import
abc
from
future.utils
import
with_metaclass
__all__
=
[
"get_slice_list"
,
"safe_cast"
,
"parse_spaces"
,
"infer_space"
,
"memo"
,
"NiftyMetaBase"
,
"hartley"
,
"my_fftn_r2c"
]
def
get_slice_list
(
shape
,
axes
):
"""
Helper function which generates slice list(s) to traverse over all
...
...
@@ -150,6 +154,10 @@ class NiftyMeta(_DocStringInheritor, abc.ABCMeta):
pass
def
NiftyMetaBase
():
return
with_metaclass
(
NiftyMeta
,
type
(
'NewBase'
,
(
object
,),
{}))
def
hartley
(
a
,
axes
=
None
):
# Check if the axes provided are valid given the shape
if
axes
is
not
None
and
\
...
...
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