Reducing your images

The instruments we use to take images leave blemishes or "artifacts" on the images. Over the past 20 years, CCD cameras have been improved so that they leave very few artifacts in the images, but they are still imperfect. It's important for us to remove these artifacts from the images before we try to get a scientific result out of the images. There are two main types of corrections we have to make to the "raw" images: a bias correction and a flat field correction. The process of making these corrections to your images is called reducing your data.

Getting started

You will be using some specialized software to reduce your data, called the Image Reduction and Analysis Facility, or IRAF. Ask your project advisor how to start IRAF and an image display tool. Take careful notes, because you will have to do this more than once!

When you start IRAF, you will see the IRAF "prompt", which looks like this: cl>. IRAF is a "command line" tool, which means you type your commands after this prompt. Some important commands to know:

Important note: whenever a word appears in brackets in this project, you should not actually type the word or the brackets. Instead, substitute in the correct name. For example, if I had a file called "myimage.fits" and I wanted it to be named "yourimage.fits", I would do this:

cl> rename myimage.fits yourimage.fits

Before you start your image reduction, take some time to learn how to display your images. Find out the names of your cluster images. You may have to look at the observing log to find them out. On the IRAF command line, type the following to display your images:

cl> display [IMAGE_NAME1] 1
cl> display [IMAGE_NAME2] 2

This tells IRAF to display your images into frames 1 and 2. There are four frames you can display your images into. By displaying images into different frames, you can "blink" back and forth between them to compare them. This will be helpful later on.

Play around with your display window for a while before moving on. Put your cursor on top of the image in the window. Press down on your mouse buttons and the following will happen:

Now play around with the buttons and menus in your display window. Click on "Frame" and you'll see a button that allows you to "blink" back and forth between your images. Click on " Zoom" and you'll be able to zoom in and out and re-center your image. Click on "Color" and you'll be able to display your image in different colors instead of the default set of gray colors.

If at any point you're confused about how to do these things, your project adviser will help! Your adviser can also show you how to use the menus at the top of your display window, and explain those two tiny images in the upper right corner.

As you look at your raw images, you may see defects such as dust doughnuts and bad pixels. You will be able to correct for most of these defects.

Learning about your images

There are some commands in the IRAF that can tell you some basic information about your images. You can find out some important statistics about your image by using the image statistics command "imstatistics":

cl> imstatistics [IMAGE_NAME]

You can find some other interesting facts about your image by looking at the image header with "imhead":

cl> imhead [IMAGE_NAME]

"Imhead" tells you the size of the image as well as its title. The image titles might be "Bias" or "Flat" or "M13" - they can tell you want kind of image it is without having to look it up in the observing log.

Correcting for bias

After you take an image with a CCD camera, the camera will read the image out onto a computer where you can look at it. As the camera reads out, it adds a small amount to every pixel in the image. This is called the bias, and we need to subtract it off again. We can subtract it off because we take calibration images called "biases", which don't have any actual light on them, they just have the bias added on. The bias images show us exactly how much to subtract off from all of our other images.

A CCD camera will generally add about the same pattern to all of the images all night long. So you'll only need to make one bias correction image which you can use to correct all of your other images.

Your telescope assistant will probably have taken several bias images for you. To get the best bias correction, if you need to average all these bias frames. This will lessen the effect that any problems from a single bias exposure will have on your final correction. (Ask your project advisor about problems such as cosmic rays which can affect your bias measurements.) Combine your bias frames using the "imcombine" command by typing:

cl> epar imcombine

Edit the page that pops up to look like the image below. When you are done, type ":go" and IRAF will combine your bias images for you.

Once you're images are combined, compare a single bias exposure to the combined bias frame you just made up. Display the two frames by typing

cl> display [SINGLE_BIAS_IMAGE] 1
cl> display [COMBINED_BIAS_IMAGE] 2

Blink back and forth between the two frames to compare them. What differences can you see? Discuss them with your project advisor.

Now that we have a good measurement of how much "bias" the camera added to each of our images, we can remove it by subtracting the bias image from each of our cluster images, standard star images, and flat field images. We do this with the "imarith" (image arithmetic) command:

cl> imarith [RAW_IMAGE] - [COMBINED_BIAS_IMAGE] [CORRECTED_IMAGE]

The minus sign tells IRAF to subtract the two images. You will probably want to add a letter to the name of the raw image to mark that you have made the correction. For example, if we want to correct our cluster image, called ccd011.fits, using our combined bias image, called combined_bias.fits, and store the new image with a new letter "b" (for bias-corrected), we type:

imarith ccd011.fits - combined_bias.fits b_ccd011.fits

The resulting images should be bias corrected. Now you just need to correct your images using the flat field images.

Correcting for sensitivity: flat fields

Each pixel in a CCD camera response slightly differently to the light that shines down on it. The flat field correction you now need to make is meant to account for these small variations, to "flatten" your images. This time, instead of subtracting the images to correct them, we will divide our images by the flat field correction.

Another thing the flat field correction will correct for is the presence of "dust doughnuts" in your raw images. If the filter used to take your images has dust on it, the dust particles will block out some of the light in certain spots on your images. These spots look like doughnuts because the dust is out of focus. Partly because each filter has a different sprinkling of dust on it, you need to make a different flat field correction for each filter your images were taken in.

What sort of calibration images do you need in order to make a flat field correction? You need to expose your camera to an even amount of light all across the CCD. Since each pixel receives the same amount of light, if one pixel ends up looking brighter, it is because that pixel is more sensitive and so we should remove more light from that pixel to make it even with the others. If you had a perfect camera where every pixel responded exactly the same way to light, you would see that every pixel recorded the same number of counts in a flat field image.

Doing the flat field correction

First you have to check your flat fields to make sure they are not overexposed or "saturated". To check on this, use "imstat":

cl> imstat [FLAT_NAME]

If a flat field is saturated, the average pixel brightness will be very high, near 32,000 counts. Ask your project adviser to help you decide whether or not your flats are saturated.

Just as with your bias frames, you'll now want to average your flat fields to get the best possible measurement of your correction. Combine the non-saturated flats for each filter separately so that you'll have different corrections for images taken in different filters. Do this using the imcombine command by typing

cl> epar imcombine

Edit the page that pops up so that it looks like the figure below. When you are done, type ":go" and IRAF will combine your flats for you.

You aren't quite done yet. If you divided a cluster image by one of your flats now, you would be dividing each pixel in your cluster image by a very large number so that the resulting image wouldn't properly reflect the true brightness of your cluster. We prevent this by dividing each combined flat field by its average. Find out the average value of each of your combined flat field by using "imstat":

cl> imstat [FLAT_NAME]

Make a note of what the "MEAN" value of your image is. This is the average number of counts in a pixel of your flat field image. Then divide by that number using "imarith":

cl> imarith [FLAT_NAME] / [MEAN_VALUE] [NEW_FLAT_NAME]

Now your flat field images can be used to correct your cluster images. There is just one more step: divide each of your bias-subtracted cluster and standard star images by the flat field for the same filter as the cluster image was taken through. Use imarith to do this. Can you figure out how to do it?... if you have trouble, ask your advisor for help.

Take a look at your reduced images!

Remember how you used the image display tool to compare the individual bias image with the combined bias image? Do the same thing again, but this time, compare the raw image, before you subtracted the bias and divided by the flat field, to the final, reduced image. Do you see any differences? You can print out your images if you would like; your advisor will show you how.

Congratulations! You have just used a tool for professional astronomers to reduce real images of distant star clusters. That is not something many people can boast.