In [1]:
# imports
import numpy as np
from pkg_resources import resource_filename
from astropy.table import Table, MaskedColumn
from specdb.cat_utils import match_ids
from dla_cnn import io as dla_io
In [2]:
g16_abs = dla_io.load_garnett16(orig=True)
In [3]:
g16_abs.keys()
Out[3]:
In [4]:
tbl1_file = resource_filename('dla_cnn', 'catalogs/boss_dr12/MNRAS/table1.dat')
In [5]:
tbl1 = Table.read(tbl1_file, format='ascii')
In [6]:
tbl1[0:5]
Out[6]:
In [7]:
tbl2_file = resource_filename('dla_cnn', 'catalogs/boss_dr12/MNRAS/table2.dat')
In [8]:
tbl2 = Table.read(tbl2_file, format='ascii')
In [9]:
tbl2[0:5]
Out[9]:
In [10]:
len(tbl1), len(tbl2)
Out[10]:
In [11]:
match_ids?
In [12]:
rows = match_ids(tbl2['THINGID'], tbl1['THINGID'])
In [13]:
for key in tbl2.keys():
if key == 'THINGID':
continue
#
print('adding column {:s}'.format(key))
new_clm = MaskedColumn(-999.*np.ones_like(tbl1['RAdeg']))
new_clm[rows] = tbl2[key]
# Mask it
msk = new_clm == -999.
new_clm.mask[msk] = True
# Add it
tbl1.add_column(new_clm, name=key)
In [14]:
tbl1[0:5]
Out[14]:
In [15]:
merged_file = resource_filename('dla_cnn', 'catalogs/boss_dr12/MNRAS/merged_g16.fits')
In [16]:
tbl1.write(merged_file)
In [ ]: