Creative Commons License Copyright © Michael Richmond. This work is licensed under a Creative Commons License.

Optical CCD image analysis, day 1

Today is the first of a two-part series of exercises in which you will analyze some optical CCD data taken by at the RIT Observatory. You can find the images we'll be using at

The goal today is to convert a series of "raw" CCD images, with all their defects, into a series of "clean" CCD images. We can then measure properties of stars in the "clean" CCD images in our next meeting.

raw dark-subtracted dark-subtracted and flat-fielded


Connecting to the analysis computer

Each student will log into the same computer to run the image analysis code. The computer's name is spiff.rit.edu, and the instructor will give you the login name and password in class. Your first job is to run the software needed to log into the computer remotely, and set up an X-Windows session so that programs running on the remote computer can display images and text on your laptop's screen.

The exact command(s) will depend on your OS. As a rough guide,

To check that the connection has been made properly, try running this command as soon as you have logged in:


     xclock

If, after a short pause, a window pops up on your screen, showing the face of a clock, then all is well, and you may proceed. If not, ask the instructor or a classmate for help. To kill the clock, type "Control-C" (hold down "Control" key and press "c") in the terminal window.

Your next task is to find your special directory (folder) on the analysis computer. Each student will have a directory for that student's own use; all the data you analyze and modify will live inside that directory and its sub-directories. The Unix command ls prints a list of the contents of the current directory. When you have logged into spiff, you should see a prompt that looks something like this:



    stu@cos-phy606:~$ 

If you type ls, you should see that the only two items in this home directory are sub-directories named ast613 and bin. You can move to the directory ast613 by typing the cd command:



    cd ast613

If you once again type ls, you will see that THIS directory contains a set of sub-directories:



bloggs  dunn       fall_2020  fall_2022  hutchins  kearney  martinez  richmond
butler  fall_2019  fall_2021  flayhart   ji        klyde    ramsey

Now, use the cd command once more to change into your own directory. In my case, I would type



    cd richmond

In this, your own private directory, you should find a large set of raw FITS files. Those are the items we will analyze.


Check the raw images

To begin, let's check some properties of the raw FITS images. There are about 72 images, but each one is pretty small (only 510 x 340 pixels), so the total size of the dataset is only around 38 Megabytes. If you ever happen to delete or mutilate these images, you can grab a fresh set from this zip archive:

You can print the FITS header of an image in two ways; in the example below, I'll use the image asas14clclear-100.fit.

Part 1:

  1. How many dark images are there? Do they all have the same exposure time?
  2. How many flatfield images are there?
  3. How many images of our target, ASASSN-14cl, are there?
  4. Where is this star in the sky? Use SIMBAD or some other tool to look up the RA and Dec. Write them down.
  5. Make a finding chart for this star, using Aladin or some other tool. Choose a field of view roughly 0.35 x 0.35 degrees = 20 x 20 arcminutes. If you can, choose the "DSS2 " passband, or at least a "red" image rather than a "blue" one. Compare the picture in your chart to the picture below, based on one of the images in our set. Which star is ASASSN-14cl? Circle it in the image below.

When you have answered these questions, please inform the instructor. Look around to see if you can help any of your neighbors.


Playing with the images

We will use a suite of image processing programs called the XVista package to examine, modify, and measure properties of the FITS images. XVista is free and open-source, but I don't recommend that you use it unless you want to dive into the source code. But it will allow us to perform some simple analysis for this class.

You can find a short tutorial on some of the XVista commands at

I have set up things for you so that you should not need to carry out the items mentioned in the "A few preliminaries" section. In general, typing the name of a command, followed by "help", will often provide some information on the arguments for the command. For example, try typing tv help .

To begin, experiment with the XVista commands and options to make sure you can display an image.

The tv command will create a new window and fill it with the pixel data from a FITS image. In simplest form,



              tv asas14clclear-100.fit 

          

You can change the contrast settings with additional arguments; for example, the following command will set pixels less than 1000 to pure black, and pixels greater than (1000 + 300) to pure white.



              tv asas14clclear-100.fit z=1000 l=300 

          

I prefer to display images with black stars on a white background, which can be done by using the "invert" argument just once:



              tv asas14clclear-100.fit z=1000 l=800 invert

          

As you move your cursor in this image window, the current pixel location, and the current pixel value, will be shown in the lower-left corner of the window.

You can create a new window which zooms in on the current location of the cursor by pressing the "z" key. For example, if I move my cursor to the bright star near (40, 106), and press "z", I will cause this new window to appear:

