pythonastropyastroquerysimbad

Querying data from Simbad using astroquery


I'm making a script in Python to get information for all objects from the NGC and IC catalogs. Actually, I already have this information from OpenNGC, however, coordinates don't have the same precision, so I need to combine both dataframes.

What I want is: the name, RA in J2000, Dec in J2000 and the type. What I also would like, but it seems still more difficult: the constellation and the magnitude (flux B).

What I'm getting: a lot of repeated results. For example, for the cluster NGC 188 I got a lot of lines, one for every object into this cluster, with the individual magnitudes. So I removed the magnitudes (flux B) to get only the objects. I will insert the magnitudes manually, if it's necessary, from the OpenNGC.

This is my code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from astroquery.simbad import Simbad
from astropy.table import Table

# Get all the NGC/IC objects
def query_deep_sky_objects(catalog):
    adql_query = f"""
    SELECT TOP 10000 main_id, otype, ra, dec
    FROM basic
    WHERE main_id LIKE 'NGC%' OR main_id LIKE 'IC%'
    ORDER BY main_id ASC
    """
    result = Simbad.query_tap(adql_query)
    return result

objects = query_deep_sky_objects('NGC')
objects.write('simbad_objects.csv', format='csv', overwrite=True)

I'm very tired, since I've spent all day searching catalogs with precision enough. I also used an another catalog taken from Vizier ('VII/118/ngc2000') without the precision I need, like in Open NGC. I'm making a sky atlas for my publications. Without the required precision, DSO and stars appear out of their place.


Solution

  • You're almost there. You can change a bit the ADQL by joining the table ident that contains all identifiers (and not only the main one), so that you don't miss any sources. The fluxes are in the table flux.

    I remove the duplicates with DISTINCT.

    SELECT DISTINCT TOP 100 main_id, otype, ra, dec,
    flux, flux_err, filter, flux.bibcode as flux_origin_of_value
    FROM basic
    JOIN ident on oid = ident.oidref
    JOIN flux on oid = flux.oidref
    WHERE (id LIKE 'NGC%' OR id LIKE 'IC%') 
    AND filter = 'B'
    ORDER BY main_id ASC
    

    This gives me results like

             main_id         |otype|        ra        |        dec        | flux |flux_err|filter|flux_origin_of_value 
    -------------------------|-----|------------------|-------------------|------|--------|------|---------------------
    "*   4 Cas"              |"V*" |351.2094267145825 |62.28281016386695  |6.592 |0.015   |"B"   |"2000A&A...355L..27H"
    "*   7 Sgr"              |"*"  |270.71291093894   |-24.28246728687    |5.86  |        |"B"   |                     
    "*   9 Mon"              |"*"  |96.75365908689    |-4.355646374689999 |6.34  |0.015   |"B"   |"2000A&A...355L..27H"
    "*   9 Sgr"              |"Em*"|270.96852085459   |-24.36073118167    |5.97  |        |"B"   |"2002yCat.2237....0D"
    "*  10 Mon"              |"bC*"|96.98986680181083 |-4.7621476108591665|4.861 |0.014   |"B"   |"2000A&A...355L..27H"
    "*  12 CMa"              |"a2*"|101.75618136296002|-21.01540324902    |5.89  |        |"B"   |"2002yCat.2237....0D"
    "*  12 Mon"              |"V*" |98.08001622857    |4.85599827378      |6.82  |0.007   |"B"   |"1993A&AS..100..591O"
    "*  15 Mon"              |"Be*"|100.24441512044264|9.895756366805493  |4.45  |0.01    |"B"   |"2002A&A...384..180F"
    "*  18 Vul"              |"SB*"|302.63973830658   |26.90416796478     |5.586 |0.014   |"B"   |"2000A&A...355L..27H"
    "*  19 Vul"              |"*"  |302.94989153336996|26.808991088130004 |6.879 |0.015   |"B"   |"2000A&A...355L..27H"
    "*  20 Vul"              |"Be*"|303.00292297134   |26.47880660233     |5.81  |        |"B"   |"2002yCat.2237....0D"
    "*  61 And"              |"s*b"|34.76855215623    |57.13549863046     |7.0   |        |"B"   |"2002yCat.2237....0D"
    "* 103 Tau"              |"SB*"|77.02759314779    |24.265174608780004 |5.56  |        |"B"   |"2002yCat.2237....0D"
    "* b Per"                |"SB*"|64.56092274545583 |50.295493065878055 |4.639 |0.014   |"B"   |"2000A&A...355L..27H"
    "* c Pup"                |"*"  |116.31373389138793|-37.968585259939175|5.34  |        |"B"   |"2002yCat.2237....0D"
    "* d01 Pup"              |"*"  |114.86391100082002|-38.30802345296194 |4.65  |        |"B"   |"2002yCat.2237....0D"
    "* d02 Pup"              |"Pu*"|114.93256487363001|-38.1392981022     |5.62  |0.01    |"B"   |"2002A&A...384..180F"
    "* d03 Pup"              |"Pu*"|114.94947883364   |-38.26065232835    |5.667 |0.014   |"B"   |"2000A&A...355L..27H"
    "* d04 Pup"              |"Be*"|114.99162956189   |-37.579424278110004|5.944 |0.014   |"B"   |"2000A&A...355L..27H"
    "* iot Ori"              |"SB*"|83.85827580502625 |-5.909888523506666 |2.53  |        |"B"   |"2002yCat.2237....0D"
    "* kap Cru"              |"SB*"|193.45383256528   |-60.37624162151    |6.12  |0.01    |"B"   |"2000A&A...355L..27H"
    "* mu. Nor"              |"s*b"|248.52091401572375|-44.04531127887388 |4.99  |        |"B"   |"2002yCat.2237....0D"
    "* omi Vel"              |"Pu*"|130.0733305508675 |-52.921909895522504|3.44  |        |"B"   |                     
    "* phi Cas"              |"s*y"|20.020485277440002|58.23161323440999  |5.66  |        |"B"   |"2002yCat.2237....0D"
    "* tau CMa"              |"SB*"|109.67702081318917|-24.954361319371664|4.25  |        |"B"   |"2002yCat.2237....0D"
    "* tet Car"              |"SB*"|160.73917486416664|-64.39445022111111 |2.54  |        |"B"   |"2002yCat.2237....0D"
    "* tet02 Ori A"          |"SB*"|83.84542183261    |-5.416064620030001 |6.3   |        |"B"   |"2002yCat.2237....0D"
    "* zet01 Sco"            |"s*b"|253.49886304786997|-42.36202981513001 |5.31  |        |"B"   |"2002yCat.2237....0D"
    "2MASS J00225403-7205169"|"AB*"|5.725253264990001 |-72.08804841359    |13.802|0.003   |"B"   |"2017A&A...607A.135W"
    "2MASS J00240156+6119328"|"RG*"|6.00651816708     |61.32580282815999  |14.68 |        |"B"   |                     
    "2MASS J00244007+6123511"|"RG*"|6.16707844506     |61.39751148121     |12.79 |        |"B"   |                     
    "2MASS J00254390-7206508"|"LP*"|6.43312095062     |-72.11409712722    |13.43 |        |"B"   |                     
    "2MASS J00294512+6011508"|"NIR"|7.438073724230001 |60.19745324021001  |15.37 |        |"B"   |"1961PUSNO..17..343H"