Space Telescope Science Institute
Intro to HST Data Handbooks 8.0 May 2011
help@stsci.edu
Table of Contents Previous Next Index Print


Introduction to the HST Data Handbooks > Chapter 4: IRAF Primer > 4.3 IRAF Basics

4.3
IRAF Basics
This section describes basic IRAF techniques such as:
4.3.1
In IRAF jargon, an application is called a task and logically related tasks are grouped together in a package. Before you can use a task, you must load the package containing that task. To load a package, type the name of the package. The prompt will then change to the first two letters of the package name, and the screen will display the names of all the newly available tasks and subpackages. Even though the prompt has changed, previously loaded packages remain loaded, and all their tasks remain available.
The standard way to specify a path through the IRAF package hierarchy to a task in a particular subpackage is to separate the package names with periods (e.g., stsdas.hst_calib.foc.focgeom.newgeom).
The most frequently used packages can be added to your login.cl file. List the packages, one per line in that file, and each will be loaded automatically when IRAF is started.
Figure 4.2: Loading Packages
Some helpful commands for managing packages are:
? - Lists tasks in the most recently-loaded package
?? - Lists all tasks loaded
package - Lists all packages loaded
bye - Exits the current package
4.3.2
This section explains how to run tasks and system-level commands, and how to use piping and redirection.
Running a Task
The simplest way to run a task is to type its name or any unambiguous abbreviation of it. The task will then prompt you for the values of any required parameters. Alternatively, you can specify the values of the required parameters on the command line when you run the task. For example, if you want to print header information on myfile.hhh, type:
IRAF does not require you to specify the complete command name—only enough of it to make it unique. For example, dir is sufficient for directory.
Escaping System-Level Commands
To run an operating system-level command (i.e., Unix command) from within the IRAF CL, precede the command with an exclamation point (!). This procedure is called escaping the command. For example:
st> !system_command
Piping and Redirection
You can run tasks in sequence if you desire, with the output of one task being used as the input for another. This procedure, called piping, is done by separating commands with a vertical bar (|), using the following syntax:
st> task1 filename | task2
For example, if a particular task prints a large volume of text to the screen, you may want to pipe it to page, which allows you to read the output one page at a time:
st> task1 filename | page
You can also redirect output from any task or command to a file by using the greater-than symbol (>) as follows:
st> command > outputfile
Background Tasks
To run a task as a background job, freeing your workstation window for other work, add an ampersand (&) to the end of the command line, like so:
st> taskname &
4.3.3
This section describes:
How to use IRAF’s online help facility
IRAF tutorials and CL tips
Online Help
You can get online help with any IRAF task or package by using the help command,1 which takes as an argument the task or package name about which you want help. Wildcards are supported. To display the online help for the STSDAS mkmultispec task, type:
Figure 4.3: Displaying Online Help
Two STSDAS tasks that display particular sections of the help file are also available:
examples - Displays only the examples for a task.
describe - Displays only the description of the task.
Typing help package will produce one-line descriptions of each task in the package.
Finding Tasks
There are several ways to find a task that does what you need:
Use help package to search through the IRAF/STSDAS package structure.
Use the apropos task as shown in Figure 4.4 to search the online help database. This task looks through a list of IRAF and STSDAS package menus to find tasks that match a specified keyword. Note that the name of the package containing the task is shown in parentheses.
IRAF Tutorials and CL tips
Hints and tutorials are available on the NOAO Web site to help you become more familiar with IRAF. See the following Web sites:
http://iraf.noao.edu/iraf/web/tutorials/tutorials.html
http://iraf.noao.edu/tips/cl.html
Figure 4.4: Using the apropos Task
4.3.4
Parameters specify the input information for IRAF tasks. They can be the names of input or output files, particular pixel numbers, keyword settings, or many other types of information that control the behavior of the task.
The two most useful commands for handling task parameters are:
lparam to display the current parameter settings (abbreviated lpar)
eparam to edit parameters (abbreviated epar)
Viewing Parameters with lparam
The lpar command lists the current parameter settings for a given task (see Figure 4.5).
Figure 4.5: Displaying Parameter Settings with lpar
Setting parameters with eparam
Epar is an interactive parameter editor. It displays all of the parameters and their current settings. You can move around the screen using the arrow keys and type new settings for any parameters you wish to change. Figure 4.6 shows what you will see when typing epar strfits when using the CL interface.
Figure 4.6: Editing Parameters with epar in IRAF
Parameter Types—What to Specify
Parameters are either required or hidden, and each parameter expects information of a certain type. Usually, the first parameter is required, and very often it expects a file name. Parameters are described in the online help for each task. Hidden parameters, shown in parentheses in the online help and the lpar and epar listings, need not be specified at each execution because their default values frequently suffice.
Wise IRAF users will check the values of hidden parameters, as they often govern important aspects of a task’s behavior.
If you specify the wrong type of information for a parameter, epar will usually display an error message saying something like “Parameter Value is Out of Range.” The message is displayed when you move to another parameter or if you press . Table 4.1 lists the different parameter types.
Table 4.1: Parameter Data Types
Full name of the file. Wild card characters (* and ?) are allowed. Some tasks accept special features when specifying file names, including “@” lists, IRAF networking syntax, and image section or group syntax (see Section 4.3.6).
Floating point numbers, can be expressed in exponential notation. Often will have minimum and maximum values.
Restoring Parameter Default Values
Occasionally, IRAF might get confused by your parameter values. You can restore the default parameters with the unlearn command. You can use unlearn either on a task or an entire package. Help on using unlearn can be found online:
http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?unlearn
 
