sot/agasc

Consider bias offset in dark subtraction

Closed this issue · 3 comments

The case of 723651200 shows that our dark current subtraction is not working well at low levels. This is a very faint star, likely close to 12.0 mag. This is early mission 2005 and it is tracked nearly 100%. The reported ACA mag is around 12.0, but the AGASC supplement estimated mag is 14.0. A true mag of 14.0 is not credible and this would not be tracked by the ACA.

[EDIT] - looking at this again I'm just confused and I'm not sure the math is right.

This is illustrated here:

# Image in e-/readout
In [52]: iok[-1]['IMG'].filled() * 5                                                                                        
Out[52]: 
array([[  0., -10.,   0., 135., -15., -10.,   0.,   0.],
       [-10., 255., -10.,   0.,   0.,  25.,  35.,   0.],
       [ -5., 190.,   0.,  35.,  35.,   0.,   5.,  25.],
       [  0.,   0., 115., 295., 310.,  65.,   0.,   0.],
       [  0.,   0., 170., 220., 265.,  90.,   0.,   0.],
       [ 70., -15.,   0., 135., 165.,  20.,  70.,   0.],
       [-25., -15.,   5.,  25.,   0.,   5., -10., -15.],
       [-10., -15.,   0.,   0.,   0.,   0., -10.,   0.]])

# Dark cal in e-/readout
In [53]: dc.aca[379:379+8, -458:-458+8] * 1.7                                                                               
Out[53]: 
<ACAImage row0=379 col0=-458
array([[ 39,  28,  26, 197,  25,  23,  16,   2],
       [ 14, 347,  33,  16,  21,  26,  76,  30],
       [ 14, 123,  12,  12,  23,  19,  23,  28],
       [ 16,  11,  35,  51,  14,  14,  12,  14],
       [ 25,  11,  11,  49,  14,   9,  14,  12],
       [ 62,   4,  11,  12,  85,  26, 141,  12],
       [ 21,   7,  11,   9,   9,  23,   9,  16],
       [  9,  19,  23,  14,  23,  12,  18,  12]])>

One idea we have discussed before (esp. for the aspect pipeline) is subtracting a bias offset from the scaled dark cal. It may well be that the on-board bias subtraction by the CCD readout electronics is not stable or we don't understand it. The intent of the designers was always that algorithms would use some sort of mean dark subtraction based on corner or edge pixels.

For instance, we could determine a bias offset for 8x8 images by:

  • Compute the difference of the 28 edge pixels
  • Discard the highest 8 and lowest 8 (TBR) differences. This is intended to account for star light in the edge pixels and errors in the dark cal. Maybe it doesn't need to symmetric, e.g. only discard the 2 lowest values.
  • Take the mean of the remaining values.

Doing this for this star seems to work and gives a more reasonable mag estimate of 12.0 mag. (Caveat - I didn't do the high/low clipping).

Now I understand this. There is a bug in the code:

    img_sub.mask *= MASK['mouse_bit']

The masked elements are True, so this should be (with a reminder to never use arithmetic operations on a boolean value):

    img_sub.mask |= MASK['mouse_bit']

So all of the mags are being computed with the full 8x8 image, so the bias offset effect is much larger due to the 28 edge pixels in the 8x8 readout. After fixing this bug the computed mag is 12.7, which is close enough to 12.0 that we may not need to do the bias offset computation.

The issue with the wrongly-used mask was fixed. I just ran the script on it and the estimated mag is 12.2 and the plot looks fine to me, so I think this issue can be closed.

Incidentally... while doing this, I noticed that this star is not in the current mags table. I wonder if there are others missing and why.

Sounds good, closing.