This is another in Astrobites’ series of articles aiming to introduce important tools used by astronomers in their everyday work. Earlier Ian tackled the databases of astronomy, and today I’ll introduce SAO ds9, the terrific image viewer application for the FITS data format that is ubiquitous in astronomy.
ds9 (whose name really does derive from Star Trek) can be used for everything from simply inspecting images to making publication-quality figures. In fact, it has so many features that I can only hope to mention a small fraction of them here. For more information, consult the excellent and thorough ds9 user manual.
If you have a favorite ds9 feature that I left out, be sure to leave a comment below!
Getting ds9 is simple: it requires no installation, you just need to download the binary appropriate for your operating system. It’s distributed for Linux, Mac OS X, or Windows.
Basic use: opening and navigating an image
First we’re just going to experiment with the basics of using ds9. These are simple tasks that astronomers use constantly to visually inspect images.
As a sample image, we’ll use the Sloan Digital Sky Survey‘s (SDSS) g-band image of the Sombrero galaxy (M104), which you can download here. Download this FITS image and open it via the File > Open menu item in ds9. You can go to File > Display FITS Header to learn everything you could ever want to know about how this SDSS image was made.
When you first open the image, you’ll be greeted by an almost totally black screen. This is because ds9 will by default show you the full range of the image – from the brightest to the dimmest point – all on a simple linear scale. Since the sky is mostly dark, almost every pixel will essentially be black. You’ll probably want to change the “lookup table” to something which will better show you the dynamic range of the image. You can do this using the Scale > ZScale menu option.
You can go to Scale > Scale Parameters… to see a histogram that will show you the exact brightness profile of the image. This histogram also allows you to constrict the display range so you can, for example, see the bright center of the Sombrero galaxy. Additionally, you can play with the colorbar by holding down the right mouse button and dragging the cursor.
You can tell that ds9 is only showing you a small portion of the image by the rectangle drawn in the finder window in the upper right corner of the screen. By default, it displays the image on a 1:1 pixel scale. If you want to see the whole image, go to Zoom > Zoom to Fit Frame. By the way, you can access all of the most common menu options like ZScale and Zoom to Fit from the “buttonbar,” which is the double row of buttons right above where the image is displayed.
To practice moving around an image, zoom back in by selecting Zoom > Zoom 1. You can recenter on any pixel in the image by clicking on it with the middle mouse button (either in the lower display pane or the small finder window above). Notice that when you mouseover any region in the image, a zoomed-in preview will be displayed in the upper-right corner of the screen.
When you move your cursor around, also notice that the current RA/DEC position of your cursor is displayed in the text boxes in the upper-left corner. Note that ds9 can only calculate these coordinates if your FITS image has a World Coordinate System (WCS) specified, as all the SDSS images do. In either case, ds9 will also display the pixel (x,y) coordinates.
Opening multiple images
Next let’s try opening multiple images at once. If the images all have WCS data, then we can match them up and compare them directly. There are all sorts of reasons you might want to do this: for example to compare images taken with different telescopes, at different times, or at different wavelengths (filters).
With your g-band image still open, download the SDSS u-band image of the Sombrero galaxy. Now go to Frame > New Frame. You can think of a frame in ds9 like a tab in a web browser – it’s just a container to open images in. With the new frame open, go to File > Open to open the u-band image you downloaded.
Navigate to a bright source in one of the two images you have open. Now match up the position of the two frames by clicking Frame > Match Frames > WCS. Now you can flip to the other image by typing Tab or going to Frame > Next Frame and you will be able to compare the same spot on the two images. If you need to, you can also match up the scale and colorbar of the two frames from the Frame menu. Alternatively, you could go to Frame > Tile Frames to see the images side by side or Frame > Blink Frames to rotate through them.
You should notice that the sources that are bright in the g-band image are dimmer in the u-band and that many faint sources are totally undetectable in the u-band. This is due to a combination of factors that conspire to make astronomical sources dim in the UV, which the u-band is just on the edge of, including atmospheric opacity, the sensitivity of CCDs, and the effective temperature of different sources.
If you download one more image, the r-band image, you can make a color mosaic! Go to Frame > New Frame RGB. A new frame should open, along with a popup window titled “RGB.” You use this window to essentially access the three subframes (R, G, and B) within this color frame. First click on the “Red” option in the popup and use File > Open to open the r-band image. Then click on “Green” and open the g-band, and then “Blue” and open the u-band. You’ll have to play with the colormap in each color frame to make something as pretty as the SDSS mosaic.
Basic data analysis & Regions
ds9 is chock full of advanced tools that you can use to analyze your data. I’ll just mention a few of my favorites here.
While you have your color mosaic up, let’s check the SDSS optical data against an infrared catalog. You would only expect the sources that are bright and red to show up in the infrared data. To automatically load the catalog of sources near the Sombrero galaxy from the Two Micron All Sky Survey (2MASS), go to Analysis > Catalogs > Infrared > 2MASS Point Sources. ds9 will automatically draw circles around all the infrared sources in your image and also open a table listing them. Click on an object in the table to pan over to it on the image. You could even download the actual image from 2MASS by going to Analysis > Image Servers > IPAC-2MASS
The circles ds9 has drawn are called “regions” and are a very powerful plotting tool. Draw your own regions by selecting the pointer tool from Edit > Pointer and then simply clicking and dragging over the image. You can go to Region > Shape to pick a different type of region. Region types include a variety of simple shapes, vectors (arrows), and text (so you can write labels).
One of the most useful region types is the “Projection.” Try it out by selecting it from Region > Shape > Projection and then clicking and dragging across a bright source. A new window will open displaying the brightness profile of the image along the line you drew. This is invaluable for taking a quick look at the point spread function of a star, the profile of a galaxy, or a spectrum of dispersed light that was recorded on a CCD chip.
Command line switches and scripting
All of the functions described above are extremely useful for interactively examining data, but it’s also possible to automate (script) actions in ds9. The simplest way is to pass command line options to ds9 when you first load it. You can also use the XPA messaging system (or its python interface) to pass commands to an open instance of ds9.
ds9 is primarily developed by the amazing Bill Joye here at the Harvard-Smithsonian Center for Astrophysics. The source code for ds9 is freely available.
Latest posts by Nathan Sanders (see all)
- Has IBEX detected eddies in the spacetime continuum? – October 28, 2013
- Interactive astronomy software produced by graduate students – August 9, 2013
- Announcing Astroplots! – August 9, 2013