Index: trunk/doc/release.2015/ps1.calibration/calibration.tex
===================================================================
--- trunk/doc/release.2015/ps1.calibration/calibration.tex	(revision 39834)
+++ trunk/doc/release.2015/ps1.calibration/calibration.tex	(revision 39835)
@@ -283,12 +283,29 @@
 {\bf WCS Keywords} When this polynomial representation is written to
 the output files, a set of WCS keywords are used to define the
-astrometric transformation elements.  It is necessary to 
+astrometric transformation elements.  It is necessary to transform the
+simply polynomials above into an alternate form:
 \begin{eqnarray}
 P & = & \sum_{i,j} C^P_{i,j} (X_{\rm chip} - X_0)^i (Y_{\rm chip} - Y_0)^j \\
 Q & = & \sum_{i,j} C^Q_{i,j} (X_{\rm chip} - X_0)^i (Y_{\rm chip} - Y_0)^j 
 \end{eqnarray}
-where $X_0, Y_0$ is the reference pixel, represented in the header as 
+
+\note{need to discuss the WCS keywords, both standard and
+  non-standard, used to represent these polynomial transformations}
+
+\begin{verbatim}
+CTYPE1,2 : RA---WRP, DEC--WRP & RA---DIS, DEC--DIS (ill-defined since the WRP entries do not generate RA,DEC)
+CRVAL1,2 : C^{L,M}_{0,0}
+CRPIX1,2 : X_0, Y_0
+PC001001 : C^{L}_{1,0}
+PC001002 : C^{L}_{0,1}
+PC002001 : C^{M}_{1,0}
+PC002002 : C^{M}_{0,1}
+PCA1XiYj : C^{L}_{i,j}
+PCA2XiYj : C^{M}_{i,j}
+\end{verbatim}
 
 \section{Real-time Calibration}
+
+\subsection{Overview}
 
 As images are processed by the data analysis system, every exposure is
@@ -333,12 +350,80 @@
 under the single common focal plane to tangent plane transformation.  
 
+\subsection{Cross-Correlation Search}
+
 The first step of the analysis is to attempt to find the match between
-the reference stars and the detected objects.  \code{psastro} uses a 
-
-\code{smf} 
+the reference stars and the detected objects.  \code{psastro} uses 2D
+cross correlation to search for the match.  The guess astrometry
+calibration is used to define a predicted set of $X^{\rm ref}_{\rm
+  chip}, Y^{\rm ref}_{\rm chip}$ values for the reference catalog
+stars.  For all possible pairs between the two lists, the values of
+\[
+$\Delta X = X^{\rm ref}_{\rm chip} - X^{\rm obs}_{\rm chip}\\
+$\Delta Y = Y^{\rm ref}_{\rm chip} - Y^{\rm obs}_{\rm chip}
+\]
+are generated.  The collection of $\Delta X, \Delta Y$ values are
+collected in a 2D histogram with sampling of \note{XXX} pixels and the
+peak pixel is identified.  If the astrometry guess were perfect, this
+peak pixel would be expected to lie at (0,0) and contain all of the
+matched stars.  However, the astrometric guess may be wrong in
+several ways.  An error in the constant term above, $C^P_{0,0},
+C^Q_{0,0}$ shifts the peak to another pixel, from which $C^P_{0,0},
+C^Q_{0,0}$ can easily be determined.  An error in the plate scale or a
+rotation will smear out the peak pixel potentially across many pixels
+in the 2D histogram.  
+
+To find a good match in the face of plate scale and rotation errors,
+the cross correlation analysis above is performed for a series of
+trials in which the scale and rotation are perturbed from the nominal
+value by a small amount.  For each trial, the peak pixel is found and
+a figure of merit is measured.  The figure of merit is defined as
+$\frac{\sigma^2_x + \sigma^2_y}{N_p^4}$ where $\sigma^2_{x,y}$ are the
+second moment of $\Delta X,Y$ for the star pairs associated with the
+peak pixel, and $N_p$ is the number of star pairs in the peak.  This
+figure of merit is thus most sensitive to a narrow distribution with
+many matched pairs.  For the PS1 exposures, rotation offsets of (-1.0,
+-0.5, 0.0, 0.5, 1.0) degrees, and plate scales of (+1\%, 0, -1\%) of
+the nominal plate scale are tested.  The best match among these 15
+cross-correlation tests is selected and used to generate a better
+astrometry guess for the chip.
+
+\subsection{Chip Polynomial Fits}
+
+The astrometry solution from the cross correlation step above is again
+used to selected matches between the reference stars and observed
+stars in the image.  The matching radius starts off quite large, and a
+series of fits is performed to generate the transformation between
+chip and tangent plane coordinates.  Three clipping iterations are
+performed, with outliers $> 3 \sigma$ rejected on each pass, where
+here $\sigma$ is determined from the distribution of the residuals in
+each dimension (X,Y) independently.  After each fit cycle, the matches
+are redetermined using a smaller radius and the fit re-tried.  
+
+\subsection{Mosaic Astrometry Polynomial Fits}
+
+The astrometry solutions from the independent chip fits are used to
+generate a single model for the camera-wide distortion terms.  The
+goal is to determine the two stage fit (chip $\rtarrow$ focal plane
+$\rtarrow$ tangent plane).  There are a number of degenerate terms
+between these two levels of transformation, most obviously between the
+parameters which define the constant offset from chip to focal plane
+($C^{L,M}_{0,0}$) and those which define the offset from focal plane
+to tangent plane ($C^{P,Q}_{0,0}$).  We limit ($C^{P,Q}_{0,0}$) to be
+0,0 to remove this degeneracy.  \note{disucss the measurement of the
+  camera distortion via the gradient}
+
+Once the common distortion coming from the optics and atmosphere have
+been modeled, \code{psastro} determines polynomial transformations
+from the 60 chips to the focal plane coordinate system.  In this
+stage, \note{NN} iterations of the chip fits are performed.  Before
+each iteration, the reference stars and detected objects are matched
+using the current best set of transformations.  These fits start with
+low order (1) and large matching radius (\note{XX}) and reduced the
+radius while allowing the order to increaes, up to 3rd order for the
+final iterations.  \note{quality of the fits as a result of this stage}.
+
+\note{describe the output smf file?}
 
 \section{DVO Description}
-
-
 
 \section{Photometry Calibration}
