Astroquery

This is the documentation for the Astroquery affiliated package of astropy.

Code and issue tracker are on GitHub.

Introduction

Astroquery is a set of tools for querying astronomical web forms and databases.

There are two other packages with complimentary functionality as Astroquery: pyvo is an Astropy affiliated package, and Simple-Cone-Search-Creator to generate a cone search service complying with the IVOA standard. They are more oriented to general virtual observatory discovery and queries, whereas Astroquery has web service specific interfaces.

Check out the A Gallery of Queries for some nice examples.

Installation

The latest version of astroquery can be conda installed while the latest and development versions can be pip installed or be downloaded directly from GitHub. On Linux systems the recommended way to install astroquery is to use the package management system to install the packages offered in the official repositories.

Using pip

$ pip install astroquery

and the ‘bleeding edge’ master version:

$ pip install https://github.com/astropy/astroquery/archive/master.zip

Using conda

It is also possible to install the latest astroquery with anaconda from the astropy channel:

$ conda install -c astropy astroquery

Archlinux

The current stable version of astroquery can be installed directly from the Arch User Repository python-astroquery package, while the latest version of the development branch in the git repository can be installed from the python-astroquery-git package.

Debian

Astroquery packages for python 2 and python 3 have been part of the Debian distribution since the release of Debian 9.0 (stretch). These packages can be installed using usual package maintenance tools like apt-get or aptitude.

Gentoo

An astroquery ebuild is available from the official Gentoo ebuild repository and can be installed with the Portage package manager.

Building from source

The development version can be obtained and installed from github:

$ # If you have a github account:
$ git clone git@github.com:astropy/astroquery.git
$ # If you do not:
$ git clone https://github.com/astropy/astroquery.git
$ cd astroquery
$ python setup.py install

Requirements

Astroquery works with Python 2.7 and 3.4 or later.

The following packages are required for astroquery installation & use:

and for running the tests:

The following packages are optional dependencies and are required for the full functionality of the alma module:

Using astroquery

All astroquery modules are supposed to follow the same API. In its simplest form, the API involves queries based on coordinates or object names. Some simple examples, using SIMBAD:

>>> from astroquery.simbad import Simbad
>>> result_table = Simbad.query_object("m1")
>>> result_table.pprint(show_unit=True)
MAIN_ID      RA         DEC     RA_PREC ... COO_QUAL COO_WAVELENGTH     COO_BIBCODE
          "h:m:s"     "d:m:s"           ...
------- ----------- ----------- ------- ... -------- -------------- -------------------
  M   1 05 34 31.94 +22 00 52.2       6 ...        C              R 2011A&A...533A..10L

All query tools allow coordinate-based queries:

>>> from astropy import coordinates
>>> import astropy.units as u
>>> # works only for ICRS coordinates:
>>> c = coordinates.SkyCoord("05h35m17.3s -05d23m28s", frame='icrs')
>>> r = 5 * u.arcminute
>>> result_table = Simbad.query_region(c, radius=r)
>>> result_table.pprint(show_unit=True, max_width=80, max_lines=5)
  MAIN_ID         RA          DEC      ... COO_WAVELENGTH     COO_BIBCODE
               "h:m:s"      "d:m:s"    ...
------------ ------------ ------------ ... -------------- -------------------
       M  42   05 35 17.3    -05 23 28 ...                1981MNRAS.194..693L
         ...          ...          ... ...            ...                 ...
V* V2114 Ori 05 35 01.671 -05 26 36.30 ...              I 2003yCat.2246....0C

For additional guidance and examples, read the documentation for the individual services below.

Available Services

If you’re new to Astroquery, a good place to start is the A Gallery of Queries:

The following modules have been completed using a common API:

These others are functional, but do not follow a common & consistent API:

Catalog, Archive, and Other

A second index of the services by the type of data they serve. Some services perform many tasks and are listed more than once.

Simulations

Simulation services query databases of simulated or synthetic data

Developer documentation

The modules and their maintainers are listed on the Maintainers wiki page.

The Astroquery API Specification is intended to be kept as consistent as possible, such that any web service can be used with a minimal learning curve imposed on the user.

The following Astroquery modules are mostly meant for internal use of services in Astroquery, you can use them for your scripts, but we don’t guarantee API stability.

License

Astroquery is licensed under a 3-clause BSD style license - see Licenses.