Table of Contents Previous Chapter
The fepTimedBias module, executing in the FEP, calibrates the bias map for subsequent timed-exposure science processing. It is called from fepCtl with a single argument, fp
, a pointer to the fepParm
structure. Before invoking fepTimedBias, the FEP must be commanded to load a timed-exposure FEPparmBlock
into fp->tp
.
The fepTimedBias function operates in one of the following modes, according to the value of fp->tp.type
:
FIGURE 193. fepTimedBias Structure in "Whole-Frame" Mode
FIGURE 194. fepTimedBias Structure in "Strip" Mode
All interactions with the BEP and with FEP hardware are made through fepio library functions described in Section 39.0. The commands that are passed between FEP and BEP are defined in that document and in Section 4.10. fepTimedBias makes use of the following functions which call each other in the manner shown in Figure 193 ("whole-frame" mode) or in Figure 194 ("strip" mode), depending on the value of fp->tp.btype
(see Table 47):
FEPparmBlock
, fp->tp
, and performs all necessary mode-dependent initialization.
EVEN=0
, ODD=1
) of the corresponding bias value. In "whole-frame" mode, this routine is called once at the very end of the task. In "strip" mode, it is called after each strip of bias values has been created.
fp->tp.bparm
[0]-1
times in "whole-frame" mode.
fp->tp.bparm
[3]
, the image pixel and its 8 neighbors are set equal to PIXEL_BAD. This routine must be followed immediately by a call to FEPtimedBias1Mean. The pair of routines are called a total of fp->tp.bparm
[1]
-- fp->tp.bparm
[0]
-- 1 times in "whole-frame" mode.
fp->expnum
-
fp->tp.bparm
[0] + 1
.
fp->tp.bparm
[0]
and when fp->tp.bparm
[2]
is non-zero. It examines all 3x3
blocks of bias values. When the central value is less than all but one of its neighbors by at least fp->tp.bparm
[2]
, it replaces the central value by the median of its neighbors.
It should only be invoked when it is suspected that the image pixels contain anomalously low values that would otherwise corrupt the "whole-frame" bias map.
The following FEPparm fields, defined in fepCtl.h and fepBep.h, and is invariably addressed by the fp pointer parameter, are used by all timed exposure bias modes:
br
bias0[4]
biassumex
FEPexpRec
record
d0clk[4]
expnum
timestamp
expcount
fepStatus
biasflagflags
FP_SUSPEND
FP_PAST_EOR
FP_TERMINATE
FP_DONE
image
nextexpnum
parityquadrants
tp
bparm[5]
btype
ncols
noclk
nrows
nskip
quadcodeThe following paragraphs describe the basic functions performed by fepTimedBias during timed exposure bias calibrations, which are determined by the fields in the parameter block, fp->tp
shown in Table 47.
TABLE 47. Parameters used by fepTimedBias
---------------------------------------------------------------------------------- Field Type Field Name "Whole-Frame" Mode "Strip" Mode ---------------------------------------------------------------------------------- unsignednrows
Number of bias rows to be calibrated. unsignedncols
Number of pixels per output node per row fepQuadCodequadcode
Output node configuration, i.e., ABCD, AC, or BD. unsignednoclk
Number of overclocks per row per output node fepBiasTypebtype
FEP_BIAS_1
FEP_BIAS_2
intbparm[0] Number of conditioning Number of exposures per exposures (PHASE2) pixel int
bparm[1] Number of approxima =0 to use mean tion-to-mean exposures =1 to use fractile (PHASE3) int
bparm[2] Rejection threshold for For mean, specifies s low-pixel elimination rejection criterion. For (immediately prior to fractile, index of sorted PHASE3) pixel array. int
bparm[3] Threshold for event rejec Ignored tion (PHASE3) int
bparm[4] Rejection threshold for Ignored approximation-to-mean unsigned
nskip
Exposure skip factor; if non-zero, don't use those with "non-standard" exposure times for bias calibration. ----------------------------------------------------------------------------------
The bias calibration algorithms themselves are presented in some detail in the ACIS report entitled "CCD Bias Level Determination" by Rita Somigliana and Peter Ford, ACIS part #36--56012--02, MIT CSR, Revision 2, May 30, 1995.
fepTimedBias calls FEPtimedBiasInit to check the fp->tp
parameter block, to initialize the parity table (fp->parity
), and set the hardware registers. It then loops, waiting for the next exposure to be received from the DEA. Subsequent processing occurs in three distinct phases, with an optional 2a phase invoked in special circumstances.
Before processing each line of image pixels, FIOgetNextCmd is called. If it returns TRUE
, fepHandleCmd is called to process a single BEP command.
After the last exposure has been processed, FEPtimedBiasParity is called to construct a bias parity buffer that contains a single parity bit for each pixel in the bias map. This will be used by the FEP hardware to detect single-bit flips in the bias map during subsequent timed exposure science runs.
Finally, fepTimedBias exits with writes to the image map disabled. It returns to its command mode and waits for more BEP commands.
fepTimedBias calls FEPtimedBiasInit to check the fp->tp
parameter block, to initialize the parity table (fp->parity
), and set the hardware registers. It then loops over calls to FIOgetExpInfo, waiting for the next exposure to be received from the DEA.
The algorithms require each image pixel to be exposed several times, and its values after each exposure must be available simultaneously. Since there is insufficient memory available to store more than a single copy of the image map, the pixels must be processed a few at a time. On each exposure, the FEP hardware is therefore commanded to write only a strip of CCD image pixels to the image map. On subsequent exposures, the registers are adjusted so that each strip is written into a different part of the image map, as shown in Figure 195.
FIGURE 195. The Relation between CCD strips, Image strips, and exposures
The choice of strip size is determined by the number of exposures desired (the value of fp->tp.bparm
[0]
), i.e. its size in rows is the smallest integer that does not exceed 1024 divided by the number of exposures. Once the image map is filled with strips, the program copies the corresponding pixel value in each strip to an array in D-cache for faster access. It then operates on the array values and uses either their truncated mean or their fractile as the bias value, which it stores in the bias map.
This algorithm, described in Section 3.2.4 of 36--56012--02, is implemented by the function mean (see Section 43.6.11). It takes the N pixel values pi, i=0,N--1, and computes their mean value p and variance s2:
If the value of BPARM[2] is zero, mean returns p as the bias value. Otherwise, it inspects the pi and removes any that do not satisfy the condition
Finally, it recomputes p from the remaining pi using Eq. 6, and returns that as the bias value.
This algorithm, which is a generalization of the Median method described in Section 3.2.5 of 36--56012--02, is implemented in the function fractile (see Section 43.6.12). It takes the N pixel values pi, i=0,N--1, sorts them into ascending order, and returns the value indexed by the value of bparm
[2]
. For instance, if N were 11 (it is usually 1024), and bparm
[2]
were 5, and the pixel values pi were,
212 216 205 1041 208 217 211 214 215 206 210
their bias value would be 212, since, when the values are sorted into ascending order,
205 206 208 210 211 212 214 215 216 217 1041
that is the value of the element p5.
43.6 Specification
This section describes the functions that are local to the fepTimedBias unit. The only external is fepTimedBias itself which is called from fepCtl. The FEPparm
structure is defined in fepCtl.h and fepBep.h, along with several pixel access macros. The interface to the FEP I/O library is described in Section 39.0, and data and messages exchanged between FEP and BEP are described in Section 4.10.
FEPparm *fp
fepTimedBias is called from fepCtl with a single argument: the pointer fp to the fepParm structure. It is responsible for all FEP actions associated with a timed exposure bias calibration. It performs the following actions:
par
array in its D-cache stack, to fp->parity
, where it will be initialized within FEPtimedBiasInit and used within FEPtimedBiasParity.
fepParm
fields and hardware registers. If FEPtimedBiasInit returns FEP_CMD_NOERR
, fepTimedBias calls fepAckCmd and continues. Otherwise, it calls fepNackCmd to pass the error code to the BEP, indicating that the command has failed, and fepTimedBias then returns to fepCtl
FP_DONE
or the FP_TERMINATE
flag is set in fp->flags
.
fp->tp.btype
) is "strip" mode (FEP_BIAS_2
), sets the mode
parameter to BIAS2. Otherwise, this is "whole-frame" mode and the mode
parameter is set according to the number of fully-processed exposures (fp->expcount
) and the fp->tp.bparm
values. The first exposure will be processed as BIAS1_PHASE1
, the next fp->tp.bparm
[0] exposures will be processed as BIAS1_PHASE2
, and the final fp->tp.bparm
[1] exposures will be processed as BIAS1_PHASE3
.
IPULSE_ARMNXTACQ
bit in the FEP's image pulse register.
fp->tp.nskip
), FEPtimedBiasExec will not be called for those exposures with the initial (i.e. less frequent) exposure time.
fp->biasmode
to TRUE
and fp->br.biassum
to the sum of the 4 elements in the fp->br.bias0
array.
FEPparm *fp BiasMode mode
This function is called from fepTimedBias to process a single frame. mode selects either a phase of the "whole-frame" algorithm: BIAS1_PHASE1, BIAS1_PHASE2, or BIAS1_PHASE3, or the "strip" algorithm, BIAS2. In the "whole-frame" algorithm, the routine loops over image frame rows, calling FIOgetNextCmd once per row to catch incoming commands from the BEP and, when detected, fepHandleCmd is called to process them. FEPtimedBiasExec then sums the overclocks and calls a subroutine to process the image pixels, depending on the mode value: BIAS1_PHASE1---FEPtimedBias1Copy copies a row of image pixels to the bias map without any change. BIAS1_PHASE2---FEPtimedBias1Cond reads a row of image pixels and uses them to replace the corresponding bias map values when the latter are larger than the former. The result of performing this operation over several consecutive expo sures is to "condition" the bias map values, removing any contamination from CCD events. BIAS1_PHASE3---first, FEPtimedBias1ZapEvent is called to mark all image map pixels that may contain events, followed by FEPtimedBias1Mean to use the unmarked pixels to update the bias values. In the "strip" algorithm, when mode has the value FEP_BIAS_2, FEPtimedBia sExec does very little until the last of a set of strips has been written to the image map. It merely adjusts the hardware pointers via calls to FIOsetImageMapRow Start and FIOsetImageMapRowLength to march the strips down the image map, and to FIOsetCcdRowStart to select different rows of the CCD. After the image map is full of strips, FEPtimedBiasExec sums the overclocks of the last frame and then calls FEPtimedBias2Proc to update the bias map.
FEPparm *fp
This function is called from fepTimedBias to verify the contents of the FEPparmBlock, fp->tp, and to perform the following initializations:
fp->quadrants
are set to 2 or 4, depending on the value of fp->tp.quadcode
.
fp->parity
[0]
through fp->parity
[4095]
are either set to PARITY_EVEN
or to PARITY_ODD
(defined in fepCtl.h) according to the bit parity of the binary integers 0--4095.
FEPparm *fp unsigned rowstart unsigned nrows
In "strip" mode, this function is called from FEPtimedBias2Proc to update nrows in the bias parity buffer, starting at row rowstart, from the correspond ing values in the bias map. In "full-frame mode", it is called from FEPtimedBias to compute the entire parity buffer at the end of the bias calibration run. Each 12- bit bias map value is used as an index into the fp->parity array, whose ele ments are either PARITY_EVEN or PARITY_ODD, according to the parity of the index. For instance, the number fifteen is represented by the bit pattern 01111, which contains an even number of `1's. Its parity is therefore even, so fp->parity[15] = PARITY_EVEN.
fp->parity must point to an array of 4096 32-bit values, which have been ini tialized to PARITY_EVEN if the index number possesses even parity, or to PARITY_ODD if odd.
FEPparm *fp
This function is called from FEPtimedBiasExec in BIAS1_PHASE1 to copy a single row of pixels from the image map (located at fp->image) to the bias map (located at fp->image + BIAS_OFFSET). Since this routine is only called for the first exposure of the bias calibration se quence, no overclock correction factor need be applied.
FEPparm *fp
This function is called from FEPtimedBiasExec in BIAS1_PHASE2 to inspect a single row of pixels from the image map (located at fp->image) and update the corresponding values in the bias map (located at fp->image + BIAS_OFFSET) when the former are smaller than the latter. Before making the comparison with the bias pixel, each image pixel is corrected for any change in average overclock by subtracting the fp->ex.dOclk element appropriate to the pixel's output node. Since the correction factor is based on the average overclocks from the previous exposure, this can only compensate for slow changes in the analog system.
FEPparm *fp
This function is called from FEPtimedBiasExec in BIAS1_PHASE3 to read a sin gle row of image pixels (located in fp->image - PIXEL_STRIDE) and update the corresponding bias values (located in fp->image + BIAS_OFFSET - PIXEL_STRIDE). Image pixels with the PIXEL_BAD value are skipped since they have been identified in a prior call to FEPtimedBias1ZapEvents as possibly containing events. Before making the comparison with the bias pixel, each image pixel is corrected for any change in average overclock by subtracting the fp->ex.dOclk element appropriate to the pixel's output node. Since the correction factor is based on the average overclocks from the previously processed exposure, this can only compen sate for slow changes in the analog system. When the pixel value p exceeds the corresponding bias value b by not more than fp->bparm[4], b is replaced by (n*b+p)/(n+1), where n is the exposure count, i.e. n=1 for the first exposure of BIAS1_PHASE3, 2 for the second, etc. Since FEPtimedBias1Mean is called immediately after FEPtimedBias1Cond, and the latter is capable of nullifying pixels in the preceding row, FEPtimedBias1Mean must also work on that row, whose first pixel is located at fp->image - PIXEL_STRIDE, rather than on the current row, pointed to by fp->image.
FEPparm *fp
This function is called from fepTimedBias at the end of BIAS1_PHASE2 to iden tify anomalously low valued pixels in the bias map. It does this by comparing each bias value with those of its 8 neighbors. If the central value is smaller than all but one of its neighbors by more than fp->tp.bparm[2], FEPtimedBias1Median replaces the central value by the median of the neighbors. This function is only invoked if fp->tp.bparm[2] is non-zero. It should only be used if it has been found from a study of previous bias maps that some anoma lously low image pixel values will be encountered, since these would otherwise dominate the bias map that is constructed during BIAS1_PHASE2.
FEPparm *fp unsigned irow
This function is called from FEPtimedBiasExec in BIAS1_PHASE3 to identify image pixel values (at location fp->image) in row irow that are larger than their corresponding bias values (at location fp->image + BIAS_OFFSET) by more than a constant fp->tp.bparm[3]. Before making the comparison, each image pixel is corrected for any change in av erage overclock by subtracting the fp->ex.dOclk element appropriate to the pixel's output node. Since the correction factor is based on the average overclocks from the previous exposure, this can only compensate for slow changes in the an alog system. Once identified, the image pixels and their immediate neighbors (8 pixels, or less if the identified pixel is on the edge of the CCD) are reset to PIXEL_BAD so that they can be identified in the FEPtimedBias1Mean routine.
FEPparm *fp
This function is called from FEPtimedBiasExec in the BIAS2 mode ("strip" pro cessing) when the image map is filled with a series of strips of pixels from the same group of CCD rows from fp->tp.bparm[0] consecutive exposures. Each image pixel is corrected for any change in average overclock by subtracting the fp->ex.dOclk element appropriate to the pixel's output node. Since the correction factor is based on the average overclocks from the last exposure that contributed to the current strip, this can only compensate for slow changes in the analog system. Each set of pixel values, one from each exposure, is copied to a buffer in D-cache, Data0 for pixels from even-indexed columns and Data1 for pixels from odd-in dexed columns. The value to be stored in the bias map is determined by the value of fp->tp.bparm[1]. bparm[1] = 0: mean is called to compute the mean of the pixel values. When fp->tp.bparm[2] is zero, this becomes the bias map value. When fp->tp.bparm[2] is non-zero, pixels with values that differ from the zeroth-order mean by more than fp->tp.bparm[2] times the RMS variance of the values are eliminated, and the mean of the remainder be comes the bias map value. bparm[1] = 1: fractile is called to sort the pixel values into ascending or der. The element in this sorted list indexed by fp->tp.bparm[2] becomes the bias map value. After processing the entire set of strips in the image map, FEPtimedBias2Proc calls FEPtimedBiasParity to compute parity flags for each of the new bias map pixel values and store the result in the appropriate section of the bias parity buffer.
unsigned *vec unsigned nvec unsigned nsigma
This function returns the integer closest to the mean value of the nvec-element ar ray vec[]. Half-integer values are rounded up. If nsigma is non-zero, the stan dard deviation (s) of the elements is also calculated, and the mean is re-calculated from those elements of vec[] that differ from the original mean value by no more than nsigma C s. The algorithm is described in Section 43.5.2.1.
unsigned *vec unsigned nvec unsigned nrep
This function sorts the elements of the nvec-element array vec[] into ascending value, and returns the value of the nrep'th element, i.e. nrep=0 returns the min imum, nrep=nvec/2 returns the median, etc. The routine uses Shell's method, which was chosen for its computational efficiency---nvec × ln(nvec)---and low start-up overhead. The algorithm is described in Section 43.5.2.2.