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
nam
ProxPython
Commits
27d2d6f6
Commit
27d2d6f6
authored
Nov 03, 2020
by
jansen31
Browse files
documentation
parent
601e8376
Changes
2
Hide whitespace changes
Inline
Side-by-side
proxtoolbox/proxoperators/P_incoherent.py
View file @
27d2d6f6
...
...
@@ -9,19 +9,20 @@ __all__ = ['P_M_incoherent', 'P_Sparsity_real_incoherent']
class
P_M_incoherent
(
P_M
):
"""
Apply the Fourier-domain modulus constraint to a set of incoherent fields:
scale the amplitudes such that the combined intensity matches the data
scale the amplitudes such that the combined intensity matches the data.
Data scaling is done while avoiding division by zero errors similar to how it is done in proxoperator.magproj
"""
def
__init__
(
self
,
experiment
):
super
(
P_M_incoherent
,
self
).
__init__
(
experiment
)
self
.
intensity
=
self
.
data
**
2
self
.
eps
=
1e-1
5
self
.
eps
=
1e-1
0
def
eval
(
self
,
u
,
prox_idx
=
None
):
amplitudes
=
self
.
prop
.
eval
(
u
)
# Propagate to measurement domain
pred
=
sum
(
abs
(
amplitudes
)
**
2
,
axis
=
0
)
# Predicted total intensity
divisor
=
sqrt
(
pred
+
self
.
eps
**
2
)
#
scaling
=
1
-
(
pred
+
2
*
self
.
eps
**
2
)
/
divisor
**
3
*
(
pred
/
divisor
-
self
.
data
)
# scaling = self.data / divisor
out
=
array
([
scaling
*
u_i
for
u_i
in
amplitudes
])
return
self
.
invprop
.
eval
(
out
)
# Propagate back
...
...
proxtoolbox/proxoperators/P_orthonorm.py
View file @
27d2d6f6
from
numpy
import
sum
,
array
,
sqrt
,
zeros_like
import
numpy
as
np
from
proxtoolbox.proxoperators.proxoperator
import
ProxOperator
...
...
@@ -9,8 +8,8 @@ __all__ = ['P_orthonorm', "P_norm"]
class
P_orthonorm
(
ProxOperator
):
def
__init__
(
self
,
experiment
):
"""
Normalize two iterates and rotate them such that they are orthogonal.
A
lso a
pplies a real-valuedness projection
Normalize two iterates and rotate them such that they are orthogonal
(sum(u.v) == 0)
.
Applies a real-valuedness projection
first.
@param experiment: experiment class
"""
...
...
@@ -40,7 +39,6 @@ class P_orthonorm(ProxOperator):
u_new
=
zeros_like
(
u_norm
)
u_new
[
0
]
=
u_norm
[
0
]
-
(
y
/
(
y
**
2
-
1
))
*
(
y
*
u_norm
[
0
]
-
u_norm
[
1
])
u_new
[
1
]
=
(
1
/
(
y
**
2
-
1
))
*
(
y
*
u_norm
[
0
]
-
u_norm
[
1
])
# TODO: need to apply normalization still?
return
u_new
...
...
@@ -51,7 +49,7 @@ class P_norm(ProxOperator):
"""
super
(
P_norm
,
self
).
__init__
(
experiment
)
self
.
norm
=
experiment
.
norm_data
#
TODO: define number of iterate components here, divide
norm
by
sqrt(n)
#
Each incoherent component is normalized to
norm
/
sqrt(n)
where n is the number of componentsss
def
eval
(
self
,
u
,
prox_idx
=
None
):
# Normalize components of u
...
...
@@ -60,6 +58,7 @@ class P_norm(ProxOperator):
return
array
([
self
.
norm
*
u
[
i
]
/
norms
[
i
]
/
sqrt
(
n_comp
)
for
i
in
range
(
n_comp
)])
# Basic test functionality
if
__name__
==
"__main__"
:
import
numpy
as
np
...
...
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