[Pythoneers] PyRAF (how to run IRAF tasks with python)

Maryam Habibi mhabibi at mpe.mpg.de
Fri Jun 10 15:20:43 CEST 2016


Hi Pythoneers!

As I needed to use some IRAF task in my python script, I thought why not
sharing  with you how to that. It might save a day of googling for you.
Most of you are probably familiar with IRAF (a general purpose software
system for the reduction and analysis of astronomical data). PyRAF gives
users the ability to run IRAF tasks in their python scripts or in an
environment that has all the power and flexibility of Python. First of
all we need IRAF on our machine. At MPE IRAF is installed as part of the
ESO scisoft.
You have to run
source /scisoft/bin/Setup.bash
...and then you can call IRAF  separately (aka cl) or via python.

Don't forget to run "mkiraf" in the folder you want to run your python
script, which will create your login.cl file, your uparm directory, and
will define system logicals and symbols. Otherwise, your python script
can not set IRAF task's parameters.

The latest version of PyRAF is v2.1.10 which supports Python 2.6, 2.7,
and 3.4, 3.5! The easiest way to install it is to use pip (pip install
pyraf  or  pip3 install pyraf). Both the pip and pip3 install the
v2.1.10 version, but to change the relevant path so that python3 finds
IRAF you need to use pip3. Finally, you can import PyRAF  as a normal
package in your python script (from pyraf import iraf), and with
iraf.testtask() you access all the iraf tasks.
You can set/view IRAF task parameters (like R.A parameter in a task
testtask) : iraf.testtask.ra='17:45:40'

That's it!
Cheers,
Maryam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.mpe.mpg.de/pipermail/pythoneers/attachments/20160610/31c8c61a/attachment.html>


More information about the Pythoneers mailing list