Searching for and retrieving images

In this notebook, we show how to search for and retrieve images from VO services using the Registry and the Simple Image Access (SIA) protocol.

  1. Finding SIA resources from the Registry
  2. Using SIA to retrieve an image
  3. Viewing the resulting image
  4. Example with multiple data services

*Note: for all of these notebooks, the results depend on real-time queries. Sometimes there are problems, either because a given service has changed, is undergoing maintenance, or the internet connectivity is having problems, etc. Always retry a couple of times, come back later and try again, and only then send us the problem report to investigate.

1. Finding SIA resources from the Registry

First, how do we find out what services are available? These are listed in a registry at STScI (see here). Our Registry function gives a simple interface for how to search for services.

Let's search for services providing images in the ultraviolet bands:

This returns an astropy table containing information about the services available. We can then specify the service we want by using the corresponding row. We'll repeat the search with additional qualifiers to isolate the row we want (note that in the keyword search the "%" character can be used as a wild card):

This shows us that the data we are interested in comes from the HEASARC's SkyView service, but the point of these VO tools is that you don't need to know that ahead of time or indeed to care where it comes from.

2. Using SIA to retrieve an image:

Now we look for images of our favorite source. See the SIA definition for usage. In short, you can specify the central position and the size (degrees as one or two floats for the RA, DEC directions). It is up to the service to determine how to provide this. Optionally, you can limit it to the format you want, e.g., "image/fits" or "image/png" etc.

What is returned to you is not the image itself but a list of images available and how to access them. This is easiest shown by example:

Extract the fields you're interested in, e.g., the URLs of the images made by skyview. Note that specifying as we did SwiftUVOT, we get a number of different images, e.g., UVOT U, V, B, W1, W2, etc. For each survey, there are two URLs, first the FITS IMAGE and second the JPEG.

Note that different services will return different column names, but all will have a column giving the URL to access the image. Though it has different column names in different services, it can always be accessed through the getdataurl function.

3. Viewing the resulting image

JPG images

Since we have asked for JPEG images, we can display an image in python easily by using its URL. Each row of the result has a getdataurl() method, and you can then hand the URL to an image displayer such as IPython.display:

Fits files

Or download the FITS image and display it with imshow, or aplpy.

(This often errors off with a time out message. Just try it again, possibly a couple of times.)

Using imshow

Using aplpy

This package knows how to read the header keywords in WCS to display the correct coordinate axes.

4. Example of data available through multiple services

Suppose we want Sloan DSS data. A generic query finds us a number of possibilities (note that this doesn't work for keywords=['sdss']; be flexible and try several search terms):

So one of these is served by SDSS's SkyServer and the other by HEASARC's SkyView.

Using HEASARC

Using SDSS SkyServer

It turns out that SkyView is just getting images by using the SIAP internally to get the data from the SDSS service. The point of the VO protocols is that you don't need to know where the data are coming from. But they can be processed differently.