-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentify_known_vvv_variables.py
93 lines (75 loc) · 2.88 KB
/
identify_known_vvv_variables.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
# Program to compile a list of variable stars identified from the VVV survey
# within a specific set of pointings.
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table, Column
from astropy.io import fits
import rges_survey_definition
import argparse
from os import path
import utils
# Configuration
# Location of data files
config = {
'data_dir': './data/',
'variable_catalogs': {
'lpv': {'file': 'VVV_LPV_J_A+A_660_A35_tableb2.fits', 'columns': [0,2,3]},
'miras': {'file': 'VVV_Miras_J_A+A_660_A35_tableb1.fits', 'columns': [0,1,2]},
}
}
def find_vvv_variables(args, config):
"""
Function to identify known variables from the VVV catalogs within the RGES survey
region
:param args: dict of user-provided configuration parameters
:param config: dict of standard configurable key-value pairs
:return: None, outputs JSON-format catalog
"""
# Load and combine the lists of OGLE4 variables of different types
vvv_catalog = load_vvv_variable_catalogs(config)
# Identify those objects within the field of view of all given fields
survey_catalog = utils.find_variables_in_fov(vvv_catalog, coord_type='degrees')
# Output catalog of known variables within the field
utils.output_json_catalog_from_table(survey_catalog, args.output_file)
def load_vvv_variable_catalogs(config):
"""
Function to load the variable star catalogs from VVV.
These are accessed via the FITS binary tables served from the CDS archive.
See data/README.md for details.
:param config:
:return: dict combine catalog of variable stars
"""
catalog = {
'name': [],
'type': [],
'ra': [],
'dec': []
}
for cat_type, cat_config in config['variable_catalogs'].items():
with fits.open(path.join(config['data_dir'],cat_config['file'])) as hdul:
data = hdul[1].data
for entry in data:
catalog['name'].append(str(entry[cat_config['columns'][0]]))
catalog['type'].append(cat_type)
catalog['ra'].append(float(entry[cat_config['columns'][1]]))
catalog['dec'].append(float(entry[cat_config['columns'][2]]))
vvv_catalog = Table([
Column(name='Name', data=catalog['name']),
Column(name='Type', data=catalog['type']),
Column(name='RA', data=catalog['ra']),
Column(name='Dec', data=catalog['dec'])
])
print('Loaded ' + str(len(vvv_catalog)) + ' known variables from VVV')
return vvv_catalog
def get_args():
"""
Gather user-provided input
:return: args dict Set of argument key-value pairs
"""
parser = argparse.ArgumentParser()
parser.add_argument('output_file', help='Path to output file')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = get_args()
find_vvv_variables(args, config)