Astronomy 480 - IRAF Tutorial for Exercise I
Introduction

Learning Goals

Files Needed

/net/projects/Astro_480/exercises/exercise1/
bias_ave_050206.fits.gz
photos.tar.gz
test-f1.fits.gz
test-f2.fits.gz

Starting IRAF

This is a short exercise that should help acquaint you with the basics of IRAF. The first step is to get IRAF running properly, with appropriate auxiliary windows.

  1. cd to your IRAF directory.
  2. Start a new window by typing xgterm & at the Linux prompt on your machine.
  3. Start up a DS9 window by typing ds9 & in the xgterm window.
  4. Now start up IRAF by typing cl –ecl (the flag means "enhanced cl"; there is a space in between cl and -ecl ).

This will give you the IRAF prompt: ecl>

hintHint: It is important that you initiate IRAF from within an xgterm window. The xgterm is set up to interpret graphical information and to open up a graphical window as needed. If you find at some stage that a stream of unintelligible garbage is spewing across the screen, you probably started IRAF from a regular terminal. Be sure you start IRAF from the directory that contains the IRAF initialization file, login.cl. How to log out of IRAF: You don't just kill the window! This is not only bad form, but it will create exceedingly bad B356 karma.

To logout of IRAF, at the prompt: ecl> logout

ALSO, IF THE LOGIN.CL FILE IS NOT IN THE DIRECTORY WHERE YOU START IRAF, MANY, MANY THINGS WILL GO WRONG, and you won't understand why. Trust us.

In this, as in forthcoming exercises, the commands (shown with a different font) after the prompt (either % or ecl>) are meant to be typed by the user; the "#" -character or ";" character indicates a comment. You can pass commands on to the Linux operating system by prefacing them with a "!", for example try this

ecl>!more login.cl

which will run the Linux process "more" on the file called login.cl. You can move down by hitting the spacebar, just as in Linux. Notice that there are a number of initialization parameters that take effect when you start up IRAF. IRAF’s heritage is complicated, and much of the syntax was initially like an antique, ancient operating system called VMS. There are many instances, however, when the intrinsic IRAF command is identical to the Linux one. For example

ecl>!ls

and

ecl>ls

have the same effect, but you should think of the former as being passed up to the Linux operating system while the second is being carried out within IRAF. By the way, ! is pronounced BANG! So, when giving assistance, one might say, "Type BANG ell ess."

You should already have the images in a directory called exercise1 or in your 'imdir.' They should be uncompressed and extracted from any tarballs. If not, return to IRAF Exercise 0, Getting Ready.

The image files for this tutorial and subsequent exercise are photo1.fits, photo2.fits, photo3.fits, bias_ave_050206.fits, test-f1.fits, and test-f2.fits.

Image Headers

The next step is to familiarize yourself a bit with some of the basic operations of IRAF. Tasks with similar or related functionality are grouped together in "packages." Tasks, and sometimes packages, have parameter files that control their operation. Your login.cl file determines which packages are loaded when IRAF starts. Others must be invoked by loading them as needed.

hintHint: If you type a favorite IRAF command that it does not recognize, the package is probably not loaded.

The image data files we will be using contain both "header" information and digital data. The header information in FITS format files is stored as ASCII characters at the top of the file. You can actually peek at the header of a FITS file in Linux using the "head" command, but it’s not recommended. IRAF has a suite of tools to look at and edit header information, and the DS9 image viewer has an option as well.

Try these commands to get started:

ecl>package # show what packages are currently loaded
ecl>help images # help for the package "images"
ecl>phelp imheader

# help for task "imheader" is the proper package loaded for its execution?

phelp in IRAF acts like "more" in Linux:
ecl><space bar> # go to next page of help
ecl>b # go back one page
ecl>? # view options
ecl>q # quit the help for this task

LPAR (list parameters)

Tasks in IRAF usually use parameters that modify the actions taken. These parameters are stored in parameter files in your uparm directory (a subdirectory off your IRAF home directory, remember?). To list the values of the parameters you use the utility lpar. It’s common to modify the values of these parameters when running IRAF. In order to revert to the default parameter set, you use the task unlearn. To list the settings of the set of parameters for the task imheader, you would type

ecl>lpar imheader # list task parameters - task names

hintHint: Parameters need only enough characters specified to be identifiable, so try the various options suggested below.

