-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathundo_tat_reduction.py
executable file
·58 lines (57 loc) · 1.59 KB
/
undo_tat_reduction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python
'''
Program:
This code is used to restore data structure
Restoring make test easier
Usage:
undo_tat_reduction.py
Editor:
Jacob975
20180621
#################################
update log
20180621 version alaph 1
1. The code works
20180625 version alpha 2
1. The code renamed from restore_tat_data.py to flatten_tat_data.py
20180710 version alpha 3
1. Rename from flatten_tat_data.py to undo_tat_reduction.py
'''
import os
from glob import glob
import time
import TAT_env
from sys import argv
def undo_tat_reduction():
# Move images back to base directory
command = "find . -mindepth 2 -type f -exec mv -t . '{}' +"
os.system(command)
# Remove all sub-folder
command = "rm -R -- */"
os.system(command)
# Remove synthesis files
command = "rm *_list* *.fits *.tar *.pro *.dat *.reg *.new"
os.system(command)
# Remove all indications
X_denotations = glob('X_*_X')
for name in X_denotations:
command = "mv {0} {1}".format(name, name[2:-2])
os.system(command)
return
#--------------------------------------------
# main code
if __name__ == "__main__":
# measure times
start_time = time.time()
#----------------------------------------
working_dir = os.getcwd()
given_dir = working_dir
if len(argv) == 2:
given_dir = argv[1]
os.chdir(given_dir)
undo_tat_reduction()
os.chdir(working_dir)
#---------------------------------------
# measuring time
elapsed_time = time.time() - start_time
print "Exiting Main Program, spending ", elapsed_time, "seconds."