DS9 Tips and Tricks
If you're not familiar with SAOIMAGE DS9, check out its homepage. It is a FITS imaging program with significant capabilities.
However, its manual is not 100% clear. There are a lot of capabilities that are not immediately obvious.
I've also written a guide on using DS9 with IRAF's imalign and imcentroid
(all below are links)
Projection (quick look spectroscopy)
The most interesting overlooked capability is the projection region. It can be accessed through the Regions: Shape menu.
It is extremely useful for quick-look spectroscopy.
You can also find out what the size and shape of a region are using Get Information
Ruler / Distance Measurements
The ruler is another useful tool, particularly during an observing run when you need to find out quickly how to slew the telescope (e.g. if you're using a coronagraph and the image is at some angle to the plane of the sky)
With the ruler, we can measure positions using get information again.
If your image has WCS coordinates defined, it becomes extremely easy to find out exactly what your slew needs to be.
DS9 can also be used to open multi-extension FITS files that IRAF may have trouble with. They will not load as data cubes by default, though: you must use the Open Multi-Ext as Data Cube option, or from the command line use ds9 -medatacube filename.fits. This is useful for the two-extension data files delivered from APO's Near Infrared Camera/Fabry Perot Spectrograph
It is possible to make publication-quality images using DS9. Under the Analysis command menu, select Coordinate Grid, then Coordinate Grid Parameters....
Note that I've used inverted colors so that the image will print nicely on white paper. The format in this image is, frankly, quite ugly. It is known as Analysis format. Thankfully, in DS9 5.0, there is a Type menu that allows you to change to Publication format. Also, you can change the colors of each element of the coordinate grid and remove the axes, tickmarks, etc. via the various menus. It will probably be necessary to modify the locations of the labels as well.
Finally, to save as a postscript, Print the file to a postscript file instead of saving it.
The resulting image is mostly satisfactory except for the annoying presence of the colorbar, which currently cannot be removed except by editing the postscript directly - I believe this is a glitch in DS9 that will likely be fixed in the next release.
EDIT 6/23/08: In the latest release(s), you can remove the colorbar using the command line option
xpaset -p ds9 view colorbar no or by selecting the option in the 'view' menu
Controlling DS9 from the command lineThere are some settings you can't change from DS9 directly. For these, you can use the xpa interface. e.g.
xpaset -p ds9 prefs bgcolor black
xpaset -p ds9 prefs nancolor black
The same can be accomplished by opening DS9 from the command line:
ds9 -prefs nancolor red
Multiple files in a fieldYou can open multiple files from the command line with commands like:
ds9 -mosaic wcs *.fits
You can then open other images by specifying a new frame (only once)
ds9 -mosaic wcs set1*.fits -frame new -file file2.fits
It is also possible to automatically align the images. They will be aligned to the last image loaded.
ds9 *.fits -match frames wcs
It can be useful to load region and contour files too. For the contour file, you must specify coordinate type (wcs) and coordinate system (icrs, fk5, galactic...)
ds9 *.fits -region load file.reg -contour load file.con wcs icrs red 1
An example gigantic command line that saves me ~30 mouse clicks. You can split the command into multiple lines by prefacing new lines with a \:
ds9 -mosaic wcs scuba*.fits -region load w34_gbttargets_handselected.reg -region load w3_nh3.reg \
-frame new -file l133_1_coadd_h2omaser.fits -region load w34_gbttargets_handselected.reg \
-region load w3_nh3.reg -contour load w34_scuba.con wcs icrs red 1 \
-file l134_1_coadd_h2omaser.fits -region load w34_gbttargets_handselected.reg \
-region load w3_nh3.reg -contour load w34_scuba.con wcs icrs red 1 -single -match frames wcs
For significantly more advanced DS9 use, you can make your own analysis packages to put in to the "analysis commands" menu.
For example, I have a file analysistools.ds9 with contents:
Quick-look Aperture PhotometryIn ds9 7.1 (released in late 2012), there is a new "Region Statistics" feature. In most regions, you can now double-click on the region, then go to the region's analysis menu and click "Statistics". It will pop up a window showing basic stats (sum, mean, stddev, etc.).
If you're looking for something a little more complex and flexible, try ds9_phot from agpy. WARNING: pyds9 currently (10/27/2012) does not work with astropy! You'll need pyfits, pywcs, pyregion, and pyds9.