Astroquery provides a uniform interface to query astronomical web services and archives, making it easier to access online astronomical data resources. It is part of the Astropy Project and integrates seamlessly with Astropy's data structures. The current version is 0.4.11, and it maintains an active development cycle with frequent releases to add new services and fix issues.
pip install astroqueryVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to query the Simbad database for an object by name and perform a cone search around specific coordinates. It shows basic data retrieval and interaction with Astropy's units and coordinates.
Use the respective service's login method, e.g., `Mast.login(token=os.environ.get('MAST_API_TOKEN'))` or `Gaia.login()`, before making queries. Tokens are often preferred for scripting.Use parameters like `max_results`, `top`, `limit`, or specific coordinate/time range filters where available. Preview query results (e.g., by checking the size of a preliminary query) before downloading the full data.
Ensure that any table names passed to `TapPlus.upload_table` do not contain a period. Replace dots with underscores or remove them.
Always check the units of table columns (e.g., `table['column_name'].unit`) and use `astropy.units` for any subsequent calculations or conversions to ensure dimensional consistency. Convert to plain numerical values only when needed and safe to do so.
Ensure `astroquery` is installed (`pip install astroquery`). Verify the exact module name for the service you are trying to use (e.g., `astroquery.simbad`, `astroquery.mast`).
Authenticate with the respective service using its `login()` method (e.g., `Mast.login(token='YOUR_API_TOKEN')`). Check documentation for required authentication methods for the specific service.
Review your query parameters (object name, coordinates, radius, filters, etc.) for typos or logical errors. Try a broader query first, then narrow it down. Check the service's own web interface to confirm data existence.
Access rows and columns using square bracket indexing: `table[0]` for the first row, `table['column_name']` for a column. For specific cells, use `table['column_name'][0]`.