If you have a mouse, you can change the contrast settings interactively by pressing and holding the middle mouse button while moving the cursor across the window.

When you are done with a window, you can delete it either by using your OS's window manager -- the little "X" in the upper corner of the image on Windows, or the red dot in the upper corner of the image on Mac OS -- or you can simply right-click while inside the window.

Pick just one of the target images: asas14clclear-100.fit, which I'll call "target image 100" for short. Look at the FITS header of this image and answer the following questions.

Part 2:

  1. What date was this taken?
  2. How long was the exposure?
  3. Now for a few questions that require you to put on your thinking caps.

  4. What is the image orientation? In other words, using the default view, which way is North and which way East?
  5. How many arcseconds per pixel? Since there are no CDELT1 or CDELT2 keywords in the FITS header, you'll have to figure this out the old fashioned way:

When you have answered these questions, please inform the instructor. Look around to see if you can help any of your neighbors.


Creating master dark frames

If we take a picture with the shutter closed, our camera SHOULD record an image which is completely empty -- no signal at all. Right? But CCDs don't work that way. Even if no light hits the silicon, electrons can still be knocked free by thermal motions of the atoms.

Let's find out just how large a signal is created this way.

First, let's display one of the raw, 1-second dark frames:



    tv dark1-001.fit  z=160 l=100

Note the "salt-and-pepper" appearance of the image, which is due to small variations from one pixel to the next. Some of these variations are due to random noise in the readout process, and in the thermal motions of atoms; but some are systematic, and will appear in every dark frame. One way to measure the pixel-to-pixel variations is with XVista's mn command, which computes the mean and standard deviation of all the pixels in an image:



    mn dark1-001.fit

We can reduce the random noise, and enhance the systematic effects, by combining 10 individual 1-second dark exposures to create a "master" dark frame:



       median dark1-*fit outfile=master_dark1.fit

We can display this image so it's easy to compare to the individual dark frame (the "xo=600" argument places this new window 600 pixels away from the left edge of your screen).



    tv master_dark1.fit z=160 l=100 xo=600

We can compute the statistical properties of this "master" dark image using the mn command on it:



    mn master_dark1.fit

Part 3:

  1. What is the mean pixel value, and the standard deviation from the mean, in this 1-second master dark?

There is also a series of 10 dark images with a longer, 30-second exposure time. Use the same steps to create a "master" 20-second dark image, called master_dark30.fit.

  1. What is the mean pixel value, and the standard deviation from the mean, in this 30-second master dark?
  2. How do the pixel values change in dark images when the exposure time increases? Does that make sense?

If you want to investigate the behavior of the dark current in more detail, the XVista command hist will create a text file with a count of the number of pixels with each pixel value. For example,



    hist master_dark30.fit

		  Mean  adus     207.86
		  Total adus 36043331.000000
		  Max.  adus   25131 at row= 172  col=485 
		  Min.  adus  -32454 at row= 157  col=311
		  Total     pixels 173400.000000
		  Overflow  pixels          0
		  Underflow pixels          1
		  Standard deviation =     132.08
		  Median        198  adus  *** warning underflow
		  Mode          198  adus  *** warning underflow


    more master_dark20.his

       0                0 0.000
      29                0 0.000
      30                1 0.000
      31                0 0.000
      62                0 0.000
      63                1 0.000
      64                0 0.000
      97                0 0.000
      98                1 0.000
      99                0 0.000
     141                0 0.000
     142                2 0.000
     143                0 0.000

        (etc.)

  1. (optional) Make a histogram of the master 1-second dark frame, and a histogram of the master 20-second dark frame. Describe any differences you see.

When you have answered these questions, please inform the instructor. Look around to see if you can help any of your neighbors.


Creating a master flatfield image

What should happen if we take an image of a blank white, uniformly lit card? We SHOULD see a picture which has the same pixel values everywhere -- nice, uniform, white (or maybe grey) pixels, all the same.

But if you take a real picture with a real CCD, attached to a real telescope, you will usually see something quite different. Something which is NOT uniform at all!

Typically, these "flatfield" images show evidence for several types of defects:

If we can make a map of these defects, then we can correct for them later. Let's try that with data from this evening. I took pictures of the twilight sky, just after sunset, when it was still too bright to show (many) stars. There is a set of 10 images, all with names like flatclear-001.fit.

