about Grigoris Maravelias
Including IRAF tasks in Python scripts

Including IRAF tasks in Python scripts

What do you get if you combine IRAF and Python ? Of course something that starts with Py and ends with RAF, PyRAF, which combines IRAF’s tasks with the Python’s command (allowing to create more sophisticated scripts than the cl ones).

But in order to implement these abilities in a python script you have to include (aka import) the packages you want to use (thanks to this post!).
Suppose that we want to use the ccdhedit command which is included in noao/imread/ccdred package. Then we write:

#!/usr/bin/env python
from pyraf import iraf
from iraf import noao, imred, ccdred

iraf.ccdhedit("bias*.fit", parameter="imagetyp", value="zero")
print "All done!"

Every parameter is given inside the () like what we would do if we were using the command line. The wildcard * is still valid and the ccdhedit will change the imagetyp header keyword to zero all the bias images in this case.

Leave a Reply

Your email address will not be published. Required fields are marked *