forked from tomr-stargazer/wuvars_perseus
/
tablemate_script_perseus.py
194 lines (158 loc) · 7.38 KB
/
tablemate_script_perseus.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
186
187
188
189
190
191
192
193
"""
This is the SCRIPT that mates tables in the NGC1333 catalog,
by calling the MODULE tablemate_core.py.
This should be kept, broadly, in sync with the Google Doc
"Auxiliary Tables in NGC1333".
# change this --
We are asking three broad questions:
1. How many of our variables are previously-known sources?
2. How many of our variables are previously-known variables?
3. How many previously-known variables in this field do we recover?
"""
import os
import numpy as np
import astropy.table
import tablemate_core
from tablemate_core import TableParameters, atpy
#import megeath_fulltable_parser_oneoff
# Top half of the script: defining various tables
dpath = os.path.expanduser("~/Dropbox/Bo_Tom/NGC1333/WSERV7/aux_catalogs/")
tables = []
WUVARS_maxvars_p = TableParameters(
data = dpath+"maxvars_spread_with_preliminary_IDs.fits",
alias= "WUVARS_2014_preliminary",
full_name = "'Master spreadsheet for 647 candidate variables', from 'Near-Infrared Variables in NGC1333', Reipurth & Rice.",
ra_cols = ['RA'], dec_cols=['DEC'],
radec_fmt = 'decimal-radians',
name_col = 'preliminary_ID')
WUVARS_allvars_t = TableParameters(
data = dpath+"allvars_spread_with_temporary_IDs.fits",
alias= "WUVARS_2014_temporary",
full_name = "'Master spreadsheet for 165 likely variables', from 'Near-Infrared Variables in NGC1333', Reipurth & Rice.",
ra_cols = ['RA'], dec_cols=['DEC'],
radec_fmt = 'decimal-radians',
name_col = 'temporary_ID')
WUVARS_allvars_f = TableParameters(
data = dpath+"allvars_spread_with_final_IDs.fits",
alias= "WUVARS_2014_final",
full_name = "'Master spreadsheet for 160 final variables', from 'Near-Infrared Variables in NGC1333', Reipurth & Rice.",
ra_cols = ['RA'], dec_cols=['DEC'],
radec_fmt = 'decimal-radians',
name_col = 'final_ID')
Twomass = TableParameters(
data = dpath+"2MASS_PSC_boxsearch_1degree_NGC1333.tbl",
alias = "2MASS_PSC",
full_name = "Two Micron All-Sky Survey: All-Sky Data Release Point Source Catalog. Released 2003 Mar 25. Box search: center (52.20630610 +31.28607228), sidelength 3600 arcsec.",
ra_cols = ['ra'], dec_cols = ['dec'],
radec_fmt = 'decimal-degrees',
name_col = 'designation')
tables.append(Twomass)
Gutermuth_2008 = TableParameters(
data = dpath+"Gutermuth2008_table2.fits",
alias = 'SpYSO',
full_name = "'Spitzer-identified YSOs: 2MASS, IRAC and MIPS photometries, and addendum (tables 2 and 3 of paper)', from 'SPITZER OBSERVATIONS OF NGC 1333: A STUDY OF STRUCTURE AND EVOLUTION IN A NEARBY EMBEDDED CLUSTER', Gutermuth et al. (2008).",
ra_cols = ['RAJ2000'], dec_cols = ['DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = 'Seq')
tables.append(Gutermuth_2008)
# 1. J/ApJ/744/6/table2 (c)New very low mass members in NGC 1333, Table 2 from 2012ApJ...744....6S (10 rows)
# 2. J/ApJ/744/6/tablen1 (c)New very low mass members of NGC 1333, Table 1 from 2012ApJ...756...24S (7 rows)
# 3. J/ApJ/744/6/table4 (c)Previously confirmed very low mass members in NGC 1333, Table 4 from 2012ApJ...744....6S (41 rows)
# tid=0 : J/ApJ/744/6/table2
# tid=1 : J/ApJ/744/6/tablen1
# tid=2 : J/ApJ/744/6/table4
Scholz_2009 = TableParameters(
data = atpy.Table(dpath+'Scholz_vizier_votable.vot', tid=2, verbose=False),
alias = "Scho09",
full_name = "'Previously confirmed very low mass members in NGC 1333, Table 4 from 2012ApJ...744....6S'",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = 'ID')
tables.append(Scholz_2009)
Scholz_2012a = TableParameters(
data = atpy.Table(dpath+'Scholz_vizier_votable.vot', tid=0, verbose=False),
alias = "Scho12a",
full_name = "New very low mass members in NGC 1333, Table 2 from 2012ApJ...744....6S",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = 'SONYC')
tables.append(Scholz_2012a)
Scholz_2012b = TableParameters(
data = atpy.Table(dpath+'Scholz_vizier_votable.vot', tid=1, verbose=False),
alias = "Scho12b",
full_name = "New very low mass members of NGC 1333, Table 1 from 2012ApJ...756...24S",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = 'SONYC')
tables.append(Scholz_2012b)
Wilking_2004 = TableParameters(
data = dpath+'Wilking2004_vizier_votable.vot',
alias = 'MBO',
full_name = "'Table 1: Photometry of northern NGC 1333 cluster' from 'NGC 1333 low-mass stars infrared photometry (Wilking+, 2004)'",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = 'MBO'
)
tables.append(Wilking_2004)
Getman_2002 = TableParameters(
data = atpy.Table(dpath+"Getman2002_vizier_votable.vot", tid=0, verbose=False),
alias = 'ACIS',
full_name = "'Table 1: ACIS NGC 1333 sources and stellar identifications', from 'Young stellar objects in the NGC 1333 (Getman+, 2002)'",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = '__GFT2002_',
max_match = 2.0)
tables.append(Getman_2002)
Aspin_1994 = TableParameters(
data = dpath+"Aspin1994.fits",
alias = 'ASR',
full_name = "'Sources in NGC1333-S (tables 1, 2, 3 and 5 of paper)' from 'Near-IR imaging photometry of NGC 1333 (Aspin+ 1994)'",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = 'ASR')
tables.append(Aspin_1994)
Lada_1996 = TableParameters(
data = dpath+"LadaAL.fits",
alias = 'LAL',
full_name = "'Catalogue' from 'JHK photometry of NGC1333 (Lada+, 1996)'",
ra_cols = ['_RAJ2000'], dec_cols = ['_DEJ2000'],
radec_fmt = 'decimal_degrees',
name_col = '__LAL96_'
)
tables.append(Lada_1996)
arnold_data = astropy.table.Table.read(dpath+'Arnold2012_table1.txt', format='ascii.tab', delimiter='\t')
Arnold_2012 = TableParameters(
data = arnold_data,
alias = 'ARN12',
full_name = "'Basic Data' from 'A Spitzer IRS Survey of NGC 1333: Insights into Disk Evolution from a Very Young Cluster (Arnold+, 2012)'",
ra_cols = ['RAJ2000'], dec_cols = ['DEJ2000'],
radec_fmt = 'sex-three',
name_col = 'Index'
)
tables.append(Arnold_2012)
# Here's our first function, that we'll use just to get things rolling
def test():
return tablemate_core.tablemater(WUVARS_maxvars_p, [Twomass, Gutermuth_2008, Scholz_2009, Wilking_2004, Getman_2002])
def vars_match(primary_table=WUVARS_allvars_f):
"""
A function that matches our variables table to all the other tables!
Takes about 15 seconds (2/13/13).
"""
return tablemate_core.tablemater( primary_table, tables)
def merge_scholz_columns(matched_table):
"""
Takes in a table with 3 Scholz columns and merges them into one Scholz column.
"""
pk = matched_table.columns.keys[0]
matched_table_copy = matched_table.where(matched_table[pk] == matched_table[pk])
scholz_a = matched_table['Scho09_ID']
scholz_b = matched_table['Scho12a_ID']
scholz_c = matched_table['Scho12b_ID']
for i in range(len(scholz_a)):
if scholz_a[i] == '-1' and scholz_b[i] != '-1':
scholz_a[i] = scholz_b[i]
elif scholz_a[i] == '-1' and scholz_c[i] != '-1':
scholz_a[i] = scholz_c[i]
matched_table_copy.remove_columns(['Scho09_ID', 'Scho12a_ID', 'Scho12b_ID'])
matched_table_copy.add_column(name='Scholz_ID', data=scholz_a, after='SpYSO_index')
return matched_table_copy