-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulk_extract_lightcurves.py
62 lines (52 loc) · 2.19 KB
/
bulk_extract_lightcurves.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
# Convenience function to extract the lightcurves from UKIRT
from os import path
import argparse
import extract_lightcurves_from_index
class Config():
def __init__(self):
self.var_catalog_file = None
self.ukirt_index_dir = None
self.year = None
self.field = None
self.ccd = None
self.star_type = None
self.output_dir = None
def run_extraction(args):
"""
The UKIRT lightcurve archive is so large that it is most efficient to
load the source catalog indices on a per-year, field and CCD basis,
rather than keep re-reading these large files for each star.
There are 296 of these index files though, so this bulk extraction
code is designed to loop over each one in turn.
"""
# Configuration
years = range(2015, 2018, 1)
fields = range(1, 65, 1)
ccds = range(1, 5, 1)
for yr in years:
for field in fields:
for ccd in ccds:
src_table_id = 'UKIRT_year' + str(yr) + '_field' + str(field) + '_ccd' + str(ccd)
index_file = path.join(args.ukirt_index_dir, src_table_id + '.json')
if path.isfile(index_file):
print('Extracting lightcurves from ' + src_table_id)
conf = Config()
conf.var_catalog_file = args.var_catalog_file
conf.ukirt_index_dir = args.ukirt_index_dir
conf.year = str(yr)
conf.field = str(field)
conf.ccd = str(ccd)
conf.star_type = args.star_type
conf.output_dir = args.output_dir
extract_lightcurves_from_index.gather_data(conf)
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument('var_catalog_file', help='Path to variable input catalog')
parser.add_argument('ukirt_index_dir', help='Path to top-level UKIRT lightcurve index directory')
parser.add_argument('star_type', help='Type of variable to extract or ALL')
parser.add_argument('output_dir', help='Path to output data directory')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = get_args()
run_extraction(args)