Commit 6918cf06 authored by Russell Luke's avatar Russell Luke
Browse files

Merge branch 'Elser' of gitlab.gwdg.de:nam/ProxPython into Elser

parents b969f03e 88d625b7
......@@ -5,7 +5,7 @@ import numpy as np
from numpy import fromfile, exp, nonzero, zeros, pi, resize, real, angle
from numpy.random import rand
from numpy.linalg import norm
from numpy.fft import fftshift, fft2
from numpy.fft import fftshift, fft2, ifft2
import proxtoolbox.utils as utils
from proxtoolbox.utils.cell import Cell, isCell
......@@ -50,7 +50,7 @@ class Elser_Experiment(PhaseExperiment):
return defaultParams
def __init__(self, **kwargs):
def __init__(self, Atoms=100, category='E', **kwargs):
super(Elser_Experiment, self).__init__(**kwargs)
self.fresnel_nr = None
self.use_farfield_formula = None
......@@ -60,20 +60,20 @@ class Elser_Experiment(PhaseExperiment):
self.abs_illumination = None
self.illumination_phase = None
self.FT_conv_kernel = Cell(1)
self.Atoms=Atoms
self.category=category
def loadData(self):
# def loadElserData(filename, M):
"""
Load Elser dataset. Create the initial iterate.
"""
#make sure input data can be found, otherwise download it
#make sure input data can be found, otherwise download it
GetData.getData('Elser')
#defaultParams = getDefaultParameters()
# So far only Nx to set the desired
# resolution
newres = self.Nx
print(newres)
# The following value for snr does not work well in Python
# as this creates numerical issues with Poisson noise
......@@ -89,6 +89,7 @@ class Elser_Experiment(PhaseExperiment):
data = np.loadtxt(fn, delimiter="\t")
data = np.sqrt(data)/self.Nx
data = np.c_[data, np.zeros(self.Nx)] # add extra column
print(data)
data = data.flatten() # make it a one-dimensional array
M = fftshift(data)
# have to look at what Elser is actually doing with his data...
......@@ -279,5 +280,9 @@ class Elser_Experiment(PhaseExperiment):
show()
if __name__ == "__main__":
Elser = Elser_Experiment(Atoms=200, category='E', algorithm='RRR', lambda_0=0.95, lambda_max=0.95, anim=True)
Elser.run()
Elser.show()
from pathlib import Path
import sys
import os
import urllib.request
import tarfile
import zipfile
from zipfile import ZipFile
#shows progress of download
def dlProgress(counter, blocksize, size):
......@@ -43,16 +44,15 @@ def getData(problemFamily):
if query_yes_no("Do you want to download the " + problemFamily + " input data?"):
urllib.request.urlretrieve(" https://github.com/veitelser/phase-retrieval-benchmarks/archive/master.zip","../InputData/" + problemFamily + ".zip", reporthook=dlProgress)
print("\nExtracting data...")
# don't know how to do this.
os.system("mv ../../../InputData/Phase/Elser/phase-retrieval-benchmarks-master/data/* ../../../InputData/Phase/Elser/")
os.system("rm -r ../../../InputData/Phase/Elser/phase-retrieval-benchmarks-master")
# don't know how to do this. The following works for linux/unix...need a more universal solution
with ZipFile("../InputData/Elser.zip") as myzip:
print(myzip.namelist())
myzip.extractall(path='../InputData/Phase/Elser/')
#os.system('mv ../InputData/Phase/Elser/phase-retrieval-benchmarks-master/data/* ../InputData/Phase/Elser/')
#os.system('rm -r ../InputData/Phase/Elser/phase-retrieval-benchmarks-master/')
elif query_yes_no("Do you want to download the " + problemFamily + " input data?"):
urllib.request.urlretrieve(" http://vaopt.math.uni-goettingen.de/data/" + problemFamily + ".tar.gz","../InputData/" + problemFamily + ".tar.gz", reporthook=dlProgress)
print("\nExtracting data...")
tar = tarfile.open("../InputData/" + problemFamily + ".tar.gz", "r:gz")
tar.extractall("../InputData/" + problemFamily)
tar.close()
if not(my_file.is_file()):
print('***************************************************************************************')
print('* Message from GetData.py: *')
......
......@@ -112,5 +112,5 @@ setup(
},
# Some packages which are required for the good operation of ProxPython
install_requires=['numpy', 'scikit-image', 'matplotlib', 'scipy']
install_requires=['numpy', 'scikit-image', 'matplotlib', 'scipy', 'h5py', 'urllib3']
)
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