-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
185 lines (148 loc) · 6.56 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import argparse
import meerkat_processing.photometry as photometry
import meerkat_processing.bane_processing as bane_processing
import meerkat_processing.assign_id as assign_id
import meerkat_processing.combine_photometry as combine_photometry
import meerkat_processing.full_catalog as full_catalog
import meerkat_processing.process_neighbors as process_neighbors
import meerkat_processing.create_plots as create_plots
import os
import logging
from app_logging import logger
from common.main_checks import check_folder_loc, check_main_folder, check_multi_folders
def start_photometry(args):
check_folder_loc(args)
path = args.folder_loc
path_check = os.path.isdir(path)
if path_check:
try:
logging.info('Beginning Photometry processing')
photometry.process_photometry(path)
except Exception as e:
logging.exception(msg='Photometry exited without processing', exc_info=e)
else:
logging.warning('folder_loc does not contain a valid filepath')
def start_bane(args):
check_folder_loc(args)
path = args.folder_loc
path_check = os.path.isdir(path)
if path_check:
try:
logging.info('Beginning Bane background processing')
bane_processing.begin_bane(path)
except Exception as e:
logging.exception(msg='Bane exited without processing', exc_info=e)
else:
logging.warning('folder_loc does not contain a valid filepath')
def start_combine(args):
check_folder_loc(args)
path = args.folder_loc
path_check = os.path.isdir(path)
if path_check:
try:
logging.info('Beginning Combine')
combine_photometry.begin_combine(path)
except Exception as e:
logging.exception(msg='Combine exited without processing', exc_info=e)
else:
logging.warning('folder_loc does not contain a valid filepath')
def start_assign_id(args):
check_main_folder(args)
path = args.main_folder
path_check = os.path.isdir(path)
if path_check:
try:
logging.info('Beginning Assign_ID')
assign_id.begin_assign(path)
except Exception as e:
logging.exception(msg='Assign_ID exited without processing', exc_info=e)
else:
logging.warning('--main_folder does not contain a valid filepath')
def start_full_catalog(args):
check_main_folder(args)
path = args.main_folder
path_check = os.path.isdir(path)
if path_check:
try:
logging.info('Beginning Full_Catalog')
full_catalog.begin_full_catalog(path)
except Exception as e:
logging.exception(msg='Full catalog exited without processing', exc_info=e)
else:
logging.warning('--main_folder does not contain a valid filepath')
def start_neighbors(args):
check_multi_folders(args)
folder_one = args.folder_one
folder_two = args.folder_two
folder_three = args.folder_three
path_check_one = os.path.isdir(folder_one)
path_check_two = os.path.isdir(folder_two)
path_check_three = os.path.isdir(folder_three)
if path_check_one and path_check_two and path_check_three:
try:
logging.info('Beginning Neighbors')
process_neighbors.begin_neighbors(folder_one, folder_two, folder_three)
except Exception as e:
logging.exception(msg='Exception in Nieghbors.', exc_info=e)
else:
logging.warning('Please check all three folder paths are valid to run Neighbors.')
def start_plotting(args):
check_multi_folders(args)
folder_one = args.folder_one
folder_two = args.folder_two
folder_three = args.folder_three
path_check_one = os.path.isdir(folder_one)
path_check_two = os.path.isdir(folder_two)
path_check_three = os.path.isdir(folder_three)
if path_check_one and path_check_two and path_check_three:
try:
logging.info('Beginning Plotting')
create_plots.begin_plotting(folder_one, folder_two, folder_three, all=False, bright=True)
except Exception as e:
logging.exception(msg='Exception in Plotting.', exc_info=e)
else:
logging.warning('Please check all three folder paths are valid to run Plotting.')
if __name__ == '__main__':
logger.init(logging.DEBUG, '.', 'app_logging')
parser = argparse.ArgumentParser(description='Please indicate which process you will be running:'
'Bane,Photometry, Combine, Full_Catalog, Neighbors, Assign_Id. Bane,'
' Photometry and Combine require --folder_loc. Neighbors requires '
'--folder_one, --folder_two, and --folder_three. Assign_ID and '
'Full_Catalog require --main_folder.')
parser.add_argument('--process')
parser.add_argument('--folder_loc')
parser.add_argument('--main_folder')
parser.add_argument('--folder_one')
parser.add_argument('--folder_two')
parser.add_argument('--folder_three')
args = parser.parse_args()
if not args.process:
logging.warning('Please indicate which process you will be running using --process. \n'
'Available processes: Bane, Photometry, Combine, Full_Catalog, Neighbors, or Assign_Id. \nBane,'
' Photometry and Combine require --folder_loc. \nNeighbors requires '
'--folder_one, --folder_two, and --folder_three. \nAssign_ID and '
'Full_Catalog require --main_folder.')
if args.process.lower() == 'photometry':
start_photometry(args)
exit()
elif args.process.lower() == 'bane':
start_bane(args)
exit()
elif args.process.lower() == 'combine':
start_combine(args)
exit()
elif args.process.lower() == 'assign_id':
start_assign_id(args)
exit()
elif args.process.lower() == 'full_catalog':
start_full_catalog(args)
exit()
elif args.process.lower() == 'neighbors':
start_neighbors(args)
exit()
elif args.process.lower() == 'plotting':
start_plotting(args)
exit()
else:
logging.warning('Input for --process is not recognized. Please check argument and choose from the following '
'list:\nbane, photometry, combine, full_catalog, assign_id, neighbors.')