Commit 05cde538 authored by Russell Luke's avatar Russell Luke
Browse files

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

parents c2881ca3 1007437f
......@@ -26,22 +26,8 @@ import tarfile
def ART_data_processor(config):
my_file = Path("../InputData/CT/ART_SheppLogan.mat")
if not(my_file.is_file()):
print("CT input data is missing.")
if GetData.query_yes_no("Do you want to download the CT input data?"):
urllib.request.urlretrieve("http://vaopt.math.uni-goettingen.de/data/CT.tar.gz","../InputData/CT.tar.gz", reporthook=GetData.dlProgress)
print("\nExtracting data...")
tar = tarfile.open("../InputData/CT.tar.gz", "r:gz")
tar.extractall("../InputData/CT/")
tar.close()
if not(my_file.is_file()):
print('***************************************************************************************')
print('* Input data still missing. Please try automatic download again or manually download *')
print('* http://vaopt.math.uni-goettingen.de/data/CT.tar.gz *')
print('* Save and unpack the CT.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('***************************************************************************************')
#make sure input data can be found, otherwise download it
GetData.getData('CT')
# load toy data
print('Loading data file ART_SheppLogan.mat ')
......
......@@ -30,24 +30,10 @@ from numpy import ceil, zeros, sqrt
def BLOCK_ART_data_processor(config):
my_file = Path("../InputData/CT/ART_SheppLogan.mat")
if not(my_file.is_file()):
print("CT input data is missing.")
if GetData.query_yes_no("Do you want to download the CT input data?"):
urllib.request.urlretrieve("http://vaopt.math.uni-goettingen.de/data/CT.tar.gz","../InputData/CT.tar.gz", reporthook=GetData.dlProgress)
print("\nExtracting data...")
tar = tarfile.open("../InputData/CT.tar.gz", "r:gz")
tar.extractall("../InputData/CT/")
tar.close()
if not(my_file.is_file()):
print('***************************************************************************************')
print('* Input data still missing. Please try automatic download again or manually download *')
print('* http://vaopt.math.uni-goettingen.de/data/CT.tar.gz *')
print('* Save and unpack the CT.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('***************************************************************************************')
# load toy data
#make sure input data can be found, otherwise download it
GetData.getData('CT')
# load toy data
if config['fanbeam'] != 'yes':
print('Loading data file ART_SheppLogan.mat ')
ART = scipy.io.loadmat('../InputData/CT/ART_SheppLogan.mat')
......
from pathlib import Path
import numpy as np
from numpy import exp, sqrt, log2,log10, floor, unravel_index, argmax, zeros
from scipy.io import loadmat
......@@ -12,28 +11,13 @@ import proxtoolbox.Utilities.GetData as GetData
import urllib.request
import tarfile
#for downloading input data
import proxtoolbox.Utilities.GetData as GetData
def Goettingen_data_processor(config):
# Parameters of the forward problem
my_file = Path("../InputData/Phase/cell256.mat")
if not(my_file.is_file()):
print("Phase input data is missing.")
if GetData.query_yes_no("Do you want to download the phase input data?"):
urllib.request.urlretrieve("http://vaopt.math.uni-goettingen.de/data/Phase.tar.gz","../InputData/Phase.tar.gz", reporthook=GetData.dlProgress)
print("\nExtracting data...")
tar = tarfile.open("../InputData/Phase.tar.gz", "r:gz")
tar.extractall("../InputData/Phase/")
tar.close()
if not(my_file.is_file()):
print('***************************************************************************************')
print('* Input data still missing. Please try automatic download again or manually download *')
print('* http://num.math.uni-goettingen.de/data/Phase.tar.gz *')
print('* Save and unpack the Phase.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('***************************************************************************************')
#make sure input data can be found, otherwise download it
GetData.getData('Phase')
experiment = config['experiment']
......
......@@ -27,30 +27,13 @@ from numpy.linalg import norm
from numpy.fft import fftshift
import proxtoolbox.Utilities as Utilities
#for loading data
from pathlib import Path
#for downloading data
import proxtoolbox.Utilities.GetData as GetData
import urllib.request
import tarfile
def JWST_data_processor(config):
my_file = Path("../InputData/Phase/pupil.pmod")
if not(my_file.is_file()):
print("Phase input data is missing.")
if GetData.query_yes_no("Do you want to download the phase input data?"):
urllib.request.urlretrieve(" http://vaopt.math.uni-goettingen.de/data/Phase.tar.gz","../InputData/Phase.tar.gz", reporthook=GetData.dlProgress)
print("\nExtracting data...")
tar = tarfile.open("../InputData/Phase.tar.gz", "r:gz")
tar.extractall("../InputData/Phase")
tar.close()
if not(my_file.is_file()):
print('***************************************************************************************')
print('* Input data still missing. Please try automatic download again or manually download *')
print('* http://vaopt.math.uni-goettingen.de/data/Phase.tar.gz *')
print('* Save and unpack the Phase.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('***************************************************************************************')
#make sure input data can be found, otherwise download it
GetData.getData('Phase')
#moved here from JWST_in since if statements not possible in dictonary
if 'distance' in config:
......
......@@ -5,12 +5,9 @@ from numpy.linalg import norm
from numpy.fft import fft2, ifft2
from numpy.random import rand
import proxtoolbox.Utilities as Utilities
from pathlib import Path
import os
import proxtoolbox.Utilities.GetData as GetData
import urllib.request
import tarfile
#for downloading input data
import proxtoolbox.Utilities.GetData as GetData
def Siemens_processor(config):
data_ball = config['data_ball']
......@@ -18,22 +15,8 @@ def Siemens_processor(config):
noise = config['noise']
snr = config['data_ball']
my_file = Path("../InputData/Phase/Siemens_star_200px.mat")
if not(my_file.is_file()):
print("Phase input data is missing.")
if GetData.query_yes_no("Do you want to download the phase input data?"):
urllib.request.urlretrieve("http://num.math.uni-goettingen.de/~r.luke/tmp/Phase.tar.gz","../InputData/Phase.tar.gz", reporthook=GetData.dlProgress)
print("\nExtracting data...")
tar = tarfile.open("../InputData/Phase.tar.gz", "r:gz")
tar.extractall("../InputData/")
tar.close()
if not(my_file.is_file()):
print('***************************************************************************************')
print('* Input data still missing. Please try automatic download again or manually download *')
print('* http://num.math.uni-goettingen.de/data/Phase.tar.gz *')
print('* Save and unpack the Phase.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('***************************************************************************************')
#make sure input data can be found, otherwise download it
GetData.getData('Phase')
print('Loading data file: Siemens_star_200px.mat')
S = np.loadtxt('../InputData/Phase/Siemens_star_200px.mat')
......
......@@ -23,6 +23,9 @@ from proxtoolbox.ProxOperators import magproj
from proxtoolbox.ProxOperators.proxoperators import ProxOperator
from multiprocessing import Pool
#for downloading input data
import proxtoolbox.Utilities.GetData as GetData
#choose backend
import matplotlib
matplotlib.use('Qt5Agg')
......@@ -1941,6 +1944,10 @@ class Ptychography(Problem):
sample_plane = None;
if self.config['sim_data_type'] == 'gaenseliesel':
#make sure input data can be found, otherwise download it
GetData.getData('Ptychography')
g = pyplot.imread('../InputData/Ptychography/gaenseliesel.png').astype(numpy.float);
g /= numpy.amax(g);
g = 0.8*g + 0.1;
......@@ -2445,6 +2452,9 @@ class Ptychography_NTT_01_26210(Ptychography):
Overloads the corresponding method of :class:`Ptychography`
to create other experiment data
"""
#make sure input data can be found, otherwise download it
GetData.getData('Ptychography')
data = scipy.io.loadmat('../InputData/Ptychography/data_NTT_01_26210_192x192.mat');
d1y = data['d1y'][0][0];
d1x = data['d1x'][0][0];
......
from pathlib import Path
import sys
import urllib.request
import tarfile
#shows progress of download
def dlProgress(counter, blocksize, size):
p = counter*blocksize*100.0/size
sys.stdout.write("\rProgress: %d%%" % p)
sys.stdout.flush()
#function to ask permission for donwload from user
def query_yes_no(question):
choices = "[y/n] "
valid_answer = {'y':True, 'ye':True, 'yes':True, 'n':False, 'ne':False}
while True:
sys.stdout.write(question + choices)
answer = input().lower()
if answer in valid_answer:
return valid_answer[answer]
else:
sys.stdout.write("Please respond with 'yes' or 'no'. \n")
#downloads the input data to the InputData folder. problemFamily has to be either Phase, CT or Ptychography
def getData(problemFamily):
if problemFamily == 'Phase':
my_file = Path("../InputData/Phase/pupil.pmod")
elif problemFamily == 'CT':
my_file = Path("../InputData/CT/ART_SheppLogan.mat")
elif problemFamily == 'Ptychography':
my_file = Path("../InputData/Ptychography/gaenseliesel.png")
else:
print("Invalid input in GetData.GetData. problemFamily has to be Phase, CT or Ptychography")
return -1
if not(my_file.is_file()):
print(problemFamily + " input data is missing.")
if 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('* Input data still missing. Please try automatic download again or manually download *')
print('* http://vaopt.math.uni-goettingen.de/data/' + problemFamily + '.tar.gz *')
print('* Save and unpack the ' + problemFamily + '.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('***************************************************************************************')
"""
The "Utilities.GetData"-module contains various ...
The "Utilities.GetData"-module contains functions to download the InputData for the example problems
"""
from .query_yes_no import *
from .dlProgress import *
from .GetData import *
__all__ = ["dlProgress", "query_yes_no"]
__all__ = ["dlProgress", "query_yes_no", "getData"]
import sys
def dlProgress(counter, blocksize, size):
p = counter*blocksize*100.0/size
sys.stdout.write("\rProgress: %d%%" % p)
sys.stdout.flush()
import sys
def query_yes_no(question):
choices = "[y/n] "
valid_answer = {'y':True, 'ye':True, 'yes':True, 'n':False, 'ne':False}
while True:
sys.stdout.write(question + choices)
answer = input().lower()
if answer in valid_answer:
return valid_answer[answer]
else:
sys.stdout.write("Please respond with 'yes' or 'no'. \n")
Supports Markdown
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