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
b0eb94c3
Commit
b0eb94c3
authored
Feb 04, 2021
by
Schellhorn
Browse files
Elser Data adding
parent
128499cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
proxtoolbox/utils/GetData/GetData.py
View file @
b0eb94c3
...
...
@@ -2,6 +2,7 @@ from pathlib import Path
import
sys
import
urllib.request
import
tarfile
from
zipfile
import
ZipFile
datadir
=
Path
(
__file__
).
parent
.
parent
.
parent
.
parent
/
'InputData'
...
...
@@ -35,18 +36,28 @@ def getData(problemFamily):
elif
problemFamily
==
'OrbitalTomog'
:
errMsg
=
'OrbitalTomog downloader is yet a work in progress'
raise
IOError
(
errMsg
)
elif
problemFamily
==
'Elser'
:
my_file
=
datadir
/
'Elser'
/
'RRR.c'
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."
)
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"
,
datadir
/
(
problemFamily
+
'.tar.gz'
),
reporthook
=
dlProgress
)
print
(
"
\n
Extracting data..."
)
tar
=
tarfile
.
open
(
datadir
/
(
problemFamily
+
'.tar.gz'
),
"r:gz"
)
tar
.
extractall
(
datadir
/
problemFamily
)
tar
.
close
()
if
problemFamily
==
'Elser'
:
link
=
'https://github.com/veitelser/phase-retrieval-benchmarks/archive/master.zip'
urllib
.
request
.
urlretrieve
(
link
,
datadir
/
(
problemFamily
+
'.zip'
),
reporthook
=
dlProgress
)
print
(
"
\n
Extracting data..."
)
with
ZipFile
(
datadir
/
(
problemFamily
+
'.zip'
),
'r'
)
as
zipObj
:
zipObj
.
extractall
(
datadir
/
problemFamily
)
else
:
link
=
" http://vaopt.math.uni-goettingen.de/data/"
+
problemFamily
+
".tar.gz"
urllib
.
request
.
urlretrieve
(
link
,
datadir
/
(
problemFamily
+
'.tar.gz'
),
reporthook
=
dlProgress
)
print
(
"
\n
Extracting data..."
)
tar
=
tarfile
.
open
(
datadir
/
(
problemFamily
+
'.tar.gz'
),
"r:gz"
)
tar
.
extractall
(
datadir
/
problemFamily
)
tar
.
close
()
if
not
(
my_file
.
is_file
()):
print
(
'***************************************************************************************'
)
print
(
'* Input data still missing. Please try automatic download again or manually download *'
)
...
...
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