What is PyRAF?

PyRAF is a command language for IRAF based on the Python scripting language that can be used in place of the existing IRAF CL.

Why a new IRAF CL?

The current IRAF CL has some shortcomings as a scripting language that make it difficult to use in writing scripts, particularly complex scripts. The major problem is that the IRAF CL has no error or exception handling. If an error occurs, the script halts immediately with an error message that has little or no information about where the error occurred. This makes it difficult to debug scripts, impossible to program around errors that can be anticipated, and difficult to provide useful error messages to the user.

But there are other important reasons for wanting to replace the CL. We want to develop a command language that is a stronger environment for general programming and that provides more tools than the existing IRAF CL. Python (www.python.org), like Perl and Tcl, is a free, popular scripting language that is useful for a very wide range of applications (e.g., writing CGI scripts, text processing, file manipulation, graphical programming, etc.). Python is also an open system that can be easily extended by writing new modules in Python, C, or Fortran. By developing a Python interface to IRAF tasks, we open up the IRAF system and make it possible to write scripts that combine IRAF tasks with the numerous other capabilities of Python.

Ultimately, we plan for PyRAF to have command-line data access and manipulation facilities comparable to those of IDL (the Interactive Data Language, www.rsinc.com, which has extensive array-processing and image manipulation capabilities). It should eventually be possible to write applications in PyRAF that can manipulate the data directly in memory and display it much as IDL does. We are hoping that Python and PyRAF will become the programming language of first resort, so that programmers and astronomers will only infrequently need to write programs in C or Fortran. Moreover, when it is necessary to use compiled languages, programs written in C, C++, and Fortran can be easily linked with and integrated into PyRAF.

What are the current PyRAF capabilities?

PyRAF can run the vast majority of IRAF tasks without any problems. You can display graphics and use interactive graphics and image display tasks as well. You can even run more than 90% of IRAF CL scripts! While many things work the same way as they do in the IRAF CL, there are some differences in how things are done, usually for the better.

Currently, the most important difference between PyRAF and the old IRAF CL is that PyRAF allows you to write scripts using a much more powerful language that has capabilities far beyond simply running IRAF tasks. Some of the things that now become possible are:

As far as the interactive environment goes, the new system has most of the current features and conveniences of the IRAF CL available as well as a number of new features. It is possible to use exactly the same familiar IRAF CL syntax to run IRAF tasks (e.g., imhead dev$pix long+). There are some additional features such as command-history recall and editing using the arrow keys, tab-completion of commands and filenames, a GUI equivalent to the epar parameter editor, the ability to display help in a separate window, and a variety of tools for manipulation of graphics. We believe the new environment is already in many ways more convenient for interactive use than the IRAF CL, and further enhancements are planned.

Does this mean I have to learn another programming language?

If you only want to use the interactive conveniences of the new language you can probably get by without learning Python; PyRAF syntax is so similar to the old CL syntax that it should be an easy transition for IRAF users.

On the other hand, if you want to write scripts using PyRAF then you will certainly want to learn Python. We understand the natural reluctance of many to learn yet another software tool. We do not claim that everyone can become an expert Python programmer instantly, but Python is a simple enough language that one can learn to do simple things in a matter of hours. If you want to use all of the powerful features of the language, you should expect that it will take days or weeks to learn, depending on the sophistication of what you wish to accomplish. Nevertheless, it is possible to do quite a lot with a very modest learning effort. We feel that the vast majority that invest the initial effort will not regret it. Python is a very flexible and powerful scripting language that has wide applicability to numerous problems beyond data processing. Once learned, you will find it a convenient tool for many problems.

The PyRAF language does have a CL-compatibility mode that allows access to IRAF tasks using CL syntax. This mode can be convenient for interactive use, but we strongly encourage users who want to write scripts to learn the Python language in order to benefit from the full power of the PyRAF system.

Yes, I'm interested. Where do I start?

Read the PyRAF tutorial to get a more detailed understanding of what PyRAF can do. We also have written a quick tour of the Python language itself. If you are installing PyRAF, see the PyRAF installation guide for instructions on how to download and install it.


Perry Greenfield & Rick White
Questions? Contact help@stsci.edu
2001 December 7