DataLink

DataLink is an International Virtual Observatory Alliance (IVOA) protocol for finding links associated with an identifier. At Gaia@AIP, these links can point to files, previews, or information about a source, table, or release. The DataLink Viewer displays the links in a browser. TOPCAT and PyVO can look them up through the DataLink service.

Crowded-field images

The Gaia DR4 table gaiadr4.crowded_field_image_summary describes the crowded-field images. Include image_id in your query result so you can use DataLink to find the FITS files for the selected images. Each FITS file contains two tables and one image.

Query interface

  1. In the Query interface, run a query on gaiadr4.crowded_field_image_summary that returns image_id.
  2. Open the Results table tab and click the image_id link for the image you want.
  3. The DataLink Viewer shows a single entry for the image, with a description, content type, and file size. Click the link under Access URL to download the FITS file.

TOPCAT

  1. In the TOPCAT main window, choose VO → TAP Query. Select Gaia@AIP TAP Service from the list of registered services or enter https://gaia.aip.de/tap in TAP URL. Click Use Service, enter a query on gaiadr4.crowded_field_image_summary that returns image_id, then click Run Query. TOPCAT TAP service selection
  2. Select the result table in the main window's Table List and click the lightning-bolt button to open Activation Actions. TOPCAT Activation Window guide
  3. Select Invoke Service and make sure its checkbox is ticked. In the Action menu, select View DataLink Table. TOPCAT uses the service information attached to the TAP result to look up links for each image. TOPCAT Invoke Service guide
  4. From the main window, use Table Data to display the result. Click the row for the image you want. TOPCAT opens the Invoke Service – View Datalink Table window for that image. TOPCAT Data Window guide
  5. Select the FITS entry in the DataLink table. Its Access URL appears under Row Detail. Choose an Action and click Invoke.

Load Tables, shown in the screenshot, loads the two tables into TOPCAT. View FITS image internally gives a quick preview of the image. Download URL saves the complete FITS file for viewing or plotting in another tool. TOPCAT DataLink Window guide

Tip for DS9. With DS9 open and connected to the same SAMP hub as TOPCAT, choose Send FITS Image in the DataLink window and click Invoke. The image opens in DS9, where you can adjust the intensity scale to bring out faint detail. TOPCAT Send FITS Image guide

Scripted access with PyVO

This example queries up to five rows from the image summary table. PyVO follows the DataLink service information attached to the TAP result. For each image, the #this entry gives the FITS file URL in access_url. The example downloads the linked files to the current directory. Replace <your token> with your Gaia@AIP API token. See Scripted access for how to find your API token.

import pyvo
import requests

url = "https://gaia.aip.de/tap"
token = 'Token <your token>'

# Setup authorization
tap_session = requests.Session()
tap_session.headers['Authorization'] = token
tap_service = pyvo.dal.TAPService(url, session=tap_session)

query = """
select top 5 * from gaiadr4.crowded_field_image_summary
"""

tap_job = tap_service.submit_job(query)
tap_job.run()
tap_job.wait()
tap_job.raise_if_error()
results = tap_job.fetch_result()

def download_file(dl, session):
    filename = dl.access_url.rsplit("/", 1)[-1]
    with session.get(dl.access_url, stream=True) as r:
        r.raise_for_status()
        with open(filename, "wb") as f:
            for chunk in r.iter_content(1024 * 1024):
                f.write(chunk)

for datalinks in results.iter_datalinks(preserve_order=True):
    for dl in datalinks.bysemantics("#this"):
        download_file(dl, tap_session)