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
4df6cfa6
Commit
4df6cfa6
authored
Jan 29, 2018
by
Philipp Arras
Browse files
Some renamings
parent
75c8e777
Changes
7
Hide whitespace changes
Inline
Side-by-side
nifty4/library/critical_power_energy.py
View file @
4df6cfa6
...
...
@@ -37,7 +37,8 @@ class CriticalPowerEnergy(Energy):
position : Field,
The current position of this energy. (Logarithm of power spectrum)
m : Field,
The map whose power spectrum has to be inferred
The map whose power spectrum is inferred. Needs to live in harmonic
signal space.
D : EndomorphicOperator,
The curvature of the Gaussian encoding the posterior covariance.
If not specified, the map is assumed to be no reconstruction.
...
...
nifty4/library/noise_energy.py
View file @
4df6cfa6
...
...
@@ -24,11 +24,11 @@ from ..minimization.energy import Energy
class
NoiseEnergy
(
Energy
):
def
__init__
(
self
,
position
,
d
,
m
,
D
,
t
,
ht
,
Instrument
,
def
__init__
(
self
,
position
,
d
,
xi
,
D
,
t
,
ht
,
Instrument
,
nonlinearity
,
alpha
,
q
,
Projection
,
munit
=
1.
,
sunit
=
1.
,
dunit
=
1.
,
samples
=
3
,
sample_list
=
None
,
inverter
=
None
):
dunit
=
1.
,
samples
=
3
,
xi_
sample_list
=
None
,
inverter
=
None
):
super
(
NoiseEnergy
,
self
).
__init__
(
position
=
position
)
self
.
m
=
m
self
.
xi
=
xi
self
.
D
=
D
self
.
d
=
d
self
.
N
=
DiagonalOperator
(
diagonal
=
dunit
**
2
*
exp
(
self
.
position
))
...
...
@@ -45,21 +45,19 @@ class NoiseEnergy(Energy):
self
.
q
=
q
self
.
Projection
=
Projection
self
.
power
=
self
.
Projection
.
adjoint_times
(
munit
*
exp
(
0.5
*
self
.
t
))
self
.
one
=
Field
(
self
.
position
.
domain
,
val
=
1.
)
if
sample_list
is
None
:
if
xi_sample_list
is
None
:
if
samples
is
None
or
samples
==
0
:
sample_list
=
[
m
]
xi_
sample_list
=
[
xi
]
else
:
sample_list
=
[
D
.
generate_posterior_sample
()
+
m
xi_
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
_
in
range
(
samples
)]
self
.
sample_list
=
sample_list
self
.
xi_
sample_list
=
xi_
sample_list
self
.
inverter
=
inverter
A
=
Projection
.
adjoint_times
(
munit
*
exp
(.
5
*
self
.
t
))
# unit: munit
map_s
=
self
.
ht
(
A
*
m
)
self
.
_gradient
=
None
for
sample
in
self
.
sample_list
:
for
sample
in
self
.
xi_
sample_list
:
map_s
=
self
.
ht
(
A
*
sample
)
residual
=
self
.
d
-
\
...
...
@@ -74,12 +72,12 @@ class NoiseEnergy(Energy):
self
.
_value
+=
lh
self
.
_gradient
+=
grad
self
.
_value
*=
1.
/
len
(
self
.
sample_list
)
self
.
_value
*=
1.
/
len
(
self
.
xi_
sample_list
)
self
.
_value
+=
.
5
*
self
.
position
.
sum
()
self
.
_value
+=
(
self
.
alpha
-
1.
).
vdot
(
self
.
position
)
+
\
self
.
q
.
vdot
(
exp
(
-
self
.
position
))
self
.
_gradient
*=
1.
/
len
(
self
.
sample_list
)
self
.
_gradient
*=
1.
/
len
(
self
.
xi_
sample_list
)
self
.
_gradient
+=
(
self
.
alpha
-
0.5
)
-
self
.
q
*
(
exp
(
-
self
.
position
))
def
at
(
self
,
position
):
...
...
@@ -87,7 +85,7 @@ class NoiseEnergy(Energy):
position
,
self
.
d
,
self
.
m
,
self
.
D
,
self
.
t
,
self
.
ht
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
alpha
,
self
.
q
,
self
.
Projection
,
munit
=
self
.
munit
,
sunit
=
self
.
sunit
,
dunit
=
self
.
dunit
,
sample_list
=
self
.
sample_list
,
dunit
=
self
.
dunit
,
xi_
sample_list
=
self
.
xi_
sample_list
,
samples
=
self
.
samples
,
inverter
=
self
.
inverter
)
@
property
...
...
nifty4/library/nonlinear_power_energy.py
View file @
4df6cfa6
...
...
@@ -52,7 +52,7 @@ class NonlinearPowerEnergy(Energy):
"""
def
__init__
(
self
,
position
,
d
,
N
,
xi
,
D
,
ht
,
Instrument
,
nonlinearity
,
Projection
,
sigma
=
0.
,
samples
=
3
,
sample_list
=
None
,
Projection
,
sigma
=
0.
,
samples
=
3
,
xi_
sample_list
=
None
,
inverter
=
None
,
munit
=
1.
,
sunit
=
1.
):
super
(
NonlinearPowerEnergy
,
self
).
__init__
(
position
)
self
.
xi
=
xi
...
...
@@ -68,13 +68,13 @@ class NonlinearPowerEnergy(Energy):
self
.
sigma
=
sigma
self
.
munit
=
munit
self
.
sunit
=
sunit
if
sample_list
is
None
:
if
xi_
sample_list
is
None
:
if
samples
is
None
or
samples
==
0
:
sample_list
=
[
xi
]
xi_
sample_list
=
[
xi
]
else
:
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
xi_
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
_
in
range
(
samples
)]
self
.
sample_list
=
sample_list
self
.
xi_
sample_list
=
xi_
sample_list
self
.
inverter
=
inverter
A
=
Projection
.
adjoint_times
(
munit
*
exp
(.
5
*
position
))
# unit: munit
...
...
@@ -82,7 +82,7 @@ class NonlinearPowerEnergy(Energy):
Tpos
=
self
.
T
(
position
)
self
.
_gradient
=
None
for
xi_sample
in
self
.
sample_list
:
for
xi_sample
in
self
.
xi_
sample_list
:
map_s
=
self
.
ht
(
A
*
xi_sample
)
LinR
=
LinearizedPowerResponse
(
self
.
Instrument
,
self
.
nonlinearity
,
self
.
ht
,
self
.
Projection
,
...
...
@@ -100,17 +100,17 @@ class NonlinearPowerEnergy(Energy):
self
.
_value
+=
lh
self
.
_gradient
+=
grad
self
.
_value
*=
1.
/
len
(
self
.
sample_list
)
self
.
_value
*=
1.
/
len
(
self
.
xi_
sample_list
)
self
.
_value
+=
0.5
*
self
.
position
.
vdot
(
Tpos
)
self
.
_gradient
*=
-
1.
/
len
(
self
.
sample_list
)
self
.
_gradient
*=
-
1.
/
len
(
self
.
xi_
sample_list
)
self
.
_gradient
+=
Tpos
def
at
(
self
,
position
):
return
self
.
__class__
(
position
,
self
.
d
,
self
.
N
,
self
.
xi
,
self
.
D
,
self
.
ht
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
Projection
,
sigma
=
self
.
sigma
,
samples
=
len
(
self
.
sample_list
),
sample_list
=
self
.
sample_list
,
samples
=
len
(
self
.
xi_
sample_list
),
xi_
sample_list
=
self
.
xi_
sample_list
,
munit
=
self
.
munit
,
sunit
=
self
.
sunit
,
inverter
=
self
.
inverter
)
...
...
@@ -128,5 +128,5 @@ class NonlinearPowerEnergy(Energy):
def
curvature
(
self
):
return
NonlinearPowerCurvature
(
self
.
position
,
self
.
ht
,
self
.
Instrument
,
self
.
nonlinearity
,
self
.
Projection
,
self
.
N
,
self
.
T
,
self
.
sample_list
,
self
.
Projection
,
self
.
N
,
self
.
T
,
self
.
xi_
sample_list
,
self
.
inverter
,
self
.
munit
,
self
.
sunit
)
nifty4/library/response_operators.py
View file @
4df6cfa6
...
...
@@ -19,8 +19,8 @@
from
..field
import
exp
def
LinearizedSignalResponse
(
Instrument
,
nonlinearity
,
ht
,
power
,
s
,
sunit
):
return
sunit
*
(
Instrument
*
nonlinearity
.
derivative
(
s
)
*
ht
*
power
)
def
LinearizedSignalResponse
(
Instrument
,
nonlinearity
,
ht
,
power
,
m
,
sunit
):
return
sunit
*
(
Instrument
*
nonlinearity
.
derivative
(
m
)
*
ht
*
power
)
def
LinearizedPowerResponse
(
Instrument
,
nonlinearity
,
ht
,
Projection
,
tau
,
xi
,
munit
,
sunit
):
...
...
nifty4/library/wiener_filter_energy.py
View file @
4df6cfa6
...
...
@@ -29,11 +29,12 @@ class WienerFilterEnergy(Energy):
Parameters
----------
position: Field,
The current
position
.
The current
map in harmonic space
.
d: Field,
the data
R: LinearOperator,
The response operator, description of the measurement process.
The response operator, description of the measurement process. It needs
to map from harmonic signal space to data space.
N: EndomorphicOperator,
The noise covariance in data space.
S: EndomorphicOperator,
...
...
test/test_energies/test_noise.py
View file @
4df6cfa6
...
...
@@ -80,16 +80,16 @@ class Noise_Energy_Tests(unittest.TestCase):
S
=
S
,
inverter
=
inverter
).
curvature
Nsamples
=
10
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
i
in
range
(
Nsamples
)]
xi_
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
i
in
range
(
Nsamples
)]
energy0
=
ift
.
library
.
NoiseEnergy
(
position
=
eta0
,
d
=
d
,
m
=
xi
,
D
=
D
,
t
=
tau
,
Instrument
=
R
,
position
=
eta0
,
d
=
d
,
xi
=
xi
,
D
=
D
,
t
=
tau
,
Instrument
=
R
,
alpha
=
alpha
,
q
=
q
,
Projection
=
P
,
nonlinearity
=
f
,
ht
=
ht
,
sample_list
=
sample_list
)
ht
=
ht
,
xi_
sample_list
=
xi_
sample_list
)
energy1
=
ift
.
library
.
NoiseEnergy
(
position
=
eta1
,
d
=
d
,
m
=
xi
,
D
=
D
,
t
=
tau
,
Instrument
=
R
,
position
=
eta1
,
d
=
d
,
xi
=
xi
,
D
=
D
,
t
=
tau
,
Instrument
=
R
,
alpha
=
alpha
,
q
=
q
,
Projection
=
P
,
nonlinearity
=
f
,
ht
=
ht
,
sample_list
=
sample_list
)
ht
=
ht
,
xi_
sample_list
=
xi_
sample_list
)
a
=
(
energy1
.
value
-
energy0
.
value
)
/
eps
b
=
energy0
.
gradient
.
vdot
(
direction
)
...
...
test/test_energies/test_power.py
View file @
4df6cfa6
...
...
@@ -132,7 +132,7 @@ class Energy_Tests(unittest.TestCase):
ht
=
ht
,
inverter
=
inverter
).
curvature
Nsamples
=
10
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
_
in
range
(
Nsamples
)]
xi_
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
_
in
range
(
Nsamples
)]
energy0
=
ift
.
library
.
NonlinearPowerEnergy
(
position
=
tau0
,
...
...
@@ -144,7 +144,7 @@ class Energy_Tests(unittest.TestCase):
nonlinearity
=
f
,
ht
=
ht
,
N
=
N
,
sample_list
=
sample_list
)
xi_
sample_list
=
xi_
sample_list
)
energy1
=
ift
.
library
.
NonlinearPowerEnergy
(
position
=
tau1
,
d
=
d
,
...
...
@@ -155,7 +155,7 @@ class Energy_Tests(unittest.TestCase):
nonlinearity
=
f
,
ht
=
ht
,
N
=
N
,
sample_list
=
sample_list
)
xi_
sample_list
=
xi_
sample_list
)
a
=
(
energy1
.
value
-
energy0
.
value
)
/
eps
b
=
energy0
.
gradient
.
vdot
(
direction
)
...
...
@@ -271,7 +271,7 @@ class Curvature_Tests(unittest.TestCase):
ht
=
ht
,
inverter
=
inverter
).
curvature
Nsamples
=
10
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
_
in
range
(
Nsamples
)]
xi_
sample_list
=
[
D
.
generate_posterior_sample
()
+
xi
for
_
in
range
(
Nsamples
)]
energy0
=
ift
.
library
.
NonlinearPowerEnergy
(
position
=
tau0
,
...
...
@@ -283,7 +283,7 @@ class Curvature_Tests(unittest.TestCase):
nonlinearity
=
f
,
ht
=
ht
,
N
=
N
,
sample_list
=
sample_list
)
xi_
sample_list
=
xi_
sample_list
)
gradient0
=
energy0
.
gradient
gradient1
=
energy0
.
at
(
tau1
).
gradient
...
...
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