ecl>lpar imhea  
ecl>lpar imh # this is not unique, more than one task name starts this way
ecl>lpar imheader # note query and hidden parameters - query parameters are listed first with hidden parameters following in parentheses
ecl>unlearn imhead # unlearn parameters - go back to defaults
ecl>imhead *.fits # short header listing - what does it tell you?
ecl>imhead *.fits > shortheads # redirection works! Useful!
ecl>page shortheads # the "page" task is the IRAF equivalent of "more" in Linux, as in "phelp" above.
ecl>lpar imhead # this lists the parameters of the task "imhead" ; how do you change them?
ecl>epar imhead # modify the task so it always types the long header listing – Move using the arrow keys, and then type yes over the parameter entry for "longheader" followed by a return. It replaces previous text.
:wq or <ctrl-D> # exit eparam mode and "save" the new parameters
ecl>lpar imhead # was the edited parameter saved?
ecl>imhead *.fits | page # you should get a long listing by default, now.

The settings of the IRAF task parameters are stored in the "uparm" directory, off your IRAF home directory. The names are concatenations of the package name, and the task name. Don’t worry, there is a way to always return to the default parameters for any given task:

ecl> unlearn imhead # go back to the default parameter setting

hintThought Questions: Do a quick self-review about parameters. How do you revert to the default parameters for a given task? What is the uparm directory? Do you understand the different syntaxes that we have been using in task executions? If you have questions review the Beginner's Guide to IRAF referenced below and linked from our calendar web page.

History

IRAF can redirect terminal output to a file, as well as pipe output from one task into the input of another task. There is also a history and recall mechanism.

ecl> history # prints history tree
ecl> ^ # recall and execute last command; include a number to execute any task in tree
ecl>arrow_keys # arrow keys also work under ecl
ecl> ehis lpar # recall last lpar command; can edit command line before executing with "return" use the arrow keys to move cursor, delete or insert to the left of the cursor
ecl> history 100 # look at last 100 commands
ecl> history 100 > hfile # redirect output to a file
ecl> page hfile # page the output file
ecl> history 100 | page # alternate method avoiding intermediate file

Note the difference between ">" and "|". This last command uses the "pipe" command, "|", which sends the output stream to another task, as opposed to ">" , the redirection symbol that is used to send the output stream to a file.

Some Applications

The images that now reside in /net/projects/Astro_480/spring-??/yourusername/exercise1/ are frames obtained in testing candidate replacement detectors for a mosaic CCD camera. Take a look and then display one of them.

ecl>imstat *.fits # gives us the statistics for the image
ecl>ls *.fits # prints out summary table with useful info. Try listing its parameters.
ecl>unlearn display  
ecl>set stdimage=imt6 # configures image display to accept large format images; temporarily overrides the default we typed into login.cl file.
ecl>lpar display # look at the parameters for the display task
ecl>disp test-f1 1 # load the first image into the image display in frame 1

DS9 ExampleYou should see a rectangular CCD image on the DS9 display, as well a smaller image with the full image shown in the upper right corner of the DS9 window.

DS9 – An image display tool

This is probably a good time to get acquainted with DS9. This utility allows you to view image data as a greyscale image. The correspondence between the raw data values and the shading on the screen can be controlled to highlight features. You can also "zoom" in on regions of interest. DS9 will handle a stack of images at once, 16 in total, placing each one in a distinct "buffer" that is referenced by numbers.

You should already have DS9 running, and you should learn how to zoom, pan, window, and blink between multiple images. All these options can be done with the mouse. Notice the pull down menus at the top of the window. Pull each menu down and review the selections; use the left mouse button to activate and pull. Alternatively, you can use the buttons that are set horizontally just above the image viewing part of DS9. Your choice.

The greyscale lookup table can be modified by moving the cursor up and down in the window (contrast) or left and right (brightness) while holding down the right mouse button. The bar across the bottom of the DS9 window shows how the digital data values are mapped onto the displayed greyscale. If the bar across the bottom shows only the far right end as white, and the rest as black, then only the highest data values will be displayed as white, and the rest black. Alternatively, if the entire bar across the bottom is the same grey color, then all pixel data values will show up as that same grey (contrast = 0). Watch the brightness and contrast values change as you hold down the right mouse button and move the cursor around the frame.

See if you can find a greyscale setting that brings out the texture in the main image section of the frame (i.e. not the overscan).

Panning and zooming might be done with the middle mouse button. Test this statement. Move the cursor to an interesting part of the image and click twice with the middle mouse button without moving the cursor. Click again without moving the cursor. If you move the cursor and then click, the region under the cursor is moved to the center of the window (panning). If you click without moving the cursor then the region is zoomed. Play with this until you understand how it works. Go back to the unzoomed image when you are finished.

We want to blink this field and that of test-f2. So we will need to load the second image into the second frame buffer; recall you have 16 frame buffers available for images. Let’s load an image into buffer #2:

ecl> display test-f2 2

