Commit 88d625b7 authored by Russell Luke's avatar Russell Luke
Browse files

still working on file i/o. Ready to check whether we are interpreting the data correctly

parent e3e0230f
......@@ -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,8 +60,8 @@ class Elser_Experiment(PhaseExperiment):
self.abs_illumination = None
self.illumination_phase = None
self.FT_conv_kernel = Cell(1)
self.Atoms = None
self.category = None
def loadData(self):
# def loadElserData(filename, M):
......@@ -69,12 +69,11 @@ class Elser_Experiment(PhaseExperiment):
#make sure input data can be found, otherwise download it
#defaultParams = getDefaultParameters()
# So far only Nx to set the desired
# resolution
newres = self.Nx
# The following value for snr does not work well in Python
# as this creates numerical issues with Poisson noise
......@@ -90,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
data = data.flatten() # make it a one-dimensional array
M = fftshift(data)
# have to look at what Elser is actually doing with his data...
from pathlib import Path
import sys
import os
import urllib.request
import tarfile
from zipfile import ZipFile
......@@ -43,11 +44,12 @@ def getData(problemFamily):
if query_yes_no("Do you want to download the " + problemFamily + " input data?"):
urllib.request.urlretrieve("","../InputData/" + problemFamily + ".zip", reporthook=dlProgress)
print("\nExtracting data...")
# don't know how to do this.
# don't know how to do this. The following works for linux/unix...need a more universal solution
with ZipFile("../InputData/") as myzip:
myzip.extract(member='phase-retrieval-benchmarks-master/data/', 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("" + problemFamily + ".tar.gz","../InputData/" + problemFamily + ".tar.gz", reporthook=dlProgress)
print("\nExtracting data...")
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