Astronomical Data Comparison Script

This Python script is designed for comparing astronomical target lists retrieved from the SIMBAD database. It uses the astroquery package to fetch identifiers for celestial objects from two different datasets, compares these datasets to find shared targets, and outputs the common identifiers. It involves data manipulation and analysis with pandas and numpy, demonstrating the process of concatenation, alias retrieval, and intersection identification among astronomical datasets.

#!/home/tboudreaux/anaconda3/envs/astro/bin/python
 
from astroquery.simbad import Simbad
import pandas as pd
import numpy as np
 
names = ['#', 'typed ident', 'identifier', 'typ', 'coord1 (ICRS,J2000/2000)', 'Mag U', 'Mag B', 'Mag V', "Mag R", "Mag I", "spec. type", "#bib", "not"]
PreviouslyReduced = pd.read_csv('PreviuosTargetListSimbad.tsv', sep='\t', skiprows=7, skipfooter=9, names=names, engine='python')
ThisDataSet = pd.read_csv('TargetListSimbad.tsv', sep='\t', skiprows=7, skipfooter=6, names=names, engine='python')
 
 
AllIdentifiers = pd.concat([PreviouslyReduced.identifier, ThisDataSet.identifier])
 
def getAllAlias(idents):
    DS = list()
    for ident in idents:
        aliases = np.array(Simbad.query_objectids(ident)).astype('U28')
        print(aliases)
        print(f"{ident}: {len(aliases)} alias found")
        DS.append(aliases)
 
    return DS
 
DS1 = getAllAlias(PreviouslyReduced.identifier)
DS2 = getAllAlias(ThisDataSet.identifier)
 
DS1_flat = np.concatenate(DS1)
DS2_flat = np.concatenate(DS2)
 
intersection = np.intersect1d(DS1_flat, DS2_flat)
idents = list()
for intersect_target in intersection:
    for ident, obs_target in zip(ThisDataSet.identifier, DS2):
        if intersect_target in obs_target:
            if ident not in idents:
                idents.append(ident)
 
 
print('Shared Targets\n==============')
for ident in idents:
    print(ident)