Commit a3b9e480 authored by alexander.dornheim's avatar alexander.dornheim
Browse files

Added automatic download of InputData to Siemens_processor

parent 311aee95
......@@ -49,7 +49,7 @@ def CDI_data_processor(config):
data_ball = config['data_ball']
f = loadmat('../InputData/phase_retrieval/CDI_intensity.mat')
f = loadmat('../InputData/Phase/CDI_intensity.mat')
# diffraction pattern
dp = f['intensity']['img'][0,0]
......@@ -36,7 +36,7 @@ def JWST_data_processor(config):
noise = config['noise'];
snr = config['data_ball'];
with open('../InputData/phase_retrieval/pupil.pmod','r') as fid:
with open('../InputData/Phase/pupil.pmod','r') as fid:
# read lower endian float <f
Xi_A = np.fromfile(fid, dtype='<f');
Xi_A = Xi_A.astype(np.float64)
......@@ -9,6 +9,7 @@ from pathlib import Path
import os
import proxtoolbox.Utilities.GetData as GetData
import urllib.request
import tarfile
def Siemens_processor(config):
......@@ -17,22 +18,25 @@ def Siemens_processor(config):
noise = config['noise']
snr = config['data_ball']
my_file = Path("../InputData/phase_retrieval/Siemens_star_200px.mat")
my_file = Path("../InputData/Phase/Siemens_star_200px.mat")
if not(my_file.is_file()):
print('* Input data missing. Please download the phase input data from *')
print('* *')
print('* Save and unpack the Phase.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
Automatic download
if GetData.query_yes_no("Phase retrieval input data could not be found. Do you want to download the Phase retrieval input data?"):
urllib.request.urlretrieve("","../InputData/phase_retrieval/proxtoolbox-matlab.tar.gz", reporthook=GetData.dlProgress)'''
print("Phase input data is missing.")
if GetData.query_yes_no("Do you want to download the phase input data?"):
urllib.request.urlretrieve("","../InputData/Phase.tar.gz", reporthook=GetData.dlProgress)
print("\nExtracting data...")
tar ="../InputData/Phase.tar.gz", "r:gz")
if not(my_file.is_file()):
print('* Input data still missing. Please try automatic download again or manually download *')
print('* *')
print('* Save and unpack the Phase.tar.gz datafile in the *')
print('* ProxMatlab/InputData subdirectory *')
print('Loading data file: Siemens_star_200px.mat')
S = np.loadtxt('../InputData/phase_retrieval/Siemens_star_200px.mat')
S = np.loadtxt('../InputData/Phase/Siemens_star_200px.mat')
dim =np.shape(S)
The "Utilities.GetData"-module contains various ...
from .query_yes_no import *
from .dlProgress import *
__all__ = ["dlProgress,query_yes_no"]
import sys
def dlProgress(counter, blocksize, size):
p = counter*blocksize*100.0/size
sys.stdout.write("\rProgress: %d%%" % p)
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]
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