Introduction to Astronomical Computing

At the College of Charleston

(last updated 1 September 2012 by J.E. Neff)

 

Exercise #3 – Getting Started with IRAF

 

This is a short exercise to get you started using X11 ("x-windows") and IRAF.  To learn more you've got to dive in, play around, look at what other people have done and are doing, and occasionally read some manuals.  The more you can build up a general knowledge, the more effective (and efficient) you will be when you need to use these tools for real data analysis.

 

 

I.                             X-WINDOWS

 

In the first exercise, we used whatever type of terminal we could find in order to issue unix commands.  Both IDL and IRAF also need to communicate with your graphical display.  That's not really done at the unix level.  Between unix and what you see on the screen there is a batch of open-source software collectively called "X-WINDOWS".  You may never need to know how it works, but you need to know how to make sure it's running, and you need to know how to run a handful of x-windows programs (applications).

 

When you log into a Linux machines, the windowing system you see is already based on x-windows, so you don't need to do anything more.  On the Macs, you have to explicitly start up X-windows.  You can find it in the Utilities subdirectory of the Applications folder.  You should put it on your dock, because you'll nearly always use it.  When you click on the X icon, x-windows will start up.  Whenever it's running, any x-windows tool will work right on top of the OS-X graphical interface.

 

The main x-windows tool you'll use is an "xterm".  It's like any other terminal window, but if you issue a command that does any kind of graphics, it will know what to do with your display.  An xterm comes up automatically on the Mac when you start X.  On linux machines, if you had an xterm on there last time you logged out, there should be one when you start the windowing system.  But you might have to start one from a menu. 

 

The other way to start an xterm is to use a command line from another terminal type (e.g. a "console").  All you have to do is type xterm and hit return, but the default xterm is limited.  So what you'll want to do is to define an alias in your .cshrc file so that when you type xterm, it will execute the following command xtermsbsl 10000 –fn 9x15bold –bg white (if you want to see what all these options mean, or to change them to something you prefer, read the man page for xterm).  One last little thing.  When you type a unix command, it runs until it's done.  So if you type the  xterm command from a different terminal, you can't use that terminal any more.  To get around this problem, end your command with an &, which executes the command "in the background".  In other words, type xterm &, not just xterm.

 

 

Although IDL runs fine in the default os-x "terminal" window, there are many other types of terminal window it doesn't work in.  So it's a good habit to start IDL from an xterm window.   

 

You can also customize your X11 Applications pull-down menu on the Mac.  For example, make the default application your favorite xterm so that you can bring up a new terminal with a command-N.  There are KDE shortcuts to speed up the process, too, so you might want to investigate those on the linux machines.

 

You will use a couple of other x-window tools. IRAF runs better out of a modified xterm, called xgterm.  You start it up the same way: xgtermsbsl 10000 –fn9x15bold –bg white &  You'll probably want to put an alias in your .cshrc file so you don't have to type this all the time, and you can also modify your X11 Applications pull-down menue to include it there.  Iraf will also use either ximtool or DS9.  Both are xwindows tools for image display and low-level analysis.  There are a lot of other X11 applications you can learn (I highly recommend you play with xephem), but nothing else is critical.

 

II.                         STARTING IRAF

 

