Astroquery is an Astropy-affiliated package that contains a collection of tools to access online Astronomical data. To install it, do:
pip install astroquery
The following modules have been completed using a common API:
astroquery.simbad)astroquery.vizier)astroquery.irsa_dust)astroquery.ned)astroquery.splatalogue)astroquery.ibe)astroquery.irsa)astroquery.ukidss)astroquery.magpis)astroquery.nrao)astroquery.besancon)astroquery.nist)astroquery.nvas)astroquery.gama)astroquery.eso)astroquery.xmatch)astroquery.atomic)astroquery.alma)astroquery.skyview)astroquery.nasa_ads)astroquery.heasarc)astroquery.lcogt)These others are functional, but do not follow a common & consistent API:
astroquery.fermi)astroquery.sdss)astroquery.alfalfa)astroquery.sha)astroquery.lamda)astroquery.ogle)astroquery.open_exoplanet_catalogue)astroquery.cosmosim)As an example, let's run a SIMBAD query:
from astropy import units as u
from astroquery.simbad import Simbad
r = Simbad.query_region('m42', radius=3. * u.arcmin)
r.colnames
r
In the following example we are looking for the SDSS photometry for a small subset of objects from the WTS survey and aim to have get a table that contains both the UKIRT JHK and SDSS griz values.
from astropy.table import Table, join
from astropy.coordinates import SkyCoord
from astroquery.sdss import SDSS
input_objects = Table.read('data/WTS_sources.txt', format='ascii')
input_objects
coords = SkyCoord(input_objects['RA'], input_objects['DEC'],
unit=u.rad)
photoobj_fields = ['ra', 'dec',
'psfMag_g', 'psfMagErr_g',
'psfMag_r', 'psfMagErr_r',
'psfMag_i', 'psfMagErr_i',
'psfMag_z', 'psfMagErr_z']
sdss_match = SDSS.query_crossid(coords, photoobj_fields=photoobj_fields,
obj_names=input_objects['obj_id'])
sdss_match
result = join(input_objects, sdss_match, keys='obj_id', join_type='left')
result
import matplotlib.pylab as plt
%matplotlib inline
plt.rc('figure', figsize=(10, 5))
plt.ylabel('J')
plt.xlabel('g-z')
plt.plot(result['psfMag_g']-result['psfMag_z'], result['J'], 'x')
Go to the documentation and try out a query interface for a service that might be relevant to you!