Suppose you have a number of images of the same field. Can you combine them to create a deeper, more detailed image? The answer is "yes," of course, but how can you do it? Just how well can you align one image with another?

Moreover, if you combine **N** images with the
same exposure time, how much do you gain over a single image?
Should you expect to see stars which are **N** times fainter?

mrdeli-001.fit mrdeli-002.fit mrdeli-003.fit ... mrdeli-100.fit

There is one special image:

template.fit

All the images were taken on August 25, 2009, as part of
a study of the eclipsing binary star MR Del.
Here's the template frame, `template.fit`

In order to share the work of measuring many images, each student today will be assigned to a set of 5 images. One student will get the images

mrdeli-001.fit mrdeli-002.fit mrdeli-003.fit mrdeli-004.fit mrdeli-005.fit

another student

mrdeli-006.fit mrdeli-007.fit mrdeli-008.fit mrdeli-009.fit mrdeli-010.fit

and so on. Please make sure you know which images you will be measuring today.

The first step in aligning and stacking is to figure out just how large an offset exists between two images. We'll use the positions of the bright stars to find this offset. You'll need to measure the position, both row and column, for each of the three bright stars, in

- the template image
`template.fit` - your five images

In order to find the position of a single star,
you can display the image with the **tv**
command and then move the cursor over the star.
Press the 'a' key, and a line like this should
appear in your terminal window.

( 414.62 199.20) flux 76482.2 npix 314.5 mag 12.791 sky 98.0 [10.0 10 30]

The two numbers inside the parantheses are the star's row and column position, respectively.

Make a table which shows the positions of each of the three stars in the template image, and in each of your five images.

MR A B row col row col row col ------------------------------------------------------------------------- template first image second image third image fourth image fifth image -------------------------------------------------------------------------------

You'll see numbers which have two decimal places
after the decimal point, like `414.62`.
Does that mean that the precision of the measurement
is 0.01 pixels?
Not necessarily.
We can determine the precision of these measurements
by making one simple assumption:
**the stars aren't moving relative to each other**
during the entire night.

Suppose we measure the **offset** between two stars
in one image, both in rows and columns.
We _should_ find exactly the same offset between those
two stars in every other image;
however, due to the presence of noise, we may _actually_
find that the offsets aren't exactly the same.
Your job today is to figure out just how precise
and repeatable these measurements of position are.

Use your table of positions to make a new table,
in which you list the **offset** between star MR
and each of the other stars.

MR - A MR - B delta_row delta_col delta_row delta_col ------------------------------------------------------------------------- template first image second image third image fourth image fifth image -------------------------------------------------------------------------------

After you've filled this table,
you can compute the **mean** and **standard deviation**
of the offsets in each case.
A quick way to compute these statistical quantities
is to use the **stats** command, like this:

- What is the standard deviation in the row difference between MR and A?
- What is the standard deviation in the row difference between MR and B?
- What is the standard deviation in the col difference between MR and A?
- What is the standard deviation in the col difference between MR and B?
- How well do you think one can measure the position of a star in these images? Express your answer in pixels, and in arcseconds. Each pixel in these images is about 1.06 arcseconds on a side.

Okay, the next step is to align your images so that each one has stars in the same position as the template image. First, make a copy of each of your five images. Give each copy a name like this:

mrdeli-005.fit ---> shift-005.fit

Next, use the first table you created to determine the difference between the position of each star in the template image and the position of that star in each other image.

Difference in position (template - other) MR A B average of all three stars ---------------------------------------------------------------------------- row first col row second col row third col row fourth col row fifth col ------------------------------------------------------------------------------

You should end up with
an average value for the difference in rows,
and an average value for the difference in columns,
for each image.
Let's say that your first image is called `mrdeli-021.fit`
and looks like this:

Let's say that for this image, you find

(template - mrdeli-021.fit) delta_row = 46.41 delta_col = -23.28

In order to shift the contents of an image by a certain
distance, you can use the **imshift** command.
For example, before

imshift shift-021.fit dr=46.41 dc=-23.28

If you display the shifted image, you'll see that the stars have moved:

- Shift each of your five images by the amount required to make it match the template.
- Verify that the shifting was correct by displaying each image next to the template.
- Place a copy of each of your shifted images into a single directory like this: (the ~ is the "tilde" character)
cp shift-021.fit ~/shift cp shift-022.fit ~/shift cp shift-023.fit ~/shift (etc.)

So, now you have a set of aligned images. What can you do with them?

One way to combine them is to add them. You can try that, like so:

add shift-021.fit shift-022.fit shift-023.fit outfile=shift_sum.fit

Another way to combine them is to use the **median** command.
Be sure to include the **nomean** keyword,
since we don't want to scale the various input files this time.

median shift-021.fit shift-022.fit shift-023.fit nomean outfile=shift_median.fit

- Create both a "sum" and "median" from your aligned images.
- Look at your "sum" and "median" images. Do they show stars which are invisible in the original template image?
- Use Aladin to show the sky around the star "MR Del". Use the "Survey" called "USNO B1.0" to make an overlay on the Aladin image window. You can click on the stars shown on the overlay to find their I-band magnitudes.
- What is the magnitude of the faintest star you can see in the original template image?
- What is the magnitude of the faintest star you can see in each of your combined images?

I combined all the images taken on this night. There were 915 images, each 5 seconds long. Here's the template image:

Here's the result of ADDING all 915 images.

Here's the result of taking the MEDIAN all 915 images.

You can copy my images like so:

cp $dd/align/shift_all_sum.fit . cp $dd/align/shift_all_median.fit .

and then you can examine the images `shift_all_sum.fit`
and `shift_all_median.fit` at your leisure.

- What is the magnitude of the faintest star you can see in the shift_all_median image?
- How many magnitudes did we gain by adding 915 individual images?
- Does that correspond to a star 915 times fainter?

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