Here's an easy way to display FITS images (or any array) in DS9 using Python (with PyFITS, NumPy and Numdisplay, which is part of stsci_python). First launch DS9, then in Python:

import numdisplay
import pyfits
arr = pyfits.getdata('file.fits')
numdisplay.display(arr)

Easy!

Alternatively, the Kapteyn package seems excellent, and uses Python's matplotlib for displaying images. It requires WCSLIB to run, though, so the installation process is a bit longer [update: apparently that bit is no longer true - 17 Oct 2011].

A third option is to use python-sao:

import pysao
import pyfits
ds9 = pysao.ds9()
f = pyfits.open('file.fits')
ds9.view(f[0])

Easy again! And the WCS information is preserved, which doesn't seem to be the case with Numdisplay.



comments powered by Disqus