The unlearn command generally will restore the parameters to reasonable values, a big help if you are no longer sure which parameter values you have changed in a complicated task.
4.3.5
IRAF uses environment variables to define which devices are used for certain operations. For example, your terminal type, default printer, and the disk and directory used for storing images are all defined with environment variables. Environment variables are defined using the set command and are displayed using the show command. Table 4.2 lists some of the environment variables that you might want to customize.
Table 4.2: Environment Variables
Default terminal display setting for image output (Set this to the largest image you will mostly want to display. imt7 will enable images up to 8192x8192.)
Default image type for output images. “hhh” is used for GEIS format and “fits” for FITS format. (“imh” is used for original IRAF format (OIF).)
You can set your environment variables automatically each time you login to IRAF by adding the appropriate commands to your login.cl file. Use your favorite text editor to specify each variable on its own line. The show command with no arguments prints the names and current values of all environment variables.
4.3.6
This section describes:
File Formats
IRAF recognizes a number of different file structures. Among them are the standard HST file formats known as GEIS and FITS (see Chapter 2), both of which differ from the original IRAF format, OIF.
GEIS is closer to OIF, in that two files are always used together as a pair:
A header file, which consists of descriptive information. IRAF (OIF) header files are identified by the suffix .imh. GEIS header files are in ASCII text format and are identified by the suffix .hhh or another suffix ending in “h”, such as .c0h or .q1h.
A binary data file,2 consisting of pixel information. IRAF data file names end with a .pix suffix. STSDAS data files end with a suffix of .hhd or another suffix that ends with “d”, such as .c0d or .q1d.
STSDAS always expects both component files of a GEIS image to be kept together in the same directory.
A single FITS file contains both the header information and the data. See Chapter 2 for details on FITS files.
When working with IRAF (OIF) or STSDAS (GEIS) images, you need only specify the header file name—the tasks will automatically use the binary data file when ­necessary.
File Specification
Most tasks in IRAF and STSDAS operate on files and expect you to specify a file name for one or more parameters. Special syntax can be used with certain tasks when specifying file names. These syntax features include:
Wild card characters, often called templates, which are used to specify multiple files using pattern matching techniques. The wild cards are:
-
 * Matches any number of characters, e.g., j91k10pt*.fits
-
 ? Matches any single character, e.g., z01x23x.c?h
 
When using wildcards to specify GEIS files with image-processing tasks, be sure to exclude the binary-pixel files by ending your file name specification with an “h”, for example: y*.??h.
List files, often called @-files, are ASCII files that contain lists of file names, one per line. If your task supports the list file feature, you would type the name of your list file, preceded by the “@” character. For example: @infiles.txt
Image section specification. Tasks that work with image data will allow you to specify a part of the image rather than the entire image. To extract a particular image section, specify each axis range in square brackets, for example: image.hhh[10:200,20:200]
IRAF networking specification. IRAF is capable of reading and writing files to and from remote systems on a network. This feature is often used with tasks in the fitsio and convfile packages, or with image display tasks. The STSDAS User’s Guide and the online help (type help networking) describe how to enable this feature. To specify that you want to use the IRAF networking feature, type the remote host name followed by an exclamation point (!), followed by the file or device name. For example: nemesis!mta
For example, when displaying from an IRAF session running on a remote machine back to your work station set the environment variable “node” by typing: set node= my_workstation!
Directory Navigation
To navigate through directories, you can use the following commands:
path or pwd - Lists the current working directory.
cd directory - Move to the named directory.
back - Revert to directory last visited.
4.3.7
There are a couple of easy things you can do to make sure that you do not have a simple memory or parameter conflict—common causes of problems:
When you run an IRAF task for the first time in a session, IRAF stores the executable file in its process cache. If IRAF appears not to be running your tasks properly, you may need to use the flprcache command to clear the process cache. To do this, type flpr. Sometimes you will need to execute this command a few times.
If you still have a problem with an IRAF task, see the NOAO IRAF pages at iraf.noao.edu and iraf.net.

1
There is an optional paging front-end for help called phelp. For more information, type help phelp from within IRAF.

2
The binary data file format is host-dependent and may require translation before it can be moved to a computer using a different architecture.


Table of Contents Previous Next Index Print