PyRAF is a command language for running IRAF tasks that is based on the Python scripting language. It gives users the ability to run IRAF tasks in an environment that has all the power and flexibility of Python. PyRAF can be installed along with an existing IRAF installation; users can then choose to run either PyRAF or the IRAF CL.
The current release of PyRAF is v2.1.9 and can be downloaded from the stand-alone PyRAF download page.
PyRAF can also be found bundled with stsci_python which can be downloaded from the stsci_python download page.
The release notes can be found here.
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, 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:
- Easier script debugging.
- Ability to trap errors and exceptions.
- Access to all the features of Python including:
- built-in list (array) and dictionary (hash table) data structures
- extensive string handling libraries,
- GUI libraries that make it straightforward to wrap IRAF tasks with GUI interfaces,
- web and networking libraries making it easy to generate html, send email, handle cgi requests, etc.
- Python was designed to make it simple to provide access to other software packages written in C or Fortran. For example, it should be comparatively easy to construct scripts that combine IRAF tasks with locally written software and libraries.
- For the more adventurous, it is possible to read data arrays and tables directly into Python and manipulate them on the command line (but in our view some improvements are needed before such capabilities will be considered the equal of IDL).
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 installation instructions on the download page for instructions on how to download and install it.