Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nam
ProxPython
Commits
eac39412
Commit
eac39412
authored
Jan 21, 2021
by
Schellhorn
Browse files
local path to absolute path reference in GetData
parent
71895a36
Changes
1
Hide whitespace changes
Inline
Side-by-side
proxtoolbox/utils/GetData/GetData.py
View file @
eac39412
...
...
@@ -3,6 +3,8 @@ import sys
import
urllib.request
import
tarfile
datadir
=
Path
(
__file__
).
parent
.
parent
.
parent
.
parent
/
'InputData'
#shows progress of download
def
dlProgress
(
counter
,
blocksize
,
size
):
p
=
counter
*
blocksize
*
100.0
/
size
...
...
@@ -25,11 +27,11 @@ def query_yes_no(question):
#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
"
)
my_file
=
datadir
/
'
Phase
'
/
'
pupil.pmod
'
elif
problemFamily
==
'CT'
:
my_file
=
P
at
h
(
"../InputData/CT/
ART_SheppLogan.mat
"
)
my_file
=
d
at
adir
/
'CT'
/
'
ART_SheppLogan.mat
'
elif
problemFamily
==
'Ptychography'
:
my_file
=
Path
(
"../InputData/
Ptychography
/
gaenseliesel.png
"
)
my_file
=
datadir
/
'
Ptychography
'
/
'
gaenseliesel.png
'
else
:
print
(
"Invalid input in GetData.GetData. problemFamily has to be Phase, CT or Ptychography"
)
return
-
1
...
...
@@ -37,10 +39,10 @@ def getData(problemFamily):
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
)
urllib
.
request
.
urlretrieve
(
" http://vaopt.math.uni-goettingen.de/data/"
+
problemFamily
+
".tar.gz"
,
datadir
/
(
problemFamily
+
'
.tar.gz
'
)
,
reporthook
=
dlProgress
)
print
(
"
\n
Extracting data..."
)
tar
=
tarfile
.
open
(
"../InputData/"
+
problemFamily
+
"
.tar.gz
"
,
"r:gz"
)
tar
.
extractall
(
"../InputData/"
+
problemFamily
)
tar
=
tarfile
.
open
(
datadir
/
(
problemFamily
+
'
.tar.gz
'
)
,
"r:gz"
)
tar
.
extractall
(
datadir
/
problemFamily
)
tar
.
close
()
if
not
(
my_file
.
is_file
()):
print
(
'***************************************************************************************'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment