Skip to content

Commit

Permalink
Finish wireup of HIP1 and TYC2 supplement 1 data
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtribick committed Dec 20, 2021
1 parent 088cbe9 commit d1d29c0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 7 deletions.
4 changes: 2 additions & 2 deletions celestia_gaia/make_stardb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .spparse import CEL_UNKNOWN_STAR, parse_spectrum
from .utils import WorkaroundCDSReader, open_cds_tarfile

VERSION = "1.1.0-beta.1"
VERSION = "1.1.0"

# remove the following objects from the output

Expand Down Expand Up @@ -234,7 +234,7 @@ def merge_all() -> Table:
data['HIP'] < 1000000,
data['HIP'],
make_tyc(data['HIP']//1000000, (data['HIP']//10) % 100000, data['HIP']%10)
).astype('uint32')
).astype(np.uint32)

data['bp_rp'] = data['phot_bp_mean_mag'] - data['phot_rp_mean_mag']

Expand Down
44 changes: 40 additions & 4 deletions celestia_gaia/parse_hip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@

import warnings

import astropy.io.ascii as io_ascii
import astropy.units as u
import numpy as np
from astropy.coordinates import ICRS, SkyCoord
import astropy.io.ascii as io_ascii
from astropy.table import Table, join, unique
from astropy.table.column import MaskedColumn
from astropy.time import Time
import astropy.units as u

from erfa import ErfaWarning

from .directories import AUXFILES_DIR, VIZIER_DIR, XMATCH_DIR
import numpy as np

from .directories import AUXFILES_DIR, GAIA_EDR3_DIR, VIZIER_DIR, XMATCH_DIR
from .utils import open_cds_tarfile


Expand Down Expand Up @@ -64,6 +67,20 @@ def load_xhip() -> Table:
return join(hip_data, biblio_data, join_type='left', keys='HIP')


def load_hip1() -> Table:
"""Load data for HIP1 stars."""
print("Loading HIP1 data")
data = Table.read(GAIA_EDR3_DIR/'hip1_subset.vot.gz', format='votable')
data.remove_columns(['rahms', 'dedms', 'hpmag'])
data.rename_columns(
['hip', 'hd', 'vmag', 'b_v', 'e_b_v', 'v_i', 'e_v_i', 'sptype'],
['HIP', 'HD', 'Vmag', 'B-V', 'e_B-V', 'V-I', 'e_V-I', 'SpType'],
)
data['SpType'] = data['SpType'].astype(np.str)
data['SpType'].mask = data['SpType'] == ''
return data


def load_tyc2specnew() -> Table:
"""Load revised spectral types."""
print("Loading revised TYC2 spectral types")
Expand Down Expand Up @@ -167,6 +184,25 @@ def process_hip(data: Table) -> Table:
metadata_conflicts='silent',
)

data = join(
data,
load_hip1(),
keys=['HIP'],
join_type='left',
table_names=['gaia', 'hip1'],
)

for hip1_col in [c for c in data.colnames]:
if not hip1_col.endswith('_hip1'):
continue
base_col = hip1_col[:-5]
gaia_col = base_col + '_gaia'
data[base_col] = MaskedColumn(
data[gaia_col].filled(data[hip1_col]),
mask=np.logical_and(data[hip1_col].mask, data[gaia_col].mask)
)
data.remove_columns([hip1_col, gaia_col])

data = join(data, load_sao(), keys=['HIP'], join_type='left')

data['r_gaia_score'] = np.where(
Expand Down
45 changes: 44 additions & 1 deletion celestia_gaia/parse_tyc.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,28 @@ def load_ascc() -> Table:
return data


def load_tyc2_suppl1() -> Table:
"""Loads the Tycho-2 supplement 1 data."""
print('Loading TYC2 supplement 1')
reader = io_ascii.get_reader(
io_ascii.Cds,
readme=str(VIZIER_DIR/'tyc2.readme'),
include_names=['TYC1', 'TYC2', 'TYC3', 'BTmag', 'VTmag']
)
reader.data.table_name = 'suppl_1.dat'
with gzip.open(VIZIER_DIR/'tyc2suppl_1.dat.gz') as gzf:
data = reader.read(gzf)

parse_tyc_cols(data)
data = data[np.logical_not(np.logical_and(data['VTmag'].mask, data['BTmag'].mask))]
# Magnitude transformation formulae from Section 2.2 "Contents of the Tycho Catalogue"
data['BT-VT'] = data['BTmag'] - data['VTmag']
data['Vmag'] = data['VTmag'] - 0.090*data['BT-VT']
data['Bmag'] = data['Vmag'] + 0.850*data['BT-VT']
data.remove_columns(['BTmag', 'VTmag', 'BT-VT'])
return data


def load_tyc_hd() -> Table:
"""Load the Tycho-HD cross index."""
print('Loading TYC-HD cross index')
Expand Down Expand Up @@ -278,6 +300,7 @@ def process_tyc(data: Table) -> Table:
table_names=('gaia', 'tspec'),
metadata_conflicts='silent',
)

data = join(
data, load_ascc(),
keys=['HIP'],
Expand All @@ -300,12 +323,32 @@ def process_tyc(data: Table) -> Table:
data[base_col] = MaskedColumn(data[base_col].filled(data[ascc_col]), mask=mask)
data.remove_column(ascc_col)

data = join(
data, load_tyc2_suppl1(),
keys=['HIP'],
join_type='left',
table_names=['gaia', 'tyc2s1'],
metadata_conflicts='silent',
)

data['Vmag'] = MaskedColumn(
data['Vmag_gaia'].filled(data['Vmag_tyc2s1']),
mask=np.logical_and(data['Vmag_gaia'].mask, data['Vmag_tyc2s1'].mask),
)

data['Bmag'] = MaskedColumn(
data['Bmag_gaia'].filled(data['Bmag_tyc2s1']),
mask=np.logical_and(data['Bmag_gaia'].mask, data['Bmag_tyc2s1'].mask),
)

data.remove_columns(['Vmag_gaia', 'Vmag_tyc2s1', 'Bmag_gaia', 'Bmag_tyc2s1'])

data = join(
data, load_tyc_hd(),
keys=['HIP'],
join_type='left',
table_names=['gaia', 'hd'],
metadata_conflicts='silent'
metadata_conflicts='silent',
)
data['HD'] = MaskedColumn(data['HD_hd'].filled(data['HD_gaia'].filled(0)))
data['HD'].mask = data['HD'] == 0
Expand Down

0 comments on commit d1d29c0

Please sign in to comment.