PyVO

1.8.1 · active · verified Thu Apr 16

PyVO is an Astropy affiliated package that provides a Python interface to access data and services from the Virtual Observatory (VO). It allows users to query astronomical catalogs, image archives, and spectral data through standard VO protocols like TAP, SIA, and SSA. The current version is 1.8.1, and it maintains an active release cadence with regular updates and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to search the Virtual Observatory registry for services and then execute a simple ADQL query against a public TAP (Table Access Protocol) service using PyVO. Results are returned as Astropy Table objects, integrating well with the broader Astropy ecosystem.

import pyvo
import os

# 1. Search the VO registry for services
# Example: Find services related to galaxies and spectroscopy
print("Searching the VO registry...")
results = pyvo.registry.search(keywords=['galaxy', 'spectroscopy'])
print(f"Found {len(results)} services matching 'galaxy' and 'spectroscopy'.")

# 2. Access a TAP service (Table Access Protocol)
# For a stable quickstart, we'll use a widely known public TAP service.
# Note: Service availability can change. This is an example.
tap_service_url = os.environ.get('PYVO_TAP_SERVICE_URL', 'https://tap.voservices.net/tap')
tap_service = pyvo.dal.TAPService(tap_service_url)
print(f"\nAttempting to connect to TAP service: {tap_service.url}")

# 3. Execute an ADQL (Astronomical Data Query Language) query
# Example: Query the ivoa.ObsCore table for Gaia data
query = "SELECT TOP 5 ra, dec, dataproduct_type FROM ivoa.ObsCore WHERE obs_collection LIKE '%Gaia%'"
try:
    tap_results = tap_service.search(query)
    print(f"\nTAP query returned {len(tap_results)} results.")
    # Results are returned as an Astropy Table object (pyvo.dal.TableSet)
    print("\nFirst 5 results (Astropy Table):")
    print(tap_results.to_table())
except Exception as e:
    print(f"\nError during TAP query: {e}")
    print("The TAP service might be temporarily unavailable or the query invalid.")

view raw JSON →