-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrange_label.py
More file actions
executable file
·50 lines (47 loc) · 1.35 KB
/
Copy patharrange_label.py
File metadata and controls
executable file
·50 lines (47 loc) · 1.35 KB
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
#!/usr/bin/python3
'''
Abstract:
This is a program for rearrange labels.
Usage:
arrange_label.py [data] [selector]
Editor:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
##################################
20181030
####################################
update log
'''
import numpy as np
import time
from sys import argv
#--------------------------------------------
# Main code
if __name__ == "__main__":
VERBOSE = 0
# Measure time
start_time = time.time()
#-----------------------------------
# Load argv
if len(argv) != 3:
print ('Error')
print ('The number of arguments is wrong.')
print ('Usage: arrange_label.py [data] [selector]')
exit()
data_name = argv[1]
selector_name = argv[2]
#-----------------------------------
# Load data
data = np.loadtxt(data_name)
selector = np.loadtxt(selector_name, dtype = int)
sub_names = ['star', 'gala', 'ysos']
for i in range(3):
sub_selector = np.where(selector == i)
sub_data = data[sub_selector]
np.savetxt('{0}_{1}.txt'.format(data_name[:-4], sub_names[i]), sub_data)
#-----------------------------------
# Measure time
elapsed_time = time.time() - start_time
print("Exiting Main Program, spending ", elapsed_time, "seconds.")