Index: trunk/doc/modules/ModulesSDRS.tex
===================================================================
--- trunk/doc/modules/ModulesSDRS.tex	(revision 4710)
+++ trunk/doc/modules/ModulesSDRS.tex	(revision 4757)
@@ -1,3 +1,3 @@
-%%% $Id: ModulesSDRS.tex,v 1.52 2005-08-05 03:43:30 price Exp $
+%%% $Id: ModulesSDRS.tex,v 1.53 2005-08-11 03:05:26 price Exp $
 \documentclass[panstarrs]{panstarrs}
 
@@ -655,5 +655,4 @@
 recipes contained in the \code{camera} configuration (details below).
 
-We also specify an additional function:
 \begin{prototype}
 bool pmConfigValidateCamera(psMetadata *camera, psMetadata *header);
@@ -664,4 +663,12 @@
 the \code{camera} configuration (see \S\ref{sec:camerarule});
 otherwise it shall return \code{false}.
+
+\begin{prototype}
+psDB *pmConfigDB(psMetadata *site);
+\end{prototype}
+
+\code{pmConfigDB} shall use the \code{site} configuration data to open
+a database handle.  \tbd{This is fairly straightforward at the moment,
+but will change when we beef up security.}
 
 \subsubsection{Example usage}
@@ -870,12 +877,14 @@
 pmReadout *pmSubtractBias(pmReadout *in, void *fitSpec, const psList *overscans,
                           pmOverscanAxis overscanAxis, const psStats *stat,
-                          int nBin, pmFit fit, const pmReadout *bias);
-\end{prototype}
-
-Two types of bias correction may optionally be performed on the input
-image, \code{in}.  The first is the subtraction of an overscan.
+                          int nBin, pmFit fit, const pmReadout *bias,
+			  const pmReadout *dark);
+\end{prototype}
+
+Three types of bias correction may optionally be performed on the
+input image, \code{in}.  The first is the subtraction of an overscan.
 Multiple overscan regions may be specified and fit as a function of
 row (or column).  The second is the subtraction of a full-frame bias
-image (or a ``dark'' image).
+image.  The third is the subtraction of a suitably scaled full-frame
+dark image.
 
 The input image, \code{in}, shall have the bias subtracted in-place.
@@ -973,15 +982,17 @@
 appropriate statistic applied to all the prescan/overscan pixels.
 
-A bias (or dark) image shall be subtracted pixel-by-pixel from the
-input image if \code{bias} is non-NULL.  Note that the input image,
-\code{in}, and the \code{bias} image need not be the same size, but
-the function shall use the offsets in the image (\code{in->x0} and
-\code{in->y0}) to determine the appropriate offsets to obtain the
-correct pixel on the \code{bias}.  In the event that the \code{bias}
-image is too small (i.e., pixels on the input image refer to pixels
-outside the range of the \code{bias} image), the function shall
-generate an error.  Any pixels masked in the \code{bias} shall also be
-masked in the output.  The bias image must be of the same type as the
-input image.
+A bias image shall be subtracted pixel-by-pixel from the input image
+if \code{bias} is non-NULL.  A dark image, multiplied by the
+\code{darkTime}, shall be subtracted pixel-by-pixel from the input
+image if \code{dark} is non-NULL.  Note that the input image,
+\code{in}, and the \code{bias} and \code{dark} frames need not be the
+same size, but the function shall use the offsets in the image
+(\code{in->x0} and \code{in->y0}) to determine the appropriate offsets
+to obtain the correct pixel on the \code{bias}.  In the event that the
+\code{bias} image is too small (i.e., pixels on the input image refer
+to pixels outside the range of the \code{bias} image), the function
+shall generate an error.  Any pixels masked in the \code{bias} or
+\code{dark} shall also be masked in the output.  The bias and dark
+images may be copied to the same type as the input image if required.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1009,29 +1020,13 @@
 
 \begin{prototype}
-pmReadout *pmNonLinearityLookup(pmReadout *in, const psVector *inFlux, const psVector *outFlux);
-\end{prototype}
-
-For each pixel in the input image, the function shall find the flux
-value in the \code{inFlux} vector, and replace the flux with the
-corresponding value in the \code{outFlux} vector.  If the sizes of the
-\code{inFlux} and \code{outFlux} vectors differ, then the function
-shall generate a warning, and the longer vector shall be truncated to
-the length of the shorter.  The \code{inFlux} vector may be assumed
-to be pre-sorted and not contain duplicate values.
-
-If the particular value of a pixel is not found in the \code{inFlux}
-vector, the corresponding \code{outFlux} shall be calculated through
-linear interpolation.  If the value of a pixel is beyond the range of
-values specified in the \code{inFlux} vector, then the function shall
-generate a warning (at most one warning of this type per call,
-preferably mentioning the number of pixels out of bounds), and replace
-that pixel value with the \code{outFlux} value corresponding to the
-minimum or the maximum, depending on whether the pixel value is below
-or above the range of \code{inFlux} values.
-
-In the event that the \code{inFlux} vector does not contain two or
-more entries (being the lower limit required for linear
-interpolation), then the function shall generate a warning, and make
-no correction to any of the pixels.
+pmReadout *pmNonLinearityLookup(pmReadout *in, const char *filename);
+\end{prototype}
+
+For each pixel in the input image, the function shall replace the flux
+with the corresponding value from the supplied lookup table, specified
+by the \code{filename}.  The lookup table file shall consist of two
+columns of data, the first being the original flux value and the
+second being the replaced flux value.  The file shall be in a format
+suitable for reading by \code{psLookupTableRead}.
 
 Both \code{pmNonLinearityPolynomial} and \code{pmNonLinearityLookup}
