pyraf - anjavdl/PHY517_AST443 GitHub Wiki

Introduction

Pyraf is an environment within python to use the astronomical software package iraf. Iraf itself dates back to when astronomers first started using CCDs - the first release was more than 30 years ago! Installing, setting up, and using iraf is somewhat cumbersome; pyraf provides a more familiar and user-friendly interface. In particular, it is much easier to write scripts in python/pyraf than in iraf. Pyraf is being developed and maintained at Space Telescope Science Institute (STScI).

Set-up

Pyraf and iraf are installed on the analysis machines in the Astro Computing Lab. If you are on a Linux system, you can install pyraf on your computer following these instructions. Note that iraf has to be installed as well.

Pyraf expects a file login.cl to be in ${HOME}/iraf (or in ${HOME}). To make ${HOME}/iraf and create the login file, run the following:

cd
mkdir iraf
cd iraf
mkiraf

When prompted, make sure to se the terminal type to xgterm. You can now start pyraf from any directory. On first start-up, it will create the directory ${HOME}/iraf/pyraf for its cache.

Usage

Similar to python, you need to load the packages you want to use. Iraf's packages are organized into a directory-like structure; type ? to see a list of the sub-packages under the current package. You can load a package (but not the sub-packages) by typing its name. For example, to load the package images and then the sub-package imutil, you would type:

images
imutil

Every task comes with an extensive help file, which can be accessed through

help task

(Replace task with the name of the task you want to look up, e.g. imarith). The help files are also accessible on the web; a few are linked below.

Image arithmetic

The task imarith (images.imutil.imarith) provides an intuitive image calculator. Adding two images is as simple as:

imarith image1.fits + image2.fits out.fit

Imarith is one of the many iraf tasks that can work with filelists. This can be done by passing a comma-separated list, e.g. the following multiplies image1.fits and image2.fits by 1.2, and writes the results into image1.out.fits and image2.out.fits:

imarith image1.fits,image2.fits * 1.2 image1.out.fits,image2.out.fits

or by writing the image list into a text file, and passing the name of the text file (as well as a corresponding text file with the names of the target images) to pyraf:

imarith @filelist * 1.2 @outlist

Note: image lists can be easily made in bash, e.g.:

ls -1 image?.fits > filelist
ls -1 image?.fits | sed 's/fits/out.fits/g' > outlist

Combining images

The task ``imcombine'' (images.imutil.imcombine) can be used to combine lists of images, with a variety of output statistics, such as the mean of the median. For example, to take the median of all images with "dark" in their name:

imcombine *dark* median_dark.fits combine=median

IMPORTANT

  • Pyraf expects all images to have the extension ".fits". Rename your images if necessary.
  • You can still execute bash commands from within pyraf, just prepend them with "!". For example: !ds9 & will bring up a ds9 window