Commit 1314e004 authored by jansen31's avatar jansen31
Browse files

Merge remote-tracking branch 'origin/dornheim' into dornheim

parents f64212d8 f060d157
Written 18th October 2019 by Alexander Dornheim
Current state of ProxPython (to my knowledge):
Folders:
docs: haven't worked on this
GUI_Python: haven't worked on this
InputData: folder for input data, input data for Phase, ART should be automatically downloaded into this folder
Nanoscale_Photonic_Imaging_demos: haven't worked on this, to contain demos for Russels book (so far 1 demo)
proxgui: haven't worked on this
proxtoolbox: most code, see below
TestSuite: testing/demos, see below
Files:
changes_in_Matlab_since_NahmeZiehe.txt: old, delete
manual.pdf: old
ProxPython_for_Dummies_README.txt: Mostly wrote it in Feb 2018 for students, still most up to date ReadMe. Contains list of demos which should work properly.
ProxPython_how_to_run_demos_on_Windows_for_dummies.txt: Short ReadMe for Windows by students (recent). Contains list of files students had problem running.
ReadMe.md: old, doesn't contain much information
setup.py: never touched this setup file
Proposed clean up:
Are both GUI folders needed? Are they working? -> Jochen
docs -> new documentation by Sylvain in future
delete changes_in_Matlab_since_NahmeZiehe.txt
Combine ReadMes
manual.pdf ?
TestSuite Folder
Phase_test_data: some output from the matlab version which I used for tests, need to talk to Sylvain if he wants to keep this. My tests are very basic, need to be done better using unitest
testing_Algortihms: folder with tests for the algortihms Robin implemented using unitest, haven't touched it personally
testing_ProxOperators: folder with tests for the proxoperators Robin implemented using unitest, haven't touched it personally
*_demo.py: Relocate/ structure in folders: Phase/ART demos etc. List of demos that should be working see ReadMe
to be continued...
......@@ -36,30 +36,30 @@ I. Phase Retrieval:
d. Phase_JWST_DRAP_demo.py (Douglas-Rachford-Alternating Projectons hybrid proposed by Nguyen, 2017) DRAP not yet in ProxPython
2. Siemens data set: far field Siemens star tests
a. Phase_Siemens_amplitude_demo.py (phase object)
a. Phase_Siemens_amplitude_demo.py (phase object)
b. Phase_Siemens_nonneg_demo.py (nonnegative object)
c. Phase_Siemens_real_demo.py (real object - possibly negative valued!?)
c. Phase_Siemens_real_demo.py (real object - possibly negative valued!?)
3. Goettingen data set:
a. tasse_ap_demo (far field optical diffraction - experimental data)
b. tasse_raar_demo (far field optical diffraction - experimental data)
c. Near_field_synthetic_demo (near field cell with noise - simulated)
b. tasse_raar_demo (far field optical diffraction - experimental data)
c. Near_field_synthetic_demo (near field cell with noise - simulated)
d. Phase_near_field_Siemens_experimental_demo(near feild x-ray of Siemens star phase object with structured beam)
e. Near_field_living_worm_demo (near field x-ray image of a living worm- not sure parameters are correct)
e. Near_field_living_worm_demo (near field x-ray image of a living worm- not sure parameters are correct)
II. Computed Tomography:
1. BLOCK_RAAR_parallel_ART_demo.py (parallelized RAAR, Luke 2005, for CT)
2. BLOCK_RAAR_sequential_ART_demo.py (RAAR, Luke 2005, for CT)
3. ART_alternating_proj_demo.py (cyclic projections)
4. ART_averaged_proj_demo.py (Cimmino algorithm)
5. BLOCK_GRAAL_parallel_ART_demo.py (Golden Ratio Algorithm of Malitskyi, 2017)
5. BLOCK_GRAAL_parallel_ART_demo.py (Golden Ratio Algorithm of Malitskyi, 2017)
7. BLOCK_AP_parallel_ART_demo.py (Block parallelized Cimmino)
Not implemented:
6. BLOCK_ART_averaged_proj_in (Block Cimmino algorithm) seems to do the same as demo 7 in ProxToolbox
V. Sudoku:
1. Sudoku_demo.py (RAAR for Sudoku following Elser's 2007 model)
1. Sudoku_demo.py (RAAR for Sudoku following Elser's 2007 model)
......
How to run a demo of ProxPython in Windows starting at 0:
Download python at https://www.python.org/downloads/ .
Download the ProxPython file from GitLab by clicking on the little cloud icon.
Open the command window by typing in cmd in the search bar.
In the command window, change your current folder to ProxPython/Testsuite by typing chdir "adress of the testsuite folder" (without the quotation marks).
You can get the adress by typing in Testsuite in the search bar, right-clicking on the folder and going for copy full path. Now you can paste it by rightclicking in the command window
Now you need to download some libraries which are needed for the demos. Type in the command window the following 4 commands:
py -m pip install numpy
py -m pip install scipy
py -m pip install h5py
py -m pip install matplotlib
Now you can run any of the demo files by typing py "name of the file.py" (without the quotation marks), for example py Sudoku_demo.py.
Demos which don't seem to work:
ART_alternating_proj_demo.py (Calculates for a long time without getting any result)
BLOCK_HAAR_sequential_ART_demo.py (module proxtoolbox.Algorithms has no attribute HAAR)
BLOCK_QNAP_sequential_ART_demo.py (module proxtoolbox.Algorithms has no attribute QNAP)
DRprotein_demo.py ( No such file or directory: '../InputData/Protein/1PTQ.pdb)
Ptychography_demo.py (Seems to loop some kind of runtimeerror)
sudoku_in.py (runs, but has no output. Might be in the wrong directory?)
Testing_problems.py (no module named 'proxtoolbox')
Testing_Utilities.py (no module named 'proxtoolbox')
TestSuite_all.py (no module named 'TestSuite')
""" Phase_JWST_DRAP_demo
written on Sep 17. 2019 by
Constantin Höing
Inst. Fuer Numerische und Angewandte Mathematik
Universität Göttingen
"""
import sys
sys.path.append('../proxtoolbox/Problems/Phase') # find out what should be in the string
sys.path.append("..")
import JWST_data_processor
import JWST_DRAP_in
from phase import Phase
JWST = Phase(JWST_DRAP_in.new_config)
JWST.solve()
JWST.show()
""" Phase_JWST_DRAP_demo
written on Sep 17. 2019 by
Constantin Höing
Inst. Fuer Numerische und Angewandte Mathematik
Universität Göttingen
"""
import sys
sys.path.append('../proxtoolbox/Problems/Phase') # find out what should be in the string
sys.path.append("..")
import JWST_data_processor
import JWST_HPR_in
from phase import Phase
JWST = Phase(JWST_HPR_in.new_config)
JWST.solve()
JWST.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_1D_AltP_cold_in
from phase import Phase
CDP = Phase(CDP_1D_AltP_cold_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_1D_AltP_warm_in
from phase import Phase
CDP = Phase(CDP_1D_AltP_warm_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_1D_DRAP_warm_in
from phase import Phase
CDP = Phase(CDP_1D_DRAP_warm_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_1D_QNAP_cold_in
from phase import Phase
CDP = Phase(CDP_1D_QNAP_cold_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_1D_RAAR_warm_in
from phase import Phase
CDP = Phase(CDP_1D_RAAR_warm_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_1D_Wirt_cold_in
from phase import Phase
CDP = Phase(CDP_1D_Wirt_cold_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_2D_AltP_cold_in
from phase import Phase
CDP = Phase(CDP_2D_AltP_cold_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_2D_DRAP_cold_in
from phase import Phase
CDP = Phase(CDP_2D_DRAP_cold_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_2D_QNAP_warm_in
from phase import Phase
CDP = Phase(CDP_2D_QNAP_warm_in.new_config)
CDP.solve()
CDP.show()
import sys
sys.path.append('../proxtoolbox/Problems/Phase')
sys.path.append('..')
import CDP_processor
import CDP_2D_Wirt_cold_in
from phase import Phase
CDP = Phase(CDP_2D_Wirt_cold_in.new_config)
CDP.solve()
CDP.show()
""" demo_tool.py
written on Sep 13 2019 by
Constantin Höing
Inst. Fuer Numerische und Angewandte Mathematik
Universität Göttingen
Description: A tool to list all demos (if added to the folder this is in) and then run a demo the user choose.
"""
from os import listdir
from os.path import realpath
def main():
L = listdir(realpath(__file__)[:-13])
newL = []
for val in L:
if "demo" in val:
newL.append(val)
L = newL
del newL
L.remove("demo_tool.py")
print("All available demos will be listet. Enter the corresponding number to run that demo\n")
L.append("exit")
while True:
print("\n\n\n\n")
for idx, val in enumerate(L):
print("({})\t{}".format(idx, val))
choice = int(input("Which demo do you want to run ?: "))
if L[choice] != "exit":
exec("import " + L[choice][:-3])
else:
quit()
main()
\ No newline at end of file
import numpy as np
import unittest
from proxtoolbox.Algorithms.CAARL import *
from proxtoolbox.ProxOperators.P_binary import *
from proxtoolbox.ProxOperators.P_RN import *
from proxtoolbox.ProxOperators.P_M import *
class test_CAARL(unittest.TestCase):
def test_CAARL(self):
config={'proxoperators':[P_binary,P_RN,P_M],'beta0':2 ,'beta_max':2,'beta_switch':1,'prox_idx':2,'iter':10,'prox_idx':2,'support_idx':np.array([1,2]),'Nx':8,'Ny':0,'Nz':0,'Prox':[P_binary,P_RN], 'norm_data':1, 'product_space_dimension':5,'beta_0':2,'M':np.array([1,2,2,2,2,12])}
self.pro= CAARL(config)
u = np.array([1,2,5,6,-5,-6])
self.assertEqual(self.pro.evaluate(u).tolist(),np.array([ -1.8703690419340218+8.437742860180073j , 2.5477381663013103+8.807889679799857j,-7.613529601089619+0.3701468196197832j, -12.384068573713796-8.437742860180071j, 9.483898643023636-8.807889679799857j, 9.836330407412484-0.3701468196197823j]).tolist())
if __name__ == '__main__':
unittest.main()
#inut:u=[1,2,5,6,-5,-6]
#output:[ -1.8703690419340218+8.437742860180073j , 2.5477381663013103+8.807889679799857j,-7.613529601089619+0.3701468196197832j, -12.384068573713796-8.437742860180071j, 9.483898643023636-8.807889679799857j, 9.836330407412484-0.3701468196197823j]
import numpy as np
import unittest
from proxtoolbox.Algorithms.CADRl import *
from proxtoolbox.ProxOperators.P_binary import *
from proxtoolbox.ProxOperators.P_RN import *
from proxtoolbox.ProxOperators.P_M import *
class test_CADRl(unittest.TestCase):
def test_CADRl(self):
config={'proxoperators':[P_RN,P_M,P_binary],'beta0':2 ,'beta_max':2,'beta_switch':1,'prox_idx':2,'iter':10,'prox_idx':2,'support_idx':np.array([1,2]),'Nx':8,'Ny':0,'Nz':0,'Prox':[P_binary,P_RN], 'norm_data':1, 'product_space_dimension':5,'beta_0':2,'M':np.array([1,2,2,2,2,12])}
self.pro= CADRl(config)
u = np.array([1,2,5,6,-5,-6])
self.assertEqual(self.pro.evaluate(u).tolist(),np.array([ (-1.9356980627875102+3.0408182027976864j) ,0.8580885402990752+2.7029495135979418j,-1.1271369416921422-0.3378686891997414j,-1.779020587713914-3.0408182027976864j,1.062835004479652-2.7029495135979418j, 1.9209320474148388+0.3378686891997414j]).tolist())
if __name__ == '__main__':
unittest.main()
import numpy as np
import unittest
from proxtoolbox.Algorithms.CDRl import *
from proxtoolbox.ProxOperators.P_binary import *
from proxtoolbox.ProxOperators.P_RN import *
from proxtoolbox.ProxOperators.P_M import *
class test_CDRl(unittest.TestCase):
def test_CDRl(self):
config={'proxoperators':[P_binary,P_RN,P_M],'beta0':2 ,'beta_max':2,'beta_switch':1,'prox_idx':2,'iter':10,'prox_idx':2,'support_idx':np.array([1,2]),'Nx':8,'Ny':0,'Nz':0,'Prox':[P_binary,P_RN], 'norm_data':1, 'product_space_dimension':5,'beta_0':2,'M':np.array([1,2,2,2,2,12]),'lambda0':2,'lambda_max':2,'lambda_switch':1,'lambda_0':2}
self.pro= CDRl(config)
u = np.array([1,2,5,6,-5,-6])
self.assertEqual(self.pro.evaluate(u).tolist(),np.array([ 0.9510576492339013-2.7982183410847505j,1.2326217479829011-2.9678073314535216j ,16.23359565239013-0.169588990368774j ,19.54586980521637+2.798218341084751j ,-16.18465330162403+2.967807331453521j , -19.778491553199267+0.169588990368774j]).tolist())
if __name__ == '__main__':
unittest.main()
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