Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nam
ProxPython
Commits
52833797
Commit
52833797
authored
Jun 06, 2017
by
alexander.dornheim
Browse files
Added first part of Phase_graphics. To be continued...
parent
a3b9e480
Changes
6
Hide whitespace changes
Inline
Side-by-side
TestSuite/Phase_Siemens_real_demo.py
View file @
52833797
...
...
@@ -9,4 +9,4 @@ Siemens = Phase(Siemens_real_in.new_config)
Siemens
.
solve
()
Siemens
.
compare_to_matlab
()
#Siemens.compare_data_to_matlab()
#JWST
.show()
Siemens
.
show
()
proxtoolbox/Problems/Phase/JWST_graphics.py
→
proxtoolbox/Problems/Phase/
Graphics/
JWST_graphics.py
View file @
52833797
File moved
proxtoolbox/Problems/Phase/Graphics/Phase_graphics.py
0 → 100644
View file @
52833797
# Phase_graphics.m
# written on May 23, 2012 by
# Russell Luke
# Inst. Fuer Numerische und Angewandte Mathematik
# Universitaet Gottingen
#
#
# DESCRIPTION: Script driver for viewing results from projection
# algorithms on various toy problems
#
# INPUT:
# method = character string for the algorithm used.
# true_object = the original image
# u_0 = the initial guess
# u = the algorithm "fixed point"
# change = the norm square of the change in the
# iterates
# error = squared set distance error at each
# iteration
# noneg = the norm square of the nonnegativity/support
# constraint at each iteration
# gap = the norm square of the gap distance, that is
# the distance between the projections of the
# iterates to the sets
#
# OUTPUT: graphics
# USAGE: Phase_graphics(config,output)
#
#############################################################
from
matplotlib.pyplot
import
subplots
,
show
import
numpy
as
np
def
Phase_graphics
(
config
,
output
):
algortihm
=
config
[
'algorithm'
]
beta0
=
config
[
'beta_0'
]
beta_max
=
config
[
'beta_max'
]
u_0
=
config
[
'u_0'
]
if
output
[
'u1'
].
ndim
==
2
:
u
=
output
[
'u1'
]
u2
=
output
[
'u2'
]
else
:
u
=
output
[
'u1'
][:,:,
0
]
u2
=
output
[
'u2'
][:,:,
0
]
iter
=
output
[
'iter'
]
change
=
output
[
'change'
]
if
'time'
in
output
:
time
=
output
[
'time'
]
else
:
time
=
999
f
,
((
ax1
,
ax2
),
(
ax3
,
ax4
))
=
subplots
(
2
,
2
)
im
=
ax1
.
imshow
(
np
.
abs
(
u
),
cmap
=
'gray'
)
f
.
colorbar
(
im
,
ax
=
ax1
)
ax1
.
set_title
(
'best approximation amplitude - physical constraint satisfied'
)
im
=
ax2
.
imshow
(
np
.
real
(
u
),
cmap
=
'gray'
)
f
.
colorbar
(
im
,
ax
=
ax2
)
ax2
.
set_title
(
'best approximation phase - physical constraint satisfied'
)
im
=
ax3
.
imshow
(
np
.
abs
(
u2
),
cmap
=
'gray'
)
f
.
colorbar
(
im
,
ax
=
ax3
)
ax3
.
set_title
(
'best approximation amplitude - Fourier constraint satisfied'
)
im
=
ax4
.
imshow
(
np
.
real
(
u2
),
cmap
=
'gray'
)
f
.
colorbar
(
im
,
ax
=
ax4
)
ax4
.
set_title
(
'best approximation amplitude - Fourier constraint satisfied'
)
show
()
'''
figure(900);
subplot(2,2,1); imagesc(abs(u)); colormap gray; axis equal tight; colorbar; title('best approximation amplitude - physical constraint satisfied'); drawnow;
subplot(2,2,2); imagesc(real(u)); colormap gray; axis equal tight; colorbar; title('best approximation phase - physical constraint satisfied'); drawnow; #caxis([4.85,5.35]);
label = [ 'iteration', ', time = ',num2str(time), 's'];
subplot(2,2,3); semilogy(change),xlabel(label),ylabel(['log of change in iterates'])
label = ['Algorithm: ',method];
title(label)
if(any(strcmp('diagnostic', fieldnames(config))))
gap = output['stats.gap;
label = [ 'iteration', ', time = ',num2str(time), 's'];
subplot(2,2,4); semilogy(gap),xlabel(label),ylabel(['log of the gap distance'])
label = ['Algorithm: ',method, ',
\b
eta=',num2str(beta0),' to ',num2str(beta_max)];
title(label)
'''
proxtoolbox/Problems/Phase/Graphics/__init__.py
0 → 100644
View file @
52833797
from
.JWST_graphics
import
JWST_graphics
from
.Phase_graphics
import
Phase_graphics
__all__
=
[
"Phase_graphics"
,
"JWST_graphics"
]
proxtoolbox/Problems/Phase/Siemens_real_in.py
View file @
52833797
...
...
@@ -77,7 +77,7 @@ new_config = {
## depending on the value of the method field.
## do different things depending on the chosen algorithm:
## maximum number of iterations and tolerances
'MAXIT'
:
1
,
'MAXIT'
:
500
,
'TOL'
:
1e-5
,
## relaxaton parameters in RAAR, HPR and HAAR
...
...
proxtoolbox/Problems/Phase/phase.py
View file @
52833797
...
...
@@ -4,7 +4,7 @@ from proxtoolbox.Problems.problems import Problem
from
proxtoolbox
import
Algorithms
from
proxtoolbox
import
ProxOperators
from
proxtoolbox.ProxOperators.proxoperators
import
ProxOperator
from
proxtoolbox.Problems.Phase
.JWST_graphics
import
JWST_g
raphics
from
proxtoolbox.Problems.Phase
import
G
raphics
from
numpy.linalg
import
norm
import
numpy
as
np
import
h5py
...
...
@@ -230,7 +230,8 @@ class Phase(Problem):
print
(
"Calculation time:"
)
print
(
self
.
elapsed_time
)
JWST_graphics
(
self
.
config
,
self
.
output
)
graphics
=
getattr
(
Graphics
,
self
.
config
[
'graphics_display'
])
graphics
(
self
.
config
,
self
.
output
)
def
compare_to_matlab
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
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