0. Setup

Please make sure your environment is set up according to the instructions here: https://github.com/NASA-NAVO/aas_workshop_2020_winter/blob/master/00_SETUP.md

Ensure you have the latest version of the workshop material by updating your environment: TBD

1. Overview

NASA services can be queried from Python in multiple ways.

2. VO Services

This workshop will introduce 4 types of VO queries:

2.1 Import Necessary Packages

2.1 Look Up Services in VO Registry

Simple example: Find Simple Cone Search (conesearch) services related to SWIFT.

2.1.1 Use different arguments/values to modify the simple example

Argument Description Examples
servicetype Type of service conesearch or scs for Simple Cone Search
image or sia for Simple Image Access
spectrum or ssa for Simple Spectral Access
table or tap for Table Access Protocol
keyword List of one or more keyword(s) to match service's metadata. Both ORs and ANDs may be specified.
  • (OR) A list of keywords match a service if **any** of the keywords match the service.
  • (AND) If a keyword contains multiple space-delimited words, **all** the words must match the metadata.
['galex', 'swift'] matches 'galex' or 'swift'
['hst survey'] matches services mentioning both 'hst' and 'survey'
waveband Resulting services have data in the specified waveband(s) ‘radio’, ‘millimeter’, ‘infrared’, ‘optical’, ‘uv’, ‘euv’, ‘x-ray’ ‘gamma-ray’

2.1.2 Inspect the results.

Using pyvo

Although not lists, pyvo results can be iterated over to see each individual result. The results are specialized based on the type of query, providing access to the important properties of the results. Some useful accessors with registry results are:

Filtering results

Of the services we found, which one(s) have 'stsci.edu' in their unique identifier?

Using astropy

With the to_table() method, pyvo results can also be converted to Astropy Table objects which offer a variety of addional features. See http://docs.astropy.org/en/stable/table/ for more on working with Astropy Tables.

Example: Find a cone search service for the USNO-B catalog and search it around M51 with a .1 degree radius. (More inspection could be done on the service list instead of blindly choosing the first service.)

The position (pos) is best specified with SkyCoord objects (see http://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html).

The size of the region is specified with the radius keyword and may be decimal degrees or an Astropy Angle (http://docs.astropy.org/en/stable/api/astropy.coordinates.Angle.html#astropy.coordinates.Angle).

Example: Find an image search service for GALEX, and search it around coordinates 13:37:00.950,-29:51:55.51 (M83) with a radius of .2 degrees. Download the first file in the results.

Find an image service

Search one of the services

The first service looks good. Search it!

For more details on using SkyCoord see http://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html#astropy.coordinates.SkyCoord

NOTE: For image searches, the size of the region is defined by the size keyword which is more like a diameter than a radius.

Download an image

For the first result, print the file format and download the file. If repeatedly executing this code, add cache=True to download_file() to prevent repeated downloads.

See download_file() documentation here: https://docs.astropy.org/en/stable/api/astropy.utils.data.download_file.html#astropy.utils.data.download_file

Example: Find a spectral service for x-ray data. Query it around Delta Ori with a search diameter of 10 arc minutes, and download the first data product. Note that the results table can be inspected for potentially useful columns.

Spectral search is very similar to image search. In this example, note:

Example: Find the HEASARC Table Access Protocol (TAP) service, get some information about the available tables.

Column Information

For any table, we can list the column names and descriptions.

Perform a Query

Example: Perform a cone search on the ZCAT catalog at M83 with a 1.0 degree radius.

3. Astroquery

Many archives have Astroquery modules for data access, including:

For more, see https://astroquery.readthedocs.io/en/latest/

3.1 NED

Example: Get an Astropy Table containing the objects from paper 2018ApJ...858...62K. For more on the API, see https://astroquery.readthedocs.io/en/latest/ned/ned.html