# Hot pixels and cosmic rays

You have learned that the number of counts in each pixel tends to rise linearly with time, due to electrons knocked free in the silicon lattice. When we take pictures of real celestial objects, we want to remove this "dark current" so that it doesn't contaminate our measurements of the brightness of stars. But how can we do that?

#### First try: subtract the mean value

Consider the 1-second warm dark frames: dark1-001d.fit, dark1-002d.fit, dark1-003d.fit. We want to get rid of the thermal contribution. Maybe we can just find the mean value, and subtract that.

1. Make a copy of the image dark1-001d.fit for trial purposes:

cp dark1-001d.fit test.fit

2. Measure the mean and standard deviation of pixel values in this dark frame. Write them down.

3. Measure the mean value in image dark1-002d.fit. Suppose that it is 210 counts.

4. Subtract this value from all pixels in the test image like so:

sub test.fit const=210

where you substitute your actual measured mean value for the "210" above.

5. Now measure the mean and standard deviation of the test.fit image, after the mean value of another dark frame has been subtracted. How does the new mean value compare to the original mean value? How does the new standard deviation compare to the original mean value?

6. Display the test.fit image, and look at it critically.

We hope to see a subtracted image which has values of exactly zero everywhere. How well did this idea work?

#### Second try: subtract one image from the next

Okay, that wasn't so great. Maybe it would be better to work on a pixel-by-pixel basis. Let's try subtracting one image directly from another:

1. Make a copy of the image dark1-001d.fit for trial purposes:

cp dark1-001d.fit test.fit

2. Subtract the image dark1-002d.fit from the test image like so:

sub test.fit dark1-002d.fit

3. Now measure the mean and standard deviation of the test.fit image. How does the new mean value compare to the original mean value? How does the new standard deviation compare to the original mean value?
4. Display the test.fit image, and look at it critically.

Is this result all zeroes? Is it better than the first attempt? Can you be quantitative?

If you look carefully, you should see at least one pixel which is way, way, way above zero. Hint: consider changing the contrast of the image like so:

tv test.fit z=0 l=200
1. What is the location (row, col) of this pixel?
2. What is its value in the subtracted image?
3. How does this value compare to the standard deviation of pixel values in the subtracted image?

The problem is that every now and then, a cosmic ray particle flies through the CCD detector and knocks lots of electrons loose. These events occur at random times and intervals, so you can't predict them. They are very hard to remove ...