@@ -1110,5 +1105,5 @@
 shall be the following:
 \begin{prototype}
-pmReadout *pmMaskBadPixels(pmReadout *in, const psImage *mask, unsigned int maskVal,
+pmReadout *pmMaskBadPixels(pmReadout *in, const pmReadout *mask, unsigned int maskVal,
                            float sat, unsigned int growVal, int grow);
 \end{prototype}
@@ -1120,5 +1115,8 @@
 pixels, along with all pixels within the \code{grow} radius masked.
 Pixels which have flux greater than \code{sat} shall also be masked,
-but not grown.
+and grown by a single pixel (in addition to the \code{grow} done on
+the \code{growVal}).
+
+\tbd{In the future, may change grow to a convolution kernel}.
 
 Note that the input image, \code{in}, and the \code{mask} need not be
@@ -1128,5 +1126,5 @@
 the appropriate offsets to obtain the correct pixel on the mask.  In
 the event that the \code{mask} image is too small (i.e., pixels on the
-input image refer to pixels outside the range of the \code{mask}
+input image correspond to pixels outside the range of the \code{mask}
 image), the function shall generate an error.
 
@@ -1183,4 +1181,73 @@
 The \code{mask} shall be of type U8, and the input image,
 \code{in}, must be of type F32.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\subsection{Paper Trail}
+
+The elements of the focal plane hierarchy each contain an
+\code{analysis} member, intended to log the results of the Phase 2
+tasks.  The Phase 2 tasks shall add to the \code{analysis} members as
+follows:
+
+\begin{itemize}
+\item \code{pmMaskBadPixels}:
+  \begin{itemize}
+  \item \code{MASK.DONE} (STR): The time at which masking was
+    completed.
+  \item \code{MASK.SAT} (S32): The number of saturated pixels masked
+    in the image
+  \item \code{MASK.SAT.GROW} (S32): The number of additional pixels
+    masked by growing the saturated pixels.
+  \item \code{MASK.BAD} (S32): The number of pixels masked in the
+    image
+  \item \code{MASK.BAD.GROW} (S32): The number of additional pixels
+    masked by growing the specified bad pixels.
+  \end{itemize}
+\item \code{pmNonLinearityPolynomial} and \code{pmNonLinearityLookup}:
+  \begin{itemize}
+  \item \code{NONLIN.DONE} (STR): The time at which the non-linearity
+    correction was completed.
+  \item \code{NONLIN.POLY} (STR): The polynomial coefficients used (if
+    applicable).
+  \item \code{NONLIN.LOOKUP} (STR): The filename for the lookup table
+    (if applicable).
+  \end{itemize}
+\item \code{pmSubtractBias}:
+  \begin{itemize}
+  \item \code{BIAS.DONE} (STR): The time at which the bias-subtraction
+    was completed.
+  \item \code{BIAS.OVERSCAN.AXIS} (STR): Overscan axis used.
+  \item \code{BIAS.OVERSCAN.FIT.TYPE} (STR): Fit type applied to
+    overscan.
+  \item \code{BIAS.OVERSCAN.FIT.COEFF} (STR): Coefficients of overscan
+    fit.
+  \item \code{BIAS.OVERSCAN.REGION} (STR): Overscan regions (from
+    \code{x0,y0,numCols,numRows}).
+  \item \code{BIAS.OVERSCAN.BIN} (S32): Number of pixels per bin used
+    in overscan.
+  \item \code{BIAS.OVERSCAN.MEAN} (F32): The mean of the binned
+    overscan pixels after subtracting the fit.
+  \item \code{BIAS.OVERSCAN.SD} (F32): The standard deviation of the
+    binned overscan pixels after subtracting the fit.
+  \end{itemize}
+\item \code{pmFlatField}:
+  \begin{itemize}
+  \item \code{FLAT.DONE} (STR): The time at which the flat-fielding
+    was completed.
+  \item \code{FLAT.BAD} (S32): Number of non-positive flat-field
+    pixels.
+  \end{itemize}
+\end{itemize}
+
+To be added by higher-levels:
+\begin{itemize}
+\item \code{BIAS.NAME} (STR): Name of bias image
+\item \code{DARK.NAME} (STR): Name of dark image
+\item \code{FLAT.NAME} (STR): Name of flat image
+\item \code{MASK.NAME} (STR): Name of mask image
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \section{Calibration}
