Using IRSA TAP services from Python

The recommended package for querying IRSA TAP services from Python is pyvo. Version 1.1 of pyvo must be used. It is installable with the "pip command".

    
pip install -U pyvo
    

Here is a sample query of the 2MASS Point Source Catalog ("fp_psc") using pyvo and the IRSA TAP service.

    
import pyvo
service = pyvo.dal.TAPService('https://irsa.ipac.caltech.edu/TAP')
result = service.run_async("""
           SELECT ra,dec,j_m,j_msigcom,h_m,h_msigcom,k_m,k_msigcom,ph_qual,cc_flg
           FROM fp_psc
           WHERE CONTAINS(POINT('ICRS',ra, dec), CIRCLE('ICRS',202.48417,47.23056,0.4))=1
    """)
tab = result.to_table()
   

The variable "tab" will be an Astropy Table object.

Additional examples using pyvo have been produced by the NASA Archive Virtual Observatory (NAVO) group, of which IRSA is a contributing member. The NAVO group has produced rendered notebooks and a repository with all the source files from our workshops.

The astroquery package contains a Tap class in astroquery.utils.tap, but this TAP client is being deprecated and it does not work correctly with IRSA's TAP service. In the near future, the astroquery package will use pyvo for TAP queries as well as for other VO queries.