Your home directory is publicly readable, and it's full of hidden system files and maybe other junk put there by the windowing system.  So the first thing you'll want to do is to make a new working directory.  Keep all of your ASTR377 stuff together in this subdirectory.  In your home directory, type mkdir ASTR377 (if you haven't already done so) then cd ASTR377 and type mkdir Iraf

 

When iraf starts up, it needs to read a file similar to your .cshrc file, but it needs to be called login.cl and it needs to be in the directory you start iraf from.  This file and a few subdirectories have to be created before you can run iraf the first time.  cd into your Iraf directory and type mkiraf and choose the xgterm option when it asks.  When this program is done, it will leave a login.cl file.  As you learn more, you might want to change some things in it, but for now, you only need to make one change.  Using pico, make sure home is set to the full path to your Iraf directory, and change the imdirs line to read /home/yourname/ASTR377/Iraf/Pixel/  (or whatever the full pathname is for the system you are on) then save the file.  Then mkdir Pixel and make sure there is also a uparm subdirectory (if not, mkdir uparm).  You only have to do all of this once in order to initialize your Iraf directory. 

 

You need to run iraf from a xgterm, and you need to have an image display tool running.  So the procedure to start iraf is

 

cd /yourhomepath/ASTR377/Iraf

xgterm &

ds9 &  (or ximtool &; if ds9 doesn't start from command line, let me know;

            you can also start it from Applications/SAOImage DS9)

cl        (from the xgterm window)

 

Don't ask me why it's cl rather than iraf.  Once you have started iraf, you will get a new command prompt (cl> or ecl> initially, but it will change as you go along).  The iraf command language is not unix.  There is a new suite of commands to learn.  But many unix commands still work (especially cd, ls, cat, more; the ones you already know). 

 

You might have data in some other directory that you want to work on.  Just cd into that directory before you try to read or write anything.  I recommend that you not work in the Iraf directory itself.

 

Iraf is a tool box that holds everything its developers imagined you would ever need to analyze astronomical data.  But not all of the drawers are open at once.  It consists of "packages" full of "tasks".  Each task is designed in a similar way.  I think of it like a voting machine.  You set all the necessary parameters then you pull the lever by typing the task name.  What you get out depends on how you set up all the required and optional parameters.   For the image reduction work we'll be starting with, you'll want to load noao, imred, and ccdred in order, but before you do that... 

 

T a ? and you'll see a list of options.  One of them is noao.  Type noao you'll see different option, one of which is imred.  ccdred is one of the options "inside" imred.  Each time you load a new package, the prompt changes to remind you of where you are at. To display the options any time, not just when you are loading packages, type a ?. 

 

Typing help gives a short description of each package.  Typing help packagename gives you a summary of the tasks inside that package.  When you get down to the bottom level (ccdred in this case), typing help taskname gives you full help on that task.  One of the first tasks you'll use will be one called display (which is actually not in any of the packages you just loaded, but it gets loaded by default), so type help display and you'll see more information than you can digest at this point.  It's a little bit of a mystery when you need to load packages to have tasks available (like combine) and when they are loaded all the time (like display), but you'll get used to it.  When you get curious about that, you can gain some insight by looking more closely at your login.cl file. 

 

The "switches" that you set before pulling the lever in each task are called parameters.  You can list all the parameters for a task with the lpar command.  Try lpar display.  Parameters in parentheses are optional and all have default values.  That doesn't mean they are unimportant.  Parameters at the top must be specified before the task will run, but they often have default values also.  display has 2 required parameters, a filename containing an image and a "frame" to write into.  DS9 and ximtool can handle multiple images at once (for comparison purposes).  For now, you'll just be looking at them one at a time, so you'll always use frame 1.  I will give you some images to practice with in part IV.  Let's say you have an image in a file called mydata.fits and you want to display it in the ds9 or ximtool window.  In your xgterm, making sure you are in the directory with the fits file, you'd type display mydata.fits 1  or you could just type display and then be prompted for the 2 required parameters (try it both way so you see how it works).  If you want to change one of the optional parameters, you can either do that at the command line by typing the optional parameter with an equals sign and an argument (e.g. display mydata.fits 1 bpcolors="blue").  This will only change the optional parameter for this execution of the task; next time it will revert to the default. 

 

If you want to change it permanently, or if you want to change a lot of parameters, it's best to use the epar command (epar display).  This pulls up the parameter list in an editor that is kind of finicky and could squawk if your terminal is not configured correctly.  Practice with it a bit.  Just move the cursor to the parameter you want to change, type in the new value, and hit return.  If your new value is accepted, it will overwrite the old one.  If it's misspelled or misunderstood, it will usually tell you what the allowed values are.  When you are done changing parameters, you have to hit :q to save the changes and exit (this strange syntax comes from the vi editor; are you sure you want to learn vi?).  Then you just execute the task again. 

 

When you are done with iraf, type logout to return to the unix prompt.

 

 

III.                     IRAF EXERCISES

 

As long as you have a sample fits image to play with, you should be able to sit down with the documentation available in the room or with the on-line help and become an expert with the two most important and frequently used tasks:  implot and display.  Practice with them until they make sense, and then start reading the help files and see what else you can do with them.

 

1.         Make a working directory in your ASTR377 directory.  Copy all of the fits files from /coolstar/neffj/ASTR377/ into your working directory.  Change to your Iraf directory, start up iraf, then cd back to your working directory.

2.         Work though the examples in the Beginners Guide to Iraf  documents (hardcopies can be found on the shelf, or you can print out your own, or you can use this on-line version).

3.         When you are done with that, start looking at the data in your working directory.  Use imhead to identify which are the bias frames.  Use imstat to determine the average bias level. Not sure how to use these?  Try reading the help pages.

4.         Using implot and display, make 3 plots of the row and column behavior of the bias.  Average at least 10 or 20 rows/columns near the edge and through the middle of the chip.  Turn in a series of plots and comment on what you see.  Reconcile these plots with the bias level you determined in question 3.

5.         Using imexamin and the j, k, r or other suitable options, determine the FWHM of the stars in one of the images.  (This takes a little practice, and there are flakey aspects that are best learned by doing.  Feel free to ask around and share notes.) Record and turn in your results.  Your values will be in pixels.  Later we will determine the conversion from pixels to arc seconds for this detector/telescope combination.  The width of the star images is a combined measure of the atmospheric "seeing" and telescope focus.  Was the telescope focused and collimated well when these data were obtained?  How can you tell?

6.         Adjust the grayscale to make the best hardcopy you can of an image with stars in it.  Turn this in, too, and describe how you adjusted the gray scale.

 

 

IV.                     LEARNING MORE

 

The next step, which you can do on your own time (but soon), is to read through and work through the Users Guide to CCD Reductions with IRAF. 

 

The main source of information is the on-line help files built into iraf.  There are some on-line tutorials that might help.

 

The notebook in 145 has a complete set of the main iraf documents.  The entire set, along with a lot of other useful information and a users support group can be found at iraf.noao.edu.