IV. Miscellaneous Tips for Working with the CL

TOC | previous | next

A) Input Lists

Many times we will want to run an IRAF task on several images. One way to do so is to give a comma separated list for the input. IRAF interprets spaces as separating different inputs, so be sure not to leave any spaces in the list of input images.

cl> imstat sn2002ap_300_B,sn2002ap_300_V,sn2002ap_300_R
#               IMAGE      NPIX      MODE      MEAN    STDDEV       MIN       MAX
       sn2002ap_300_B    173400     1344.     1393.     192.8   -31158.    16957.
       sn2002ap_300_V    173400     1111.     1146.     169.5      750.    26947.
       sn2002ap_300_R    173400     1615.     1653.     193.7     1131.    28546.

You can also use wildcards in your input:

cl> imstat sn2002ap_300_*
#               IMAGE      NPIX      MODE      MEAN    STDDEV       MIN       MAX
   sn2002ap_300_B.fit    173400     1344.     1393.     192.8   -31158.    16957.
  sn2002ap_300_B2.fit    173400     1336.     1393.     188.8   -31260.    17067.
   sn2002ap_300_R.fit    173400     1615.     1653.     193.7     1131.    28546.
  sn2002ap_300_R2.fit    173400     1652.     1681.     197.2   -30392.    17127.
   sn2002ap_300_V.fit    173400     1111.     1146.     169.5      750.    26947.
  sn2002ap_300_V2.fit    173400     1095.     1123.     173.6   -31350.    16715.

The last option is to generate a list file. A list file is just a text file which contains the filenames you want to operate on, placing one file name per line. You could generate it using any text editor you choose. To tell IRAF that the input is a list file, prepend an "at" symbol like so:

cl> imstat @list_sn2002ap
#               IMAGE      NPIX      MODE      MEAN    STDDEV       MIN       MAX
   sn2002ap_300_B.fit    173400     1344.     1393.     192.8   -31158.    16957.
  sn2002ap_300_B2.fit    173400     1336.     1393.     188.8   -31260.    17067.
   sn2002ap_300_R.fit    173400     1615.     1653.     193.7     1131.    28546.
  sn2002ap_300_R2.fit    173400     1652.     1681.     197.2   -30392.    17127.
   sn2002ap_300_V.fit    173400     1111.     1146.     169.5      750.    26947.
  sn2002ap_300_V2.fit    173400     1095.     1123.     173.6   -31350.    16715.

There is an easy way to generate such files using the files task within IRAF. The files task, works similarly to ls in UNIX, but it outputs one filename per line as a list file should contain. Here is an example of the output of files:

cl> files sn2002ap_300_*
sn2002ap_300_B.fit
sn2002ap_300_B2.fit
sn2002ap_300_R.fit
sn2002ap_300_R2.fit
sn2002ap_300_V.fit
sn2002ap_300_V2.fit

The list is simply printed to the screen. To make a list file we want the output to go to a file. We can do this using redirection commands (which work similarly in IRAF to redirection commands in UNIX). To redirect to a file, we use append a > and the file name to the command. Be aware that the > redirection will not overwrite files, so there cannot already be a file with that name. The type and page commands in IRAF will print the contents of a text file to the screen (similar to cat and more in UNIX respectively), we can use those to check that out list file contains what we wanted.

cl> files sn2002ap_300_* > list_sn2002ap
cl> type list_sn2002ap
sn2002ap_300_B.fit
sn2002ap_300_B2.fit
sn2002ap_300_R.fit
sn2002ap_300_R2.fit
sn2002ap_300_V.fit
sn2002ap_300_V2.fit

You can also explore the use of the UNIX commands for text editing to change the output of the files task. grep is very useful, sed, awk, and perl can also be used. For example,

cl> files sn2002ap_300_* | grep B > list_sn2002ap_B
cl> type list_sn2002ap_B
sn2002ap_300_B.fit
sn2002ap_300_B2.fit

B) CL History

One other convenience in the IRAF CL is command history. In UNIX, we use the up-arrow to scroll back through previous commands. In IRAF, we use the ehistory command. To invoke, just type ehist or sometimes just e at the CL. Then use the up arrow to scroll back through old commands, hit enter to rerun a command, you can also edit commands before running them, to exit ehist, hit CTRL-c.

You can also call back the last occurrence of a command, by using ehist text, then the ehist list will jump to the last occurrence of a command which began with "text".


C) The apropos Task

On some installations (unfortunately not the cosmos installation for those of you in ASTR 3510/3520) the apropos task is available. The apropos task helps you find the right task for a given job. apropos searches through brief descriptions of all the tasks looking for the keyword you input. Beware though, that there are a lot of tasks in IRAF, sometimes apropos hurts more than it helps when it returns dozens of task names.


D) Image Subsections

You can operate on sections of images if you like. To describe the subset of pixels that you want to work on, use the following format:

cl> imstat imagename[x1:x2,y1:y2]

where x1 and x2 are the x range, y1 and y2 are the y range of pixels. You can also use imcopy to create a new image which is the subsection of a larger image:

cl> imcopy imagename[x1:x2,y1:y2] imagename2

E) CL Scripts

In using IRAF, you may wish to script a set of commands which can be run in sequence with one command. To do so, we compose a CL script, which is a text file usually ending in .cl. We can run the script by redirecting it to the cl using the < redirection command.

For example, if we create a text file called myscript.cl which contains the following lines

displ 026_n2392_600_ha 1 zsc- z1=32943 z2=37000
imstat 026_n2392_600_ha

Then we run it using

cl> cl < myscript.cl
z1=32943. z2=37000.
#               IMAGE      NPIX      MODE      MEAN    STDDEV       MIN       MAX
     026_n2392_600_ha    173400    32945.    33056.      402.    11003.    61213.

We can also add comments to our scripts with the # symbol. Anything following the # symbol on a line is interpreted as a comment. For example, our text file myscript.cl could also be written

# Display the image
displ 026_n2392_600_ha 1 zsc- z1=32943 z2=37000  # note the altered z range
# See the image statistics
imstat 026_n2392_600_ha

This script runs the identical commands, but with comments which will make it easier to interpret later on.


TOC | previous | next

Copyright © Josh Walawender