The Antioch ESPACE Academy is a local and regional center for standards-based astronomy education at all grade levels.

The Academy provides students with a motivational venue for learning about science through research or outreach oriented projects based on instruction in earth science, astronomy and space science.

 

Site Map

 
 

SPITZER SPACE TELESCOPE
AGN Project
tt

t

Quick Links

 

These notes are also posted here:

http://homepage.mac.com/astronomyteacher/documents/iraf.html

 

Installing and Using IRAF
to prepare images for use with HOU's Image Processing software

This page details the technical problems and solutions encountered while trying to prepare images from the TLRBSE project's Teacher Observing Program, which yielded images from a 0.9 meter telescope at Kitt Peak National Observatory.

Background (purpose of the project)

Installing IRAF

Bit depth of FITS images

Using IRAF to convert images' bit depth

Opening images with HOU Image Processing Software

=====

Background

The information in this section was published as an article at the web site Low End Mac.

Recently two of my students were selected to participate in the Teacher Observing Program at Kitt Peak National Observatory, through a program sponsored by the National Optical Astronomy Observatory in Tucson, Arizona. This involved making a proposal for the use of a 36" telescope (for you non-astronomers, that means bigger than what most amateurs own, but on the small end of professional-class scopes). My students suggested observing BL Lac, a blazar or active galactic nucleus, and various globular clusters to observe RR Lyrae variables. A brief overview of our experience is posted here (http://www.noao.edu/outreach/tlrbse/top-200410.html). The purpose of this article is to describe the technical problems we encountered and solved along the way, providing assistance to others who may face similar problems and to make comments about the state of advanced scientific software for the Macintosh.


The task

When using professional-class telescopes, astronomers are interested in isolating the true signal from an object being imaged from the noise or interference in the telescope and camera which can obscure the thing you're trying to measure. Telescopes use CCD cameras similar to those used in digital cameras, but they require careful calibration to remove these sources of unwanted signal. Calibration of the camera involves taking "bias frames" to show how electrical signals used to read the camera's picture may provide false spots in the image, and "flat frames" which are pictures of blank white spots on the observatory wall to show how dust in the optical path may cast shadows on the image making parts of the image artificially brighter or dimmer than it would otherwise appear. In practice a user must apply these corrections to each picture taken to remove these unwanted signals so the remaining image is pure signal with no static, so to speak. Then measurements of brightness and other characteristics can be taken which are scientifically meaningful.


An excellent tutorial on the details of this process is located here:
http://www.astro.ufl.edu/~oliver/ast3722/lectures/CCDImaging/CCDimaging.htm.
Using the camera, then, provided us with a collection of dark frames, bias frames, and "raw" images of our various target objects. Our task was to combine these into a single calibrated image, and then take measurements.

All of the images generated by this program are in FITS format. FITS is a file format which preserves the original data as read out on the chip in the camera. Unlike jpegs or other formats, altering the appearance of a FITS file does not alter the original data, just how it is displayed. This is pretty much a universal standard among professional astronomers.
More about FITS format here: http://fits.gsfc.nasa.gov/fits_home.html

