Commit 52833797 authored by alexander.dornheim's avatar alexander.dornheim
Browse files

Added first part of Phase_graphics. To be continued...

parent a3b9e480
......@@ -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()
# 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, ', \beta=',num2str(beta0),' to ',num2str(beta_max)];
title(label)
'''
from .JWST_graphics import JWST_graphics
from .Phase_graphics import Phase_graphics
__all__ = ["Phase_graphics", "JWST_graphics"]
......@@ -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
......
......@@ -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_graphics
from proxtoolbox.Problems.Phase import Graphics
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):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment