## Example of Creating a Dark Frame

Overview: In this example, we will run through a hypothetical example of creating a dark frame. The values you obtain and use will differ. For clarity, the information that the computer types out and our discussion of it is in italics.

1) First, determine the average CCD temperature for your star images. from the temperature recorded in several image headers. Take the average (Sum/N) of every fifth image (to save computing time), and call this value TCCD.

```cc> hselect *_*.imh UT,CCD-TEMP yes > ccdtemp
cc> !page ccdtemp
cc> curfit ccdtemp function=legendre order=1 power+```

Let's say the number that prints out on the bottom of the screen is -1.12045E01 = -11.20C.

2) Next, see which temperatures have dark frames available:

```cc> imhead /b1/layden/BGTEL/DARKS/DarkT*.imh
/b1/layden/BGTEL/DARKS/DarkTm03.imh[...]: Dark at T=-2.98C...
/b1/layden/BGTEL/DARKS/DarkTm09.imh[...]: Dark at T=-8.17C...
/b1/layden/BGTEL/DARKS/DarkTm12.imh[...]: Dark at T=-11.77C...```

3) The dark current increases quickly at hotter temperatures, so we must interpolate between the the dark frames with temperatures immediately above and below our CCD operating temperature, TCCD. Select from the list in Step 2 the temperatures above and below TCCD: call them T2 (above) and T1 (below). The fractional contribution of each dark frame to our final dark is then:

From Step 2, we find 'DarkTm12.imh' has a temp just below TCCD, so T1 = -11.77C, while 'DarkTm09.imh' has a temp just above TCCD, so T2 = -8.17C. Plugging into the equations above, we find f1 = 0.158 and f2 = 0.842.

4) Copy fractions of each dark to the current directory and add them together to get the final dark that is appropriate to the images we are processing. Let's say the dark frame with T1is called 'DarkTmNN.imh', and the one with T2 is called 'DarkTmMM.imh'. Note: for f1 and f2, you should enter the numbers you computed in Step 3.

```cc> epar imarith [set pixt=r, calct=r, hparams=darktime]
cc> imarith /b1/layden/BGTEL/DARKS/DarkTm12.imh * 0.842 D1.imh verb+
cc> imarith /b1/layden/BGTEL/DARKS/DarkTm09.imh * 0.158 D2.imh verb+
cc> imariht D1.imh + D2.imh LDark.imh verb+```

5) Check to see that all worked properly. If TCCD was closer to T1, then the total number of counts in LDark (the final dark frame) should be closer to the dark at T1 than at T2 (by the fractions we calculated!).

```cc> imstat *D*.imh fields="image,midpt"
D1.imh 44.77
D2.imh 14.84
LDark.imh 59.76
cc> imstat /b1/layden/BGTEL/DARKS/DarkT*.imh
/b1/layden/BGTEL/DARKS/DarkTm03.imh 211.4
/b1/layden/BGTEL/DARKS/DarkTm09.imh 93.91
/b1/layden/BGTEL/DARKS/DarkTm12.imh 53.17```

OK, we're looking good: the value for LDark (59.76) is between the values for Tm09 (93.91) and Tm12 (53.17), and is closer to the value for Tm12, just as TCCD (-11.20) is closer to T1 (-11.77) than it is to T2 (-8.17). Our interpolation has worked.

Also, the darktime for LDark should be 500 sec:

```cc> hsel *D*.imh \$I,darktime yes
D1.imh 421.
D2.imh 79.
LDark.imh 500.```

Good, it is. We should be all set to apply LDark to the skyflats and star images.

This is a tricky step. If you have any doubts, ask Andy.

Updated 2002 Jul 02 - ACL