How to use SAO ds9 to examine astronomical images

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

SAO ds9 dispalying the SDSS g-band image of the Sombrero Galaxy, zoomed to fit and displayed with ZScale.

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.

Using ds9's scale parameters to constrain the display range of the image to highlight the bright center of the Sombrero galaxy.

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

Playing with the colormap parameters of a color mosaic of the Sombrero galaxy with ds9.

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

Loading the catalog of 2MASS point sources near the Sombrero galaxy (green circles and table on right) and examining the radial profile of the Sombrero's disk and bulge (below).

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.

Of course, some of ds9’s most powerful and frequently-used functionality comes from its capacity as a display server for IRAF. ds9 can also interact with the table management software TOPCAT.

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.

About Nathan Sanders

I am one of the members of the team that founded Astrobites in 2010 and a co-founder of ComSciCon, the Communicating Science Workshop for graduate students. I earned my Ph.D. in astronomy at Harvard University in 2014, focusing on observations of supernovae and their host galaxies; investigating how massive stars explode and enrich the interstellar medium. I did my undergraduate work at Michigan State University.

Discover more from astrobites

Subscribe to get the latest posts to your email.


  1. Just wanted to add that ds9 is used by loads of observational astronomers all over the world and despite a somewhat old fashioned look it is a very popular program. It is well worth an astronomers time time to get to grips with it.

  2. GAIA is great for making finding charts and identifying what the magnitude of the stars in your image are. I have not used GAIA and IRAF together, but I assumes that should not be much of a problem.

  3. I believe that many of the catalog/image interfaces in ds9=>Analysis use VO technologies as their backend.

    unlike other former Starlink packages like TOPCAT (catalogs) and SPLAT (spectra), GAIA makes you swallow the entire Starlink pill.

  4. You might also be interested in:
    It’s a lightweight wrapper to pyds9, which adds some ready made python wrappers to common actions such as pan, zoom, scale, etc. I also use a bit of python trickery so you can write these functions for a single frame, then automatically apply them to all frames if you so desire. It’s a work in progress rather than a polished product, but it should be easy for anyone with a little python / ds9 knowledge to get stuck in. Collaborators welcome!

  5. i need to know the x and y what are they means spectra ????

  6. I need to assign coordinates using ds9, I just started using it yesterday and I’m feeling lost. Can anyone help?

  7. Many of the links in this article no longer work, like the download links of the u and g bands of M104. Could someone update this excellent article on SAO DS9? Thanks!

    • Thanks for pointing this out! We will look into the issue, and update it ASAP.

  8. So how can i detect these one? I`m ready to investigate space marines, but, fortunately, i can`t see nearly as far

  9. is it somehow possible to show an fits image median/mean/min/max values with ds9?

  10. All the packages mentioned in the article are part of the Debian Astro Pure Blend and may be directly installed in Debian, Ubuntu, Mint and similar distributions: saods9, python(3)-pyds9, xpa-tools, iraf.

  11. How can I use DS9 to measure the FWHM of a star image?

  12. do the download links work no longer or is it just me ?

  13. I use the xpa tools with ds9 on a daily bases. It makes ds9 incredibly powerful, as good as ds9 already is. It has a slight weakness in 3D fits cubes, those it can do orthogonal views. For those who want to play with a really cool view of interactive 3D fits, look at glnemo2 (google it). It has some ideas borrowed from ds9. The author has some youtubes explaining advanced features.



  1. Installing and Running Gadget-2 « astrobites - [...] astrobite will be another in a series on career advice and useful astronomical tools.  So far, it looks like…
  2. Astronomy software developer Bill Joye on ds9 7.0 | astrobites - [...] the new ds9 release. If you’re not familiar with the software, you may want to first read the tutorial…
  3. AstroImageJ: A Simple and Powerful Tool for Astronomical Image Analysis and Precise Photometry | astrobites - […] AIJ is built on Java, and runs easily on multiple platforms (e.g., Macs, Windows, and Linux). AIJ does everything…
  4. Astrobites: A Look back at 2016! | astrobites - […] How to use SAO ds9 to examine astronomical images, by Nathan […]

Leave a Reply