All of our computers were Mac laptops. We had access to the following pieces of software. Links are included to the sources users can get to these. The limitations of each piece of software is noted.
NIH Image, This freeware program for Mac OS 9 can open FITS files, but requires customized Pascal-like macros to do basic astronomical functions such as brightness counts (adding up the counts detected in each pixel of a star's image). The macros available for us to use (from the Teacher Leaders in Research Based Education project--not available for download) would not open the images provided by the telescope we used.

Image processing: This program from the Hands-On Universe project could open FITS files we'd collected in other places (if you ignored some user warnings, etc.) Unfortunately it would not open images we took ourselves at the Kitt Peak telescope.

Image J: This Java-based successor to NIH Image opens everything just fine, but doesn't yet have the specialized macros needed by amateur and professional astronomers to perform measurements. I got a copy of a beta set of macros under development, but it isn't functional yet. Like NIH Image, most plugins and macros available on the web are aimed at medical applications.


IRAF: This UNIX-based program is what is used by most professional astronomers to analyze images. It is very powerful, difficult to use, and uses many arcane text-based commands similar to UNIX commands. Installing it is not a simple task, but it is doable. An experienced power user who encounters no problems can finish the installation in about two hours. I encountered problems, so it took perhaps three days of off-and-on work to solve all the issues before IRAF became functional. This was only possible at all because of the very thorough and well-written set of instructions at Marcos Huerta's web site.

This points out a common problem with science software for the Mac. Many professional astronomers use Macs, because they need easy access to UNIX. I've met several myself who use them for exactly that reason. These programs represent the low-end of the spectrum (such as NIH Image) where programs are available, but in some limited way or for specialized educational purposes. At the other end is the high-powered IRAF, which does anything, but has a steep learning curve. There isn't anything in the middle for Mac users equivalent to a program like, for example, Maxim DL for the PC, which is what most amateur astronomers are using these days for this kind of work.

Mac users wanting to work with Maxim DL have no choice but to use Virtual PC, which is pretty much an advertisement for getting a real PC--just functional enough to run real PC software, just slow enough to be annoying to the point of wanting a real machine. This is why I say Mac astronomical image processing software is polarized. There's the low-end educational versions (great at what they are designed for, but limited) and then there's the highest end there is (IRAF--which, by the way, doesn't run in Windows at all), but there's nothing in between.

There are a number of programs which show promise but are not complete packages. The most useful of these is Keith's Image Stacker which can be used to combine bias and dark frames as well as "stack" images to enhance contrast. You cannot take measurements such as brightness counts with KIS, however, and my experience was it could not open my FITS files for technical reasons I'll explain in a separate article. For what it does, it is really useful, but it doesn't do exactly what I need, which is sort of in a gray area between amateur and professional needs.


There has been an ongoing discussion thread about these and other astronomical issues sponsored by the Applelust site (http://lists.topica.com/lists/hubble_boy). If you are interested in astronomy and use a Mac, you should subscribe, and read the astronomy related articles posted at Applelust.

In the remainder of this document I detail how I installed IRAF using Huerta's instructions and help files, and then how I managed to convert the images from the format we got them into a format our older software at school could read, plus how we generated some preliminary data from the images.

Installing IRAF

Image Reduction for Astronomy Facility (IRAF) is a professional-level astronomy program used by most professional astronomers for data reduction. It will install in OS X, but not in Windows. I used Marcos Huerta's excellent instructions and installer packages from this site:

http://www.owlnet.rice.edu/~marcosh/iraf/

I am not going to attempt to improve on his excellent instructions, but just provide some notes about how it went when I tried it. Everything went pretty well, more or less, with just a couple of exceptions. As his instructions indicated, you must go into the System Preferences for Accounts, and create a user named "iraf."

In step 2 (http://www.owlnet.rice.edu/~marcosh/iraf/iraf.html) he suggests that you download the installer while in your normal account but then put it in /Users/You/Public so the "iraf" user can get to it. This did not work for me because of permission issues, and I had to download and install it at the root level of the hard drive. This is the directory you get when you double-click on the Macintosh HD icon on your desktop. It is not inside of any particular user's folder.

Later on Huerta notes that in Mac OS X 10.1 and 10.3, you may get some weird error. I did, and because he said to ignore it, I did, and as predicted, it worked anyway.

When you are instructed to use the Terminal, you will be typing some UNIX commands such as cd (change directory) and sudo. These are extremely sensitive to syntax. If a command ends in a slash, don't leave it off. If there is a space between a character and a slash, don't leave it out. Once the installer runs, don't move any files around.

When performing the mkiraf command, a script is run which tries to install everything in subdirectories preset within directories which all refer to each other later, so don't try to install it in a "convenient" location. Mine didn't work; as it turned out, I had permissions issues. If your install says a series of "command not recognized" after each step, the script didn't work. I eventually resorted to using the FAQ (question # 8) http://www.owlnet.rice.edu/~marcosh/iraf/faq.html#q8.

Following these directions seemed to repair the permissions flaw, which, for whatever reason, caused the installer to run incorrectly.

In the next major step, The X11Iraf package is installed. This installed correctly, but I did have to follow the instructions for editing and creating a file called .cshrc for this. This file must exist in the directory you use to start IRAF. The instructions on the site tell you how to tell if this is set incorrectly, and refer you to a "Unix for Newbies" page for instructions on how to fix the problem. I did, so my advice is : don't skip the "You might have to" sections. Look for the part of the instructions on this page which says "You have to edit your .cshrc or .tcshrc file to fix this." I had to.

Everything else went pretty well, but as some of the astronomers I worked with told me, using IRAF is fine when it works. Fixing things is part finding good instructions, part intuition, and part reading between the lines. Knowing just a little UNIX doesn't hurt either. While running in the terminal, I used the following commands frequently and independently of the "just type it like I said to" instructions on the web page.

ls (list files in the current directory)

cd .. (move one level up in the directory heirarchy)

cd directory name (move to the directory named, if it exists within the current directory. sd

The UNIX for Newbies page at Huerta's site tells you many other commands you might need.

I also recommend installing Huerta's "IRAF Button" application, which autolaunches not only the IRAF application and the X11 environment, but other support software such as the graphic display software called DS9. I had an issue involved with the placement of the .cshrc file not being in the user level directory (/Users/yourname/) where I would usually be when running IRAF. This took a little while to figure out, but eventually, after erasing everything, deleting the iraf user, and starting over, I managed to run the installer packages exactly as described on Huerta's site (when he says to be in a certain account when installing, believe him) to make everything function correctly.

Make sure you install the xgterm application as IRAF is really not useful without it. I also installed the "popular graphic package" on the download page. There is a lot of talk about OroborosX and ximtool; these are only options. I used X11 which is from Apple, and it worked fine.

If you've done everything correctly, when you run "The IRAF button" then you should see a screen that looks more or less like this:

Click on the image for a magnified view.

The IRAF Button application is in the lower left corner. IRAF itself is running in the upper left within xgterm. IRAF is actually a text-only program and requires an external viewer such as DS9 (shown on the right) to display images. The two applications talk to each other and can feed data into subroutines and functions as you work.

Bit depth of FITS images

Like most other graphic formats, FITS is not a single one-size fits all protocol. It can handle a variety of bit depths. Bit depth refers to the number of bits in the number variables used to store data from each pixel. An image with a bit depth of 1 is black and white. Each pixel can either be a 1 or a 0, which requires only 1 bit. Mac Classic computers (the kind with the old 9" screen) had a bit depth of 1. Most amateur class cameras generate images with a bit depth of 8 or 16, corresponding to 256 or thousands of colors. Many of the common programs available to educators open one or the other of these formats, sometimes not both (depending on what the developer of the software usually uses). Professional level cameras can generate images with millions of shades of grey (too many for monitors to display or your eyes to discern even if your monitor could display them.) This is one of the reasons false color is used in image processing, because it brings out detailt to subtle to recognize with the more realistic looking greyscale images.

IRAF can be used for any kind of image processing. Ostensibly I should have used it to take our bias images and flats taken by my students Robert Johnson and Tri Nguyen at the 0.9 meter telescope (details are here) and used IRAF to calibrate or reduce the images to a form which could be measured. While I struggled with installing IRAF, NOAO astronomer Katy Garmany calibrated the images for us using IRAF, so I left that task to be learned another day. Once she generated calibrated images, however, we discovered they would not open in the Hands On Universe program Image Processing which we usually use for collecting data from images. I eventually determined this was because the HOU software requires a 16 bit unsigned image and the FITS images were 32 bit images.

Signed images remove one bit from the color depth data and use it to signify positive or negative values. There is a thorough discussion of this issue at this web site: http://www.rwc.uc.edu/koehler/comath/13.html .

My task therefore became to convert the calibrated images from Dr. Garmany into a lower bit depth where our software could open and read the information. We could have used IRAF for the measurements, but as I only have one or two computers capable of running IRAF, and I have 15 which can run the older software, I opted to convert the data so more students could work simultaneously.

If you want to know how to persuade IRAF to do data reduction of raw images, there is a tutorial written for another project posted here: http://www.nuro.nau.edu/nuro/info/iraf.html. I haven't tried it yet but it looks like it is pretty straightforward, written for brave beginners.

Conversion of bit depth using IRAF

Here are the steps I used to prepare my images for student use. To begin with:

The original images are in a directory I could find easily.

IRAF is installed and running properly.

In the following instructions type exactly what is between the brackets [ ] but don't type the brackets themselves.

Using UNIX commands at the cl> prompt, navigate to the the directory with the images. Type [ls] to list the directory, [cd ..] to go one level higher in the heirarchy, and [cd foldername] to move into a folder. For example you might type [ls], press return, [cd ..] and press return, [cd ..] and press return again to go two levels higher in the directory tree, then [cd images] to move into the directory images. The exact sequence of commands you type will depend on precisely where you have installed IRAF and where the images are stored on your computer. It is very similar to DOS commands or Apple II file commands if you're old enough to remember that.

Verify you can see the files to be converted by typing [ls]. There shouldn't be anything else in the directory except the images you wish to convert.

1. In the IRAF window, type [noao].
Note, due to the way X11 and xgterm work your cursor must be in the window before typing letters will appear on the screen.

2. Then type [imred].

3. Next type [ccdred].

4. Now type [epar ccdlist]. This means you will EDit the PARameters of the function. Using arrow keys to move up and down and return to make changes, change the filename to [*.fits] which will use a wildcard to select all of the images in the directory.

5. Set the ccdtype to [object].

6. Type a colon -q [:q] to exit the epar subroutine.

7. Enter [ccdlist > filename] where filename is the name of a text file to which all the files you've selected will be listed. This shows the real power of IRAF--batch processing. If a professional has hundreds of images they can all be manipulated at once like this. I expect the calibration steps are done in a similar way.

8. Now a new file will appear in your image directory containing a list of all the images you wish to convert.

9. Next do [epar wfits].

10. Set fits source files to [@filename] where [filename] is the same exact name of the list you just made.

11. Set fits file to new name such as [16bitconverted]. This phrase will be appended to the new files as they are written. The old filename will still be there so you can tell which is which. Each file will be numbered in the sequence it is done.

12. Set bi = [16]. (This is the whole reason we went through this.

14. Type [:q] to exit epar, then execute the wfits command by typing [wfits]. If everything is setup OK, all the files will convert. Large files take a few seconds each on a 1 GHz TiBook.

You're done with this step!

Opening files with HOU Image Processing.

This is for users of the HOU program Image Processing. You can now open 16 bit files generated by IRAF from professional-grade cameras. All you have to do is:

1. Always open from the file menu, not by double-clicking.

2. Don't use the "recently opened" menu to open files. Doesn't work.

3. Don't panic when the software says "Unrecognized format. Opening as FITS". It'll work.

4. Then you can do brightness counts on stars, draw slices to get distances, etc. You can even read the FITS header if necessary.

When I learn how to reduce images using IRAF, I'll write that up as well, but it may take a while...

If you found any of this useful, I'd appreciate a note. Enjoy!

P.S. Don't move or rename files in the directory after making the list, or the process will abort in the middle.

 

 


Jeff Adkins, Director
astronomyteacher@mac.com

Cheryl Domenichelli, Assistant Director
cheryldomenichelli@antioch.k12.ca.us

4700 Lone Tree Way
Antioch, CA 94531

The ESPACE Academy is sponsored in part by a grant from the California Department of Education's Specialized Secondary Program.