Blink between the two frames by pressing the "Frame" and then "Blink" buttons. You can adjust the blink rate by using the drop down "Frame" menu. These two routes, offering simple and more complex options respectively apply to most controls in DS9. Do you see small differences between the frames? You may have to zoom in on a small region to see the subtle differences in pixel values.

hintNOTE: There is a subtle feature of the DS9 image display tool that is very important. If you open an image through "Files" and "Open…." from the drop-down menu at the top of the DS9 window, you get better scaling, with more flexibility. A perfect example: Open a new frame from within DS9 window. Open up test-f2.fits by using the "Files, Open" menu. See the difference? The data and analysis performed will be identical; it is the scaling that is different. (There are ways to make the scaling equal, surely, we just haven't bothered to find out.)

Now, display some different images, those containing real stars.

ecl>disp photo2 3 #Can you find the faint galaxy in this field?
ecl>disp photo3 4 #If you don't see at least 50 stars, then adjust the scaling.
hintNOTE: if you use the DS9 buttons or menus to open files, you must click on 'frame' and 'new'; otherwise, the previous image in a frame gets clobbered.

Scroll through the frames using the "Frame" button options (i.e. next/previous). Notice that the name of the image changes, at the top of the window, as you change what is displayed.

Imexamine

Recall that a FITS file contains the header information, and a two-dimensional array of intensity values corresponding to the amount of light detected at each pixel. With an image displayed on the DS9 window, you can use one of IRAF’s most powerful interactive utilities to explore the pixel data. In the IRAF window, type

ecl>imexamine #ecl>imexam will also work

This provides access to a toolkit that will take some time to explore. The cursor appears as a small round doughnut. Keystrokes initiate a number of tasks that occur centered on the cursor. Here is a list of some imexamine tasks you should try out:

? lists imexamine options
z prints out pixel values in a region around the cursor
m computes statistics on pixels near the cursor
s makes a surface plot of the region around the cursor
e makes a contour plot of the region around the cursor
l makes a plot of the pixel values of the line containing the cursor
c makes a plot of the pixel values down the column that contains the cursor
q quits out of imexamine task, control returns to IRAF xgterm window

Try these out and see what happens. Place the cursor over a stellar image in the photo2.fits image, and try z, s, e, and r in imexamine. Refer to the on-line phelp facility for imexamine, as needed.

While you’re running imexamine you can change how IRAF interprets keyboard and mouse inputs. You can switch between the original IRAF session, the DS9 window and the graphics window. The table below describes how to change the input mode between the IRAF xgterm, the "graphics" window, and the "image" window (DS9). IMPORTANT: If you close the graphics window while running imexamine, you will not be able to reopen it without restarting imexamine. IRAF is extremely persnickety about having the commands given in the absolutely correct order.

To go to

Type

Image cursor

i

Graphics cursor

g

IRAF window
q

Table 1. Keystrokes to switch input streams in imexamine

Make sure you feel comfortable with imexamine. We will use it almost every day for the rest of the quarter.

warningREPEAT: When using cl –ecl, switching between the graphics window, the image window, and the xgterm is a very sensitive process! You will hang up the graphics window, get stuck in another window, or even crash the computer. The program cares a lot about the ORDER you do your keystrokes, and whether or not you properly quit a window. Make sure this point sticks!

With the image test-f2.fits displayed on the DS9 window, use imexamine and the graphical and image display windows to roam around the frame. In this image the output amplifier, which leads to the complete read-out process, is at the lower left corner of the picture, at pixel 1,1.

ecl>disp test-f2.fits 1 #puts image into DS9 buffer 1
ecl>imexam  

Now execute the following keystrokes, with the cursor positioned somewhere in the middle of the image:

l # letter ‘l’ produces a plot of the line under the cursor (goes across all columns)
c # letter ‘c’ produces a plot of the column under the cursor (goes across all rows)
g # changes cursor over to the graphics window. Move the mouse over that frame
:y 200 3000 # rescales the y-axis of the plot to range only between 200 and 5000
:x 1020 1050 # zooms in on columns towards the right edge of the detector
:x # resets x limits
:y # resets y limits
q # letter ‘q’ gets you out of graphics mode.

Can you tell where the overscan pixels begin from the graphics plot alone?

You can generate a hardcopy printout of whatever is in the graphics window. Check with our course Wiki (wikiastro480ia), your instructor or TA to find out how. The method seems to change in direct correlaton to updates on the computers.

You should now be able to work through the worksheet that accompanies this tutorial. Refer to the IRAF online "phelp" facility and this document before asking for help. If those don’t work, then by all means ask your instructor, TA, or one of your fellow students.

When you’ve filled out the worksheet, hand it in and exit IRAF by typing

ecl> logout

References