Commit 0b68c71d authored by alexander.dornheim's avatar alexander.dornheim
Browse files

In phase moved comparision with matlab results to method compare_to_matlab....

In phase moved comparision with matlab results to method compare_to_matlab. This is only intended to be used for testing. Note u_0 needs to be fixed in a specific way, noise should be switched off.
Added test for 1 Iteration: After 1 Iteration maximum norm of difference is 5.4e-06, Forbenius norm of difference is 2.5e-05.
parent 53f0fb4a
......@@ -7,4 +7,5 @@ from phase import Phase
JWST = Phase(JWST_in.new_config)
JWST.solve()
JWST.compare_to_matlab()
JWST.show()
......@@ -60,7 +60,7 @@ new_config = {
# What are the noise characteristics (Poisson or Gaussian or none)?
'noise' : 'Poisson', #'Poisson',
'noise' : 'none', #'Poisson',
#==========================================
# Algorithm parameters
......@@ -87,7 +87,7 @@ new_config = {
#maximum number of iterations and tolerances
'MAXIT' : 500,
'MAXIT' : 1,
'TOL' : 1e-8,
# relaxaton parameters in RAAR, HPR and HAAR
......
......@@ -204,16 +204,36 @@ class Phase(Problem):
self.output['u1'],self.output['u2'],self.output['iter'],self.output['change'],self.output['gap'] = \
self.algorithm.run(self.config['u_0'],self.config['TOL'],self.config['MAXIT'])
#print(self.iters)
#print(nonzero(self.u1))
#print(self.u1[self.u1.nonzero()]);
#print(norm(self.u1));
#print(self.u1[64,16]);
#print(norm(self.u2));
#print(self.u1[71,46]);
#print(self.gap);
#print(self.change);
f = h5py.File('u1.mat')
def _postsolve(self):
"""
Processes the solution and generates the output
"""
def show(self):
"""
Generates graphical output from the solution
"""
print("Calculation time:")
print(self.elapsed_time)
JWST_graphics(self.config,self.output)
def compare_to_matlab(self):
"""
Routine to test and verify results by comparing to matlab
Note that this is only for development and should not be used by a normal user
For result to match u_0 should be chosen as np.multiply(config['abs_illumination'],exp(1j*2*pi*0.5*np.ones(newres)))'] =
"""
if self.config['MAXIT'] == 1:
f = h5py.File('Phase_test_data/u1_1.mat')
elif self.config['MAXIT'] == 500 :
f = h5py.File('Phase_test_data/u1_500.mat')
else:
print("No file available to compare to.")
return
u1 = f['u1'].value.view(np.complex)
u1 =np.array(u1)
u1 = u1.T
......@@ -240,21 +260,4 @@ class Phase(Problem):
print(norm(u1))
print("Frobenius norm of python u1:")
print(norm(self.output['u1']))
def _postsolve(self):
"""
Processes the solution and generates the output
"""
def show(self):
"""
Generates graphical output from the solution
"""
print("Calculation time:")
print(self.elapsed_time)
JWST_graphics(self.config,self.output)
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