The Correct Frames Module

There are two parts of the correct frames module; the production of flat fields and biases in the postage stamp pipeline, and the correction of raw data in the frames pipeline.

Correcting Raw Frames

Frames Pipeline Inputs

The inputs to the correct frames module are:

The raw pixel data

The correct frames module can accept two forms of raw data, either complete frames (including overscan region), or subregions (which must not have overscan regions attached); the latter are used by the PSP to flat field postage stamps.

A 1-D bias vector

The bias vector must be the full width of the chip with overscan regions removed. It's scaled up by some value, TSCALE, that's specified in the header.

A 1-D inverted flat-field vector

The flat vector is the full width of the chip with overscan regions removed. It is scaled as described in the section on PSP algorithms.

A CCDPAR structure

The following elements of the CCDPAR structure are used:

The left and right bias drifts

How much the bias level of the right and left amplifiers has drifted relative to the bias vector.

Frames Pipeline Algorithms

First the entire frame is searched for saturated pixels (using a different threshold for each amplifier of two-amplifier chips), which are grouped into OBJMASKs in the MASK_SATUR mask. Because a saturated pixel may have bled into its neighbour above or below it, but the resulting pixel value may be below threshold, an additional pixel at above and below each saturated column is added to this mask. In addition, if extra_bad_satur_columns is specified in the fpParam.par file (default: 1), pixels just to the left and right of the saturated OBJMASK are treated as saturated; they appear to be contaminated by charge transfer problems in the serial register.

There are also effects that look like bias variations due to bright stars generating charge as they cross the serial register, which is as light-sensitive as any other part of the detector and is not masked on our CCDs. To remove these, we monitor the median value of the overclock and bias (extended register) pixels. While doing this, we note that the extended register was pixels were read before the data region, so the value from the previous row should be used. If the correction is greater than half a DN we linearily interpolate between the value from the left and the right of the chip (or to the centre for two-amplifier chips) and subtract the result.

Each pixel that is not saturated is then bias subtracted (allowing for bias drifts) and divided by the flat field (or, more precisely, multiplied by the inverse flat field). The soft_bias is then added back to keep all pixel values positive.

Because of the way that the flat field is normalised, a low-sensitivity pixel that isn't saturated in the raw frame can have a value too large to fit into 16 bits after flatfielding. If this is the case, the nominal saturation_level for the frame is lowered. Unless something nasty has happened (e.g. the bias drift is wildly wrong) the adopted saturation level should still be close to 65000.

The final stage is to interpolate over all bad pixels, including those labelled as saturated. The algorithm used is described elsewhere. In deriving the interpolation coefficients we assume that the signal-to-noise is infinite, and that the PSF is a sigma=1pixel Gaussian (i.e. ~ 1" FWHM). The correction code is machine generated, to it wouldn't be too hard to relax these restrictions if it proved necessary.

All interpolated pixels are added to the MASK_INTERP mask.

Interpolation is only carried out using good pixels from the same row; it would be better to use a region with larger support, but the book-keeping involved was too frightening to contemplate (remember; we have to handle bleed trails as well as intrinsic bad columns, and they can easily be adjacent or separated by a single column or row).

No provision is made for non-linearity of the CCDs. XXX

Frames Pipeline Outputs

Outputs are: Furthermore, once the C code to correct the frame has been run, the TCL routine regStatsFromQuartiles is used to determine the global sky level (and its standard deviation). These values should come from PSP, but there seem to be problems. XXX