The procedure for creating the "master" flatfield frame involves two steps:

  1. subtract the appropriate master dark frame from each raw flatfield image
  2. combine all the dark-subtracted flatfield images to create the "master" flatfield image

Let's carry out each step in turn, but pause between them to examine the intermediate products.

Part 4

  1. What is the exposure time of these flatfield images?
  2. Which master dark frame should we use to correct them?
  3. For each of the 10 raw flatfield images, create a dark-subtracted version. I'll show an example for the first flatfield frame, but you should do it for all 10 of them. (Hint: typing the up-arrow key will show the previous command, and the left-arrow key will allow you to edit that command before executing it)
    
    
                  sub flatclear-001.fit master_dark1.fit outfile=flatclear-001_sub.fit
    
              
  4. The result should be a set of new, dark-subtracted images, each with a filename ending in "_sub.fit".

  5. Do the dark-subtracted images look different to your eyes?
  6. Now, combine all 10 of the dark-subtracted flatfield images to create the "master" flat:
    
    
                  median flatclear-*_sub.fit outfile=master_flatclear.fit
    
              
  7. compute the mean and standard deviation from the mean of the master flatfield image
  8. (optional) use the hist command on the master flatfield image, and then examine the master_flatclear.his file to determine properties of distribution of pixel values in it

When you have answered these questions, please inform the instructor. Look around to see if you can help any of your neighbors.


Clean those target images!

Okay, we're ready for the big step: we are going to clean the target images. Our procedure will be equivalent to these mathematical steps:



       Step 1:      subtract appropriate master dark

       Step 2:      divide by a normalized version of master flat


We could also write that, on a pixel-by-pixel basis, we will do this:



                              raw(i,j) - master_dark(i,j)
  clean pixel (i,j)  =   [ --------------------------------- ]  * FLATMEAN
                                   master_flat(i,j)


where FLATMEAN is the mean pixel value in the master flatfield image.

Here are the commands you can run to perform these calculations on the raw ASASSN-14cl images. I'll use just one image as an example, but each student should pick a set of 5 consecutive images (for example, numbers 100 - 120, or 040 - 060) and do this for all 5 of them. The commands I show below will place the "cleaned" images into a sub-directory called "clean"; that will keep things organized for later analysis.

Part 5:

  1. Which images will you process? Write down your choice of the 5 image indices.
  2. Execute the following command for each raw image to create a dark-subtracted version:
    
    
                  sub asas14clclear-100.fit master_dark30.fit outfile=asas14clclear-100_sub.fit
              
  3. Use the tv command to display one of the raw images, and its dark-subtracted countpart. Arrange the two windows to be side-by-side. Do they look different? If so, how?
  4. Can you explain this difference in appearance?
  5. Now, execute the following command to divide the dark-subtracted images by a normalized copy of the master flatfield; the cleaned versions will be placed into the clean subdirectory.
    
    
                  div asas14clclear-100_sub.fit master_flatclear.fit flat outfile=clean/asas14clclear-100_clean.fit
    
              
  6. Use the tv command to display one of the raw images, and to display its cleaned version. Arrange the two windows to be side-by-side. Do they look different? If so, how?

The result should be that a set of nice-looking images appears in your clean sub-directory. These images should be mostly free of hot pixels, and mostly free of obvious flat-field image defects.

If your images still look crummy, check with the instructor.

When you have answered these questions, please inform the instructor. Look around to see if you can help any of your neighbors.


Measure the clean images

Okay, you have a set of clean images showing ASASSN-14cl and a bunch of other stars. Good! We'll deal with photometry next time, so for now, just measure some image properties and get ready for the science. Choose one of your clean images and examine it to answer the following questions.

Part 6:

  1. What is the typical pixel value in the star-free background regions of your clean images?
  2. What is the source of this "background sky" light?
  3. Which star is ASASSN-14cl? Make a chart and label on it ASASSN-14cl and 3 stars of similar brightness; call those comparison stars "A", "B" and "C".
  4. Measure the peak pixel value in ASASSN-14cl. What is it?
  5. Move the cursor to ASASSN-14cl and press the "r" key; a new window should pop up to display the radial profile around the target, like this:

  6. What is the FWHM of this image in pixels? What is the FWHM in arcseconds?
  7. How does the FWHM of comparison stars compare to that of ASASSN-14cl?
  8. Examine 3 other images in your set. Does the FWHM change much from image to image?


For more information


Creative Commons License Copyright © Michael Richmond. This work is licensed under a Creative Commons License.