def load_xhip() -> Table: """Load the XHIP catalogue from the VizieR archive.""" print('Loading XHIP') with open_cds_tarfile(os.path.join('vizier', 'xhip.tar.gz')) as tf: print(' Loading main catalog') hip_data = tf.read_gzip('main.dat', [ 'HIP', 'Comp', 'RAdeg', 'DEdeg', 'Plx', 'pmRA', 'pmDE', 'e_Plx', 'Dist', 'e_Dist', 'SpType', 'RV' ], fill_values=[('', '-1', 'Tc', 'Lc'), ('', 'NaN', 'phi')]) hip_data.add_index('HIP') print(' Loading photometric data') photo_data = tf.read_gzip('photo.dat', [ 'HIP', 'Vmag', 'Jmag', 'Hmag', 'Kmag', 'e_Jmag', 'e_Hmag', 'e_Kmag', 'B-V', 'V-I', 'e_B-V', 'e_V-I' ]) photo_data[ 'HIP'].unit = None # for some reason it is set to parsecs in the ReadMe photo_data.add_index('HIP') hip_data = join(hip_data, photo_data, join_type='left', keys='HIP') print(' Loading bibliographic data') biblio_data = tf.read_gzip('biblio.dat', ['HIP', 'HD']) biblio_data.add_index('HIP') return join(hip_data, biblio_data, join_type='left', keys='HIP')
def load_tyc_spec() -> Table: """Load the TYC2 spectral type catalogue.""" print('Loading TYC2 spectral types') with open_cds_tarfile(os.path.join('vizier', 'tyc2spec.tar.gz')) as tf: data = tf.read_gzip('catalog.dat', ['TYC1', 'TYC2', 'TYC3', 'SpType']) parse_tyc_cols(data) data.add_index('TYC') return data
def _load_ascc_tyc_ids(filename: str) -> Table: data = None with open_cds_tarfile(filename) as tf: for data_file in tf.tf: sections = os.path.split(data_file.name) if len(sections) != 2 or sections[0] != '.' or not sections[1].startswith('cc'): continue section_data = tf.read_gzip( os.path.splitext(sections[1])[0], ['TYC1', 'TYC2', 'TYC3'], readme_name='cc*.dat') if data is None: data = section_data else: data = vstack([data, section_data], join_type='exact') return data
def load_tyc_hd() -> Table: """Load the Tycho-HD cross index.""" print('Loading TYC-HD cross index') with open_cds_tarfile(os.path.join('vizier', 'tyc2hd.tar.gz')) as tf: data = tf.read_gzip('tyc2_hd.dat', ['TYC1', 'TYC2', 'TYC3', 'HD']) parse_tyc_cols(data) err_del = np.array(TYC_HD_ERRATA['delete'] + [a[1] for a in TYC_HD_ERRATA['add']]) data = data[np.logical_not(np.isin(data['HD'], err_del))] err_add = Table(np.array(TYC_HD_ERRATA['add']), names=['TYC', 'HD'], dtype=[np.int64, np.int64]) data = vstack([data, err_add], join_type='exact') data = unique(data.group_by('HD'), keys='TYC') data = unique(data.group_by('TYC'), keys='HD') return data
def load_ascc() -> Table: """Load ASCC from VizieR archive.""" print('Loading ASCC') with open_cds_tarfile(os.path.join('vizier', 'ascc.tar.gz')) as tf: data = None for data_file in tf.tf: sections = os.path.split(data_file.name) if (len(sections) != 2 or sections[0] != '.' or not sections[1].startswith('cc')): continue section_data = _load_ascc_section(tf, os.path.splitext(sections[1])[0]) if data is None: data = section_data else: data = vstack([data, section_data], join_type='exact') data = unique(data.group_by(['TYC', 'd3']), keys=['TYC']) data.rename_column('d3', 'Comp') data.add_index('TYC') return data
def download_gaia_hip(username: str) -> None: """Download HIP data from the Gaia archive.""" hip_file = os.path.join('gaia', 'gaiadr2_hip-result.csv') if not proceed_checkfile(hip_file): return conesearch_file = os.path.join('gaia', 'hip2conesearch.zip') if proceed_checkfile(conesearch_file): download_file(conesearch_file, CONESEARCH_URL) # the gaiadr2.hipparcos2_best_neighbour table misses a large number of HIP stars that are # actually present, so use the mapping from Kervella et al. (2019) "Binarity of Hipparcos # stars from Gaia pm anomaly" instead. with open_cds_tarfile(os.path.join('vizier', 'hipgpma.tar.gz')) as tf: hip_map = unique(tf.read_gzip('hipgpma.dat', ['HIP', 'GDR2'])) with ZipFile(conesearch_file, 'r') as csz: with csz.open('Hipparcos2GaiaDR2coneSearch.csv', 'r') as f: cone_map = io_ascii.read(f, format='csv', names=['HIP', 'GDR2', 'dist'], include_names=['HIP', 'GDR2']) cone_map = unique(cone_map) hip_map = join(hip_map, cone_map, join_type='outer', keys='HIP', table_names=['pm', 'cone']) hip_map['GDR2'] = hip_map['GDR2_pm'].filled(hip_map['GDR2_cone']) hip_map.remove_columns(['GDR2_pm', 'GDR2_cone']) hip_map.rename_column('HIP', 'original_ext_source_id') hip_map.rename_column('GDR2', 'source_id') Gaia.upload_table(upload_resource=hip_map, table_name='hipgpma') try: download_gaia_data('hip_id', f'user_{username}.hipgpma', hip_file) finally: Gaia.delete_user_table('hipgpma')
def load_tyc2specnew() -> Table: """Load revised spectral types.""" print("Loading revised TYC2 spectral types") with open_cds_tarfile(os.path.join('vizier', 'tyc2specnew.tar.gz')) as tf: data = tf.read('table2.dat', ['HIP', 'SpType1']) return data[data['SpType1'] != '']
def load_ubvri() -> Table: """Load UBVRI Teff calibration from VizieR archive.""" print('Loading UBVRI calibration') with open_cds_tarfile(os.path.join('vizier', 'ubvriteff.tar.gz')) as tf: return tf.read_gzip('table3.dat', ['V-K', 'B-V', 'V-I', 'J-K', 'H-K', 'Teff'])