Index: trunk/doc/modules/ModulesSDRS.tex
===================================================================
--- trunk/doc/modules/ModulesSDRS.tex	(revision 6757)
+++ trunk/doc/modules/ModulesSDRS.tex	(revision 6762)
@@ -1,3 +1,3 @@
-%%% $Id: ModulesSDRS.tex,v 1.76 2006-04-01 03:07:09 price Exp $
+%%% $Id: ModulesSDRS.tex,v 1.77 2006-04-04 18:52:47 eugene Exp $
 \documentclass[panstarrs,spec]{panstarrs}
 
@@ -1851,34 +1851,120 @@
 the fringe pattern is used both in the process of constructing the
 master image and in scaling the master image when it is applied to
-science image.  We thus need a method of measuring the fringe
-amplitude which is robust in the presence of stars and which is fast.
-We implement a method used at CFHT in which the fringe pattern is
-mapped by a series of points pairs which correspond to peaks and
-valleys of the fringe pattern.  We define the following function to
-measure the global fringe amplitude of an image given a collection of
-fringe point pairs.
-\begin{prototype}
-stats *pmFringeStats (psArray *fringePoints, psImage *image, psMetadata *config);
-\end{prototype}
-This function measures the robust median at each of the minimum and
-maximum coordinates and determines the difference and mean of the two
-values.  The size of the box used to make the measurement at each
-point is specified by the configuration variable
-\code{FRINGE_SQUARE_RADIUS}.  From the collection of differences, the
-robust median is calculated, and returned as part of the fringe
-statistics.  For each fringe point, the values of \code{delta} and
-\code{midValue} are also assigned and available to the user on return.
- 
-The \code{fringePoints} are defined by the following structure:
+science image.  This is the method currently in use at CFHT and it
+usually performs well.  However, the fringe signal can vary as the
+emission lines in the atmosphere change, and the above method breaks
+down unless different fringe images corresponding to different
+atmospheric conditions are constructed.  
+
+An alternative technique is to use multiple master fringe images at
+the same time, each representing different atmospheric conditions.
+The observed fringe frame can be considered as a linear combination of
+different fringe patterns, depending on the relative strengths of the
+lines active in creating each of the fringe masters.  It is not
+critical that the fringe master images represent completely orthogonal
+fringe patterns, they need only sample sufficiently different
+conditions to provide a handle on the underlying fringe signals.  
+
+We define a method of measuring the fringe pattern which is robust in
+the presence of stars and which is fast.  We implement a varient on
+the method used at CFHT in which the fringe pattern is mapped by a
+series of points distributed across the image.  At CFHT, manual effort
+is used to carefully define point pairs which correspond to peaks and
+valleys of the fringe pattern.  We implement a different approach in
+which the fringe points are randomly chosen across the image.  At each
+point in the image, the median flux is measured in a box of specified
+size.  A low-frequency spatial filter is then applied to these
+measurements.  The resulting array of points and fluxes then
+represents the strength of the fringe pattern on that image.  The
+comparison between any two fringe images is then just a linear fit
+between these fringe statistics vectors, as follows:
+\[
+S_i = C_0 + C_1 F_i
+\]
+where $S_i$ is the fringe statistic on the science image and $F_i$ is
+the fringe statistic on the reference fringe image.  Extending this
+logic to any number of reference fringe images results in the
+following relationship:
+\[
+S_i = C_0 + \sum_j C_j F_j
+\]
+
+In order to correct a single science image, the collection of fringe
+statistics ($S_i$) are used to measure the coefficients $C_0$, $C_j$.
+The linear combination of the reference fringe images is then used to
+build a master image which is subtracted from the science image.  The
+following structures and functions implement the above concepts.
+
+The \code{pmFringeStats} structure represents the fringe statistics
+for a given image.  
 \begin{datatype}
 typedef struct {
-    double xMin;
-    double yMin;
-    double xMax;
-    double yMax;
-    double delta;
-    double midValue;
-} pmFringePoint;
+    psU32 nRequested;   // number of fringe points selected
+    psU32 nAccepted;    // number of fringe points not masked
+    psU32 dX;           // median box half-width
+    psU32 dY;           // median box half-height
+    psU32 nX;           // large-scale smoothing in x (col)
+    psU32 nY;      	// large-scale smoothing in y (row)
+    psVector x;    	// fringe point coordinates (col)
+    psVector y;    	// fringe point coordinates (row)
+    psVector f;    	// fringe point median
+    psVector df;   	// fringe point stdev
+    psVector mask;      // fringe point on/off mask
+} pmFringeStats;
 \end{datatype}
