Index: trunk/ppTranslate/documentation/ICD/PSDC-940-005.tex
===================================================================
--- trunk/ppTranslate/documentation/ICD/PSDC-940-005.tex	(revision 34708)
+++ trunk/ppTranslate/documentation/ICD/PSDC-940-005.tex	(revision 34712)
@@ -9,4 +9,16 @@
 \newcommand{\outformatversion}{%
   \texttt{PS1\_DV3}}
+
+\newcommand{\commentFrom}[4]{%
+  \mbox{ }\\\null\hfill\begin{tabular}{|p{4in}}
+    \hline
+    \emph{Comment from {#1} (#2)}: {#3}\\
+    \hline
+    Answer: {#4}\\
+    \hline
+  \end{tabular}}
+
+\newcommand{\commentFromSC}[3]{%
+  \commentFrom{SC}{#1}{#2}{#3}}
 
 % basic document variables
@@ -1000,4 +1012,538 @@
 \end{center}
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newpage
+\section{\texttt{ppMops} Implementation Details}
+\label{sec-ppmops}
+
+\subsection{Source Code}
+\label{sec-ppmops-sourcecode}
+
+The \texttt{ppMops} source code can be found at
+\url{https://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/trunk/ppTranslate}. The
+SVN revision of the analyzed code as well as the corresponding
+software version depends on the version of this document and can be
+found in the History subsection (see subsection
+\ref{sec-ppmops-sourcecodehistory}).
+
+\subsection{Source Code Analysis History}
+\label{sec-ppmops-sourcecodehistory}
+\begin{tabular}{|c|c|c|p{2in}|c|c|}
+  \hline
+  \parbox{.5in}{Doc Version} & Date & Author & Description & SVN Rev. & \parbox{.5in}{Software Version}\\
+  \hline
+  \hline
+  --- & 2012-09-14 & SC & Creation & 34439 & 3\footnotemark{}\\
+  \hline
+\end{tabular}\footnotetext{Modified version 3}
+
+\subsection{Main}
+Source code: \texttt{src/ppMops.c}.
+
+\texttt{ppMops} can be run on the command line independently from the
+IPP framework. It is functionnally made of four parts:
+\begin{enumerate}
+\item Analyzing the command-line arguments (see subsection
+  \ref{sec-implementation-args});
+\item Reading the detections from the input diff files and the exposure
+  parameters (see subsection \ref{sec-implementation-read});
+\item Removing the duplicated detections (see subsection
+  \ref{sec-implementation-merge});
+\item Writing the products (see subsection
+  \ref{sec-implementation-write});
+\end{enumerate}
+
+\subsection{Command-Line Arguments Analysis}
+\label{sec-implementation-args}
+
+Source code: \texttt{src/ppMopsArguments.c}.
+
+\subsubsection{Parameters}
+
+There are only two mandatory arguments:
+\begin{enumerate}
+\item The first argument is a filename. The associated file contains
+  the list of the names of all the diff files that will be used as
+  input. For simplicity, we will identify that list by:
+  \texttt{list\_of\_diffs\_inputs}.
+\item The second argument is the name of the output file. We will call
+  it \texttt{output\_file\_name}.
+\end{enumerate}
+
+The following parameters can be taken from the command line arguments
+options (if they are provided, otherwise they take the default value):
+\begin{itemize}
+\item \texttt{exp\_name}: exposure name (default: NULL);
+\item \texttt{exp\_id}: Exposure identifier (IPP internal; default: 0);
+\item \texttt{chip\_id}: Chip stage identifier (IPP internal; default: 0);
+\item \texttt{cam\_id}: Camera stage identifier (IPP internal; default: 0);
+\item \texttt{fake\_id}: Fake stage identifier (IPP internal; default: 0);
+\item \texttt{warp\_id}: Warp stage identifier (IPP internal; default: 0);
+\item \texttt{diff\_id}: Diff stage identifier (IPP internal; default: 0);
+\item \texttt{inverse}: Inverse subtraction (boolean; default: false);
+\item \texttt{zp}: Magnitude zero point (default: NAN);
+\item \texttt{zp\_error}: Error in magnitude zero point (default: NAN);
+\item \texttt{astrom\_rms}: Astrometric solution RMS (default: NAN);
+\item \texttt{version}: CMF file version (default: 0);
+\end{itemize}
+
+\subsubsection{Parameters Values Validation}
+\begin{itemize}
+\item If the list of input file names is empty, an error is displayed
+  and \texttt{ppMops} exits.
+\item There is no check on the validity of the different parameters
+  (values, files existence...).
+\end{itemize}
+
+\subsection{Reading Detections}
+\label{sec-implementation-read}
+
+Source code: \texttt{src/ppMopsRead.c}.
+
+Each file from the \texttt{list\_of\_diffs\_inputs} is opened. A
+\texttt{ppMopsDetections} object is populated from the data that are
+read from that file. The set (namely a \texttt{psArray}) of all the
+valid \texttt{ppMopsDetections} objects is the product of this part.
+
+The data which are extracted from each file are the following:
+\begin{itemize}
+\item From the header are extracted:
+  \begin{itemize}
+  \item \texttt{diffSkyfileId}: Its value is
+    associated to the keyword \texttt{IMAGEID}. If not present or 0, the
+    program exits with an error.
+  \item The current diff version is derived from the value associated
+    to EXTTYPE. If the \texttt{version} has not already been set, it
+    is set to the value which has just been read. If it was set at
+    some point (either through the command line, or from a previous
+    input), the current diff version value is checked against the
+    \texttt{version}. Different values will produce warning messages.
+  \item \texttt{raBoresight} is given the value associated to
+    \texttt{FPA.RA};
+  \item \texttt{decBoresight} is given the value associated to
+    \texttt{FPA.DEC};
+  \item \texttt{filter} is given the value associated to
+    \texttt{FPA.FILTER};
+  \item \texttt{airmass} is given the value associated to
+    \texttt{AIRMASS};
+  \item \texttt{exptime} is given the value associated to
+    \texttt{EXPTIME};
+  \item \texttt{posangle} is given the value associated to
+    \texttt{FPA.POSANGLE};
+  \item \texttt{alt} is given the value associated to
+    \texttt{FPA.ALT};
+  \item \texttt{az} is given the value associated to
+    \texttt{FPA.AZ};
+  \item \texttt{mjd} is computed from the \texttt{mjdobs} value
+    associated to \texttt{MJD-OBS} by: \[\mathtt{mjd} = \mathtt{mjdobs} +
+    \frac{\mathtt{exptime}}{2*3600*24}\]
+  \item \texttt{seeing} is initialized (note that it is modified in
+    the loop over the valid detections) using
+    $\mathtt{fwhm}_\mathtt{maj}$ (wrt $\mathtt{fwhm}_\mathtt{min}$)
+    associated to the keyword \texttt{FWHM\_MAJ} (wrt
+    \texttt{FWHM\_MIN});
+  \item \texttt{naxis1} is set to the value associated to
+    \texttt{IMNAXIS1}, that is the number of columns of the original
+    image;
+  \item \texttt{naxis2} is set to the value associated to
+    \texttt{IMNAXIS2}, that is the number of rows of the original
+    image;
+  \end{itemize}
+\item From the \texttt{SkyChip.psf} extension:
+  \begin{itemize}
+  \item This extension contains all the detections. One row is
+    associated to each detection.
+  \item A detection is rejected if at least one of the following
+    parameters has an non-finite value: \texttt{x}, \texttt{y},
+    \texttt{ra}, \texttt{dec}, \texttt{mag}, \texttt{magErr},
+    \texttt{xErr}, \texttt{yErr}, \texttt{scale}, \texttt{angle}.
+  \item A detection is rejected if its associated \texttt{flags}
+    matches:
+    {\small
+    \texttt{PM\_SOURCE\_MODE\_FAIL | PM\_SOURCE\_MODE\_BADPSF |
+      PM\_SOURCE\_MODE\_SATURATED | PM\_SOURCE\_MODE\_CR\_LIMIT |
+      PM\_SOURCE\_MODE\_SKY\_FAILURE}}
+  \item \texttt{x} is associated to the \texttt{X\_PSF} keyword;
+  \item \texttt{y} is associated to the \texttt{Y\_PSF} keyword;
+  \item \texttt{ra} is associated to the \texttt{RA\_PSF} keyword. It
+    is converted to radians;
+  \item \texttt{dec} is associated to the \texttt{DEC\_PSF} keyword. It
+    is converted to radians;
+  \item \texttt{mag} is computed from the value associated the
+    \texttt{PSF\_INST\_MAG} keyword, namely:
+    \[
+    \mathtt{mag} = \mathtt{PSF\_INST\_MAG} + \mathtt{zp}
+    \]
+    where \texttt{zp} is defined in the arguments list (see subsection
+    \ref{sec-implementation-args});
+  \item \texttt{magErr} is associated to the
+    \texttt{PSF\_INST\_MAG\_SIG} keyword;
+  \item \texttt{xErr} is associated to the \texttt{X\_PSF\_SIG}
+    keyword;
+  \item \texttt{yErr} is associated to the \texttt{Y\_PSF\_SIG}
+    keyword;
+  \item \texttt{scale} is associated to the \texttt{PLTSCALE}
+    keyword;
+  \item \texttt{angle} is associated to the \texttt{POSANGLE}
+    keyword;
+  \item \texttt{flags} is associated to the \texttt{FLAGS} keyword;
+  \item \texttt{raErr} is defined by: 
+    \[
+    \mathtt{raErr} = \frac{\mathtt{scale}}{3600}
+    \sqrt{\cos^2(\mathtt{angle}) \mathtt{xErr}^2 +
+      \sin^2(\mathtt{angle}) \mathtt{yErr}^2}
+    \]
+  \item \texttt{decErr} is defined by: 
+    \[
+    \mathtt{decErr} = \frac{\mathtt{scale}}{3600}
+    \sqrt{\sin^2(\mathtt{angle}) \mathtt{xErr}^2 +
+      \cos^2(\mathtt{angle}) \mathtt{yErr}^2}
+    \]
+  \end{itemize}
+\item \texttt{seeing} is defined as the product of the mean of
+  $\mathtt{fwhm}_\mathtt{maj}$ and $\mathtt{fwhm}_\mathtt{min}$ by the
+  mean of the \texttt{scale} values for valid detections, that is:
+  \[
+  \mathtt{seeing} = \frac{\mathtt{fwhm}_\mathtt{maj} +
+    \mathtt{fwhm}_\mathtt{min}}{2} \times \frac{\sum_{\mathtt{valid\
+        detections}}(scale)}{\#(\mathtt{valid\ detections})}
+  \]
+\item The number of valid detections is also kept (but not used).
+\item For each row of the \texttt{SkyChip.xfit} extension:
+  \begin{itemize}
+  \item This extension contains only a subset of the detections. Each
+    row contains the index of the current detection which is the value
+    associated to the keyword \texttt{IPP\_IDET};
+  \item Note that detections parameters whose index could not be found
+    in the \texttt{SkyChip.xfit} extension are set to NaN.
+  \item The following columns are extracted \texttt{X\_EXT},
+    \texttt{Y\_EXT}, \texttt{X\_EXT\_SIG}, \texttt{Y\_EXT\_SIG},
+    \texttt{EXT\_INST\_MAG}, \texttt{EXT\_INST\_MAG\_SIG},
+    \texttt{NPARAMS}, \texttt{EXT\_WIDTH\_MAJ}, \texttt{EXT\_WIDTH\_MIN},
+    \texttt{EXT\_THETA}, \texttt{EXT\_WIDTH\_MAJ\_ERR},
+    \texttt{EXT\_WIDTH\_MIN\_ERR}, and \texttt{EXT\_THETA\_ERR}. No check is
+    performed on them at this stage.
+  \end{itemize}
+\end{itemize}
+
+At the end of this stage, all input files have been used to populate a
+collection of sets of detections. Let us call that collection $({\cal
+  D}_{i})_{i \in \{1..n\}}$. Each of those sets contains data read
+from one file and it is important to note that only a few checks have
+been performed on the data (more precisely, only non-masked detections
+which have defined values have been inserted). The following cases can
+therefore happen: (1) Any ${\cal D}_i$ can be "empty", that is, does
+not contain any valdiated detection; (2) Some parameters like
+\texttt{seeing} can have an undefined value (e.g. \texttt{NaN}).
+
+\subsection{Merging Detections}
+\label{sec-implementation-merge}
+
+Source code: \texttt{src/ppMopsMerge.c}.
+
+That part of the code essentially uses a kd-tree implementation to
+compare distances between detections. The collection of sets of
+detections will be called $({\cal D}_{i})_{i \in \{1..n\}}$ (see
+previous section). 
+
+\subsubsection{Checks}
+\label{sec-implementation-merge-checks}
+
+Checks are performed on data that have been extracted from FITS files
+headers. Namely, they are:
+\begin{itemize}
+\item \texttt{raBoresight} constancy across all the detections;
+\item \texttt{decBoresight} constancy across all the detections;
+\item \texttt{filter} constancy across all the detections;
+\item \texttt{airmass} constancy across all the detections;
+\item \texttt{exptime} constancy across all the detections;
+\item \texttt{posangle} constancy across all the detections;
+\item \texttt{alt} constancy across all the detections;
+\item \texttt{az} constancy across all the detections;
+\item \texttt{mjd} constancy across all the detections;
+\end{itemize}
+
+Any inconsistency displays an error and the program exits.
+
+\subsubsection{kd-Tree Merging}
+\label{sec-implementation-merge-kdtree}
+
+All valid detections are inserted into a kd-tree (using the
+\texttt{psTree} implementation). \texttt{ra} and \texttt{dec} are used
+as keys for the nearest neighbor search. An iteration over all valid
+detections is then performed. 
+
+The detection in a 1 arcsec neighborhood around the current valid
+detection which is the closest to the image center is chosen as the
+best candidate for the source. Then, the best of the candidates is
+chosen as the source. All other detections are considered duplicates,
+and marked as invalid, then removed from the detections set to which
+they belong.
+
+Note that \texttt{numGood} which is supposed to give the number of
+valid detections is not updated.
+
+\subsection{Writing Final Product}
+\label{sec-implementation-write}
+
+Source code: \texttt{src/ppMopsWrite.c}.
+
+To resolve any ambiguity, we will note the parameter named
+\texttt{param} which was built for the set of detections ${\cal
+  D}_{i}$ will be denoted by ${\cal D}_{i}(\mathtt{param})$. 
+
+Note that, except for the parameters that have been checked at the
+merge stage (see paragraph~\ref{sec-implementation-merge-checks}),
+there is no guarantee that ${\cal D}_{i}(\mathtt{param}) = {\cal
+  D}_{j}(\mathtt{param})$ when $i \neq j$. There is no guarantee to
+that ${\cal D}_{i}(\mathtt{param})$ is defined (in the mathematical
+sense), e.g. it could be \texttt{NaN}...
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\subsubsection{Exposure Parameters: Header Details}
+\label{sec-implementation-write-header}
+
+The first set of detections among the $({\cal D}_{i})_i$ that contains
+at least one valid detection is chosen. To fix ideas, let us denote
+it by ${\cal D}_{i_0}$. 
+
+The following parameters are written to the product FITS header:
+
+\begin{itemize}
+\item \texttt{SWSOURCE} (Software source): Constructed from the SVN
+  repository value. Generated when compiled.
+\item \texttt{SWVERSN} (Software version): Constructed from the SVN
+  version value. Generated when compiled.
+\item \texttt{EXP\_NAME} (Exposure name): Set by \texttt{exp\_name}
+  argument value;
+\item \texttt{EXP\_ID} (Exposure identifier): Set by \texttt{exp\_id}
+  argument value;
+\item \texttt{CHIP\_ID} (Chip stage identifier): Set by
+  \texttt{chip\_id} argument value;
+\item \texttt{CAM\_ID} (Cam stage identifier): Set by \texttt{cam\_id}
+  argument value;
+\item \texttt{FAKE\_ID} (Fake stage identifier): Set by
+  \texttt{fake\_id} argument value;
+\item \texttt{WARP\_ID} (Warp stage identifier): Set by
+  \texttt{warp\_id} argument value;
+\item \texttt{DIFF\_ID} (Diff stage identifier): Set by
+  \texttt{diff\_id} argument value;
+\item \texttt{DIFF\_POS} (Positive subtraction): Set by
+  \texttt{inverse} argument value;
+\item \texttt{MJD-OBS} (MJD of exposure midpoint): Set by ${\cal
+    D}_{i_0}(\mathtt{mjd})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{RA} (Right Ascension of boresight): Set by ${\cal
+    D}_{i_0}(\mathtt{raBoresight})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{DEC} (Declination of boresight): Set by ${\cal
+    D}_{i_0}(\mathtt{decBoresight})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{TEL\_ALT} (Telescope altitude): Set by ${\cal
+    D}_{i_0}(\mathtt{alt})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{TEL\_AZ} (Telescope azimuth): Set by ${\cal
+    D}_{i_0}(\mathtt{az})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{EXPTIME} (Exposure time (sec)): Set by ${\cal
+    D}_{i_0}(\mathtt{exptime})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{ROTANGLE} (Rotator position angle): Set by ${\cal
+    D}_{i_0}(\mathtt{rotangle})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{FILTER} (Filter name): Set by ${\cal
+    D}_{i_0}(\mathtt{filter})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{AIRMASS} (Airmass of exposure): Set by ${\cal
+    D}_{i_0}(\mathtt{airmass})$. Uniqueness guaranteed by
+  \ref{sec-implementation-merge-checks};
+\item \texttt{SEEING} (Mean seeing): Set by the median of defined (not
+  \texttt{NaN}, not \texttt{Infinity}) of $({\cal
+    D}_{i}(\mathtt{seeing}))_i$;
+  \commentFromSC{2012-09-18}{Check if it is what we
+    really expect. Take the example of 3 set of detections for which
+    \texttt{seeing} is defined, assuming the first one contains 1000
+    detections with a \texttt{seeing} of 1.0, the second one contains
+    10 detections with a \texttt{seeing} of 2.0, the third one 10
+    detections with a \texttt{seeing} of 3.0. Do we really want the
+    global \texttt{seeing} value to be 2.0?}{}
+\item \texttt{OBSCODE} (IAU Observatory code): Hard-coded value
+  defined in \texttt{src/ppMops.h} (value \texttt{F51});
+  \commentFromSC{2012-09-18}{I'm surprised that it's defined locally
+    and not in some high-level project header file}{}
+\item \texttt{MAGZP} (Magnitude zero point): Set by \texttt{zp}
+  argument value;
+\item \texttt{MAGZPERR} (Error in magnitude zero point): Set by
+  \texttt{zp\_error} argument value;
+\item \texttt{ASTRORMS} (Error in magnitude zero point): Set by
+  \texttt{astrom\_rms} argument value;
+\item \texttt{CMFVERSION} (CMF version): Set by \texttt{version}
+  argument value but possibly modified by first \texttt{EXTTYPE}
+  value;
+  \commentFromSC{2012-09-18}{Depends on the order of the input FITS
+    file and their \texttt{EXTTYPE} value (e.g. if \texttt{-version 0}
+    is used as argument and two files are used, one with
+    \texttt{EXTTYPE} of 1, the other with \texttt{EXTTYPE} of
+    2). However we do not expect to have different values for
+    \texttt{EXTTYPE}, do we?}{}
+\end{itemize}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\subsubsection{Detection Parameters: Extension Details}
+\label{sec-implementation-write-detection}
+
+If no detection is present in any detections set, an extension is
+still created and contains exactly one row of undefined values
+(\texttt{NaN} for floating-point data, 0 for integral types).
+
+To resolve any ambiguity, we will note the parameter named
+\texttt{param} which was built for the detection $j$ in the set of
+detections ${\cal D}_{i}$ will be denoted by ${\cal
+  D}_{ij}(\mathtt{param})$ where \texttt{param} was defined in
+paragraph~\ref{sec-implementation-read}. When the \texttt{param}
+parameter is the exact copy of the value associated to the keyword
+\texttt{INPUT\_KEY}, we will write it as ${\cal
+  D}_{ij}(\mathtt{INPUT\_KEY})$ (note the use of the uppercase
+letters).
+
+For each detection $j$ in each detections set ${\cal D}_{i}$, the
+following products are written to the output FITS file:
+\begin{itemize}
+\item \texttt{RA} associated to ${\cal D}_{ij}(\mathtt{ra})$ (which is
+  identical to ${\cal D}_{ij}(\mathtt{RA\_PSF})$);
+\item \texttt{RA\_ERR} associated to ${\cal D}_{ij}(\mathtt{raErr})$;
+\item \texttt{DEC} associated to ${\cal D}_{ij}(\mathtt{dec})$ (which
+  is identical to ${\cal D}_{ij}(\mathtt{DEC\_PSF})$);
+\item \texttt{DEC\_ERR} associated to ${\cal
+    D}_{ij}(\mathtt{decErr})$;
+\item \texttt{MAG} associated to ${\cal D}_{ij}(\mathtt{mag})$;
+\item \texttt{MAG\_ERR} associated to ${\cal D}_{ij}(\mathtt{magErr})$
+  (which is identical to ${\cal
+    D}_{ij}(\mathtt{PSF\_INST\_MAG\_SIG})$);
+\item \texttt{PSF\_CHI2} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_CHISQ})$;
+\item \texttt{PSF\_DOF} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_NDOF})$;
+\item \texttt{CR\_SIGNIFICANCE} associated to ${\cal
+    D}_{ij}(\mathtt{CR\_NSIGMA})$;
+\item \texttt{EXT\_SIGNIFICANCE} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_NSIGMA})$;
+\item \texttt{PSF\_MAJOR} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_MAJOR})$;
+\item \texttt{PSF\_MINOR} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_MINOR})$;
+\item \texttt{PSF\_THETA} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_THETA})$;
+\item \texttt{PSF\_QUALITY} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_QF})$;
+\item \texttt{PSF\_NPIX} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_NPIX})$;
+\item \texttt{MOMENTS\_XX} associated to ${\cal
+    D}_{ij}(\mathtt{MOMENTS\_XX})$;
+\item \texttt{MOMENTS\_XY} associated to ${\cal
+    D}_{ij}(\mathtt{MOMENTS\_XY})$;
+\item \texttt{MOMENTS\_YY} associated to ${\cal
+    D}_{ij}(\mathtt{MOMENTS\_YY})$;
+\item \texttt{N\_POS} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_NPOS})$;
+\item \texttt{F\_POS} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_FRATIO})$;
+\item \texttt{RATIO\_BAD} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_NRATIO\_BAD})$;
+\item \texttt{RATIO\_MASK} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_NRATIO\_MASK})$;
+\item \texttt{RATIO\_ALL} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_NRATIO\_ALL})$;
+\item \texttt{FLAGS} associated to ${\cal D}_{ij}(\mathtt{FLAGS})$;
+\item \texttt{DIFF\_SKYFILE\_ID} associated to ${\cal
+    D}_{i}(\mathtt{diffSkyfileId})$ (that is, the \texttt{diff\_id} of
+  the file which was used to compute the difference);
+\item \texttt{IPP\_IDET} associated to ${\cal
+    D}_{ij}(\mathtt{IPP\_DET})$ (since it is the position of the
+  detection if the $i$th diff file, it is not very useful. However
+  gaps in the numbering show that detections have been removed.
+\item \texttt{PSF\_INST\_FLUX} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_INST\_FLUX})$;
+\item \texttt{PSF\_INST\_FLUX\_SIG} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_INST\_FLUX\_SIG})$;
+\item \texttt{AP\_MAG} associated to ${\cal D}_{ij}(\mathtt{AP\_MAG})$;
+\item \texttt{AP\_MAG\_RAW} associated to ${\cal
+    D}_{ij}(\mathtt{AP\_MAG\_RAW})$;
+\item \texttt{AP\_MAG\_RADIUS} associated to ${\cal
+    D}_{ij}(\mathtt{AP\_MAG\_RADIUS})$;
+\item \texttt{AP\_FLUX} associated to ${\cal D}_{ij}(\mathtt{AP\_FLUX})$;
+\item \texttt{AP\_FLUX\_SIG} associated to ${\cal
+    D}_{ij}(\mathtt{AP\_FLUX\_SIG})$;
+\item \texttt{PEAK\_FLUX\_AS\_MAG} associated to ${\cal
+    D}_{ij}(\mathtt{PEAK\_FLUX\_AS\_MAG})$;
+\item \texttt{CAL\_PSF\_MAG} associated to ${\cal
+    D}_{ij}(\mathtt{CAL\_PSF\_MAG})$;
+\item \texttt{CAL\_PSF\_MAG\_SIG} associated to ${\cal
+    D}_{ij}(\mathtt{CAL\_PSF\_MAG\_SIG})$;
+\item \texttt{SKY} associated to ${\cal D}_{ij}(\mathtt{SKY})$;
+\item \texttt{SKY\_SIGMA} associated to ${\cal D}_{ij}(\mathtt{SKY\_SIGMA})$;
+\item \texttt{PSF\_QF\_PERFECT} associated to ${\cal
+    D}_{ij}(\mathtt{PSF\_QF\_PERFECT})$;
+\item \texttt{MOMENTS\_R1} associated to ${\cal D}_{ij}(\mathtt{MOMENTS\_R1})$;
+\item \texttt{MOMENTS\_RH} associated to ${\cal D}_{ij}(\mathtt{MOMENTS\_RH})$;
+\item \texttt{KRON\_FLUX} associated to ${\cal D}_{ij}(\mathtt{KRON\_FLUX})$;
+\item \texttt{KRON\_FLUX\_ERR} associated to ${\cal
+    D}_{ij}(\mathtt{KRON\_FLUX\_ERR})$;
+\item \texttt{KRON\_FLUX\_INNER} associated to ${\cal
+    D}_{ij}(\mathtt{KRON\_FLUX\_INNER})$;
+\item \texttt{KRON\_FLUX\_OUTER} associated to ${\cal
+    D}_{ij}(\mathtt{KRON\_FLUX\_OUTER})$;
+\item \texttt{DIFF\_R\_P} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_R\_P})$;
+\item \texttt{DIFF\_SN\_P} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_SN\_P})$;
+\item \texttt{DIFF\_R\_M} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_R\_M})$;
+\item \texttt{DIFF\_SN\_M} associated to ${\cal
+    D}_{ij}(\mathtt{DIFF\_SN\_M})$;
+\item \texttt{FLAGS2} associated to ${\cal D}_{ij}(\mathtt{FLAGS2})$;
+\item \texttt{N\_FRAMES} associated to ${\cal
+    D}_{ij}(\mathtt{N\_FRAMES})$;
+\item \texttt{PADDING} associated to ${\cal
+    D}_{ij}(\mathtt{PADDING})$;
+\item \texttt{X\_EXT} associated to ${\cal D}_{ij}(\mathtt{X\_EXT})$;
+\item \texttt{Y\_EXT} associated to ${\cal D}_{ij}(\mathtt{Y\_EXT})$;
+\item \texttt{X\_EXT\_SIG} associated to ${\cal
+    D}_{ij}(\mathtt{X\_EXT\_SIG})$;
+\item \texttt{Y\_EXT\_SIG} associated to ${\cal
+    D}_{ij}(\mathtt{Y\_EXT\_SIG})$;
+\item \texttt{EXT\_INST\_MAG} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_INST\_MAG})$;
+\item \texttt{EXT\_INST\_MAG\_SIG} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_INST\_MAG\_SIG})$;
+\item \texttt{NPARAMS} associated to ${\cal
+    D}_{ij}(\mathtt{NPARAMS})$;
+\item \texttt{EXT\_WIDTH\_MAJ} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_WIDTH\_MAJ})$;
+\item \texttt{EXT\_WIDTH\_MIN} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_WIDTH\_MIN})$;
+\item \texttt{EXT\_THETA} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_THETA})$;
+\item \texttt{EXT\_WIDTH\_MAJ\_ERR} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_WIDTH\_MAJ\_ERR})$;
+\item \texttt{EXT\_WIDTH\_MIN\_ERR} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_WIDTH\_MIN\_ERR})$;
+\item \texttt{EXT\_THETA\_ERR} associated to ${\cal
+    D}_{ij}(\mathtt{EXT\_THETA\_ERR})$;
+\end{itemize}
+
+\subsection{Testing}
+\label{sec-implementation-test}
+
+No test data have been provided.
+
+\commentFromSC{2012-09-18}{No data exists to test the software. It
+  would be good to make sure that the products are consistent at least
+  (1) From one software release to another; (2) From one software
+  execution to another; (3) To check if the product depends one the
+  order in which the input data are ingested and processed. Stress
+  tests could also be imagined, e.g. involving large data sets}{ }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newpage
 \section{Obsolete Stuff?}