+
+The \code{pmFringeStats} structure is allocated with the following
+function:
+\begin{prototype}
+pmFringeStats *pmFringeStatsAlloc (
+    int nPts,     // number of points to create
+    int dX,     // half-width of fringe boxes
+    int dY,     // half-height of fringe boxes
+    int nX,     // smoothing scale in x
+    int nY    // smoothing scale in y
+);
+\end{prototype}
+
+A set of fringe points appropriate to the dimensions of a specific
+image are created with the following function:
+\begin{prototype}
+bool pmFringeStatsCreatePoints (pmFringeStats *fringe, psImage *image);
+\end{prototype}
+
+In general, \code{pmFringeStatsCreatePoints} should only be needed
+when a new chip and filter are first use for analysis.  Multiple
+fringe images with the same chip and filter need to be examined with
+the same fringe points in order for the statistical comparison to be
+meaningful.  The constructed fringe points should be saved and loaded
+as a FITS table using the following function:
+\begin{prototype}
+bool pmFringeStatsWriteFits (psFits *fits, pmFringeStats *fringe);
+bool pmFringeStatsReadFits (psFits *fits, pmFringeStats *fringe);
+\end{prototype}
+
+In order to measure the fringe statistics for a given image, the
+following function is defined:
+\begin{prototype}
+bool pmFringeStatsMeasure(pmFringeStats *fringe, pmReadout *readout)
+\end{prototype}
+This function measures the robust median at each of the fringe points
+and saves the median values in \code{fringe->f} and the scatter in
+\code{fringe->df}.
+ 
+Given the fringe statistics for a science image, and the fringe
+statistics for a set of reference fringe images, the following
+function can be used to measure the scaling coefficients of the
+reference fringe frames which best fit the science image fringe
+pattern:
+\begin{prototype}
+pmFringeScale *pmFringeScaleMeasure (pmFringeStats *science, psArray *fringes) 
+\end{prototype}
+
+Given a science image, a set of master fringe images, and a the set of
+fringe statistics for the reference fringe images, the following
+function can be used to correct the science image for the fringe pattern:
+\begin{prototype}
+psImage *pmFringeCorrect(psImage *out, psMetadata *info, psImage *science, psArray *fringeImage, psArray *fringeStats);
+\end{prototype}
 
 \subsection{Flat-field Re-Normalization}
@@ -2945,4 +3031,45 @@
 available approximation to the Sextractor classification scheme.
 \tbd{the correspondence is not yet defined}.
+
+\subsection{Object List Input/Output}
+
+We support several object catalog formats.  Some of these mimic the
+formats used by the Elixir system to support testing with existing
+data and software.  Some of these are for use by the Pan-STARRS
+project for testing.
+
+\subsubsection{OBJ Format}
+
+This format is produced by versions of DoPhot and is used by the
+Elixir system as an intermediate output data product.  The objects are
+written to a text file with fixed line-length and with fixed column
+positions.  The file has no header associated with it.  This is only
+an output format, and should be used just for testing and comparison
+with the Elixir tools.
+
+\subsubsection{SX Format}
+
+This format is produced by versions of Sextractor and is used by the
+Elixir system as an intermediate output data product.  The objects are
+written to a text file with fixed line-length and with fixed column
+positions.  The file has no header associated with it.  This is only
+an output format, and should be used just for testing and comparison
+with the Elixir tools.  The SX and OBJ formats are similar, but use a
+somewhat different definition of the columns.
+
+\subsubsection{CMP Format}
+
+This format is used extensively by the Elixir system, and many data
+files are available in this format.  The format is a pseudo-FITS
+format, consisting of a FITS header (with NAXIS=2) and a text data
+segment with fixed line length.  The CMP files are always in SPLIT
+format in the sense that each object table is a single file. 
+
+\subsubsection{CMF Format}
+
+This format is a true FITS table format.  The object data is stored
+for each readout in a separate extension.  In addition, the Cell
+headers are stored in their own extensions (with NAXIS=0).  In SPLIT
+format, the Cell header is the PHU header.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
