Index: trunk/doc/modules/CameraImages.tex
===================================================================
--- trunk/doc/modules/CameraImages.tex	(revision 5359)
+++ trunk/doc/modules/CameraImages.tex	(revision 5361)
@@ -774,6 +774,6 @@
 typedef struct {
     double X, Y;
+    double L, M;
     double P, Q;
-    double L, M;
     double R, D;
     double Mag;
@@ -782,6 +782,6 @@
 This structure specifies the coordinate of the detection in each of
 the four necessary coordinate frames: \code{X,Y} define the position
-in the \code{psReadout} frame, \code{P,Q} define the position in the
-\code{psChip} frame, \code{L,M} define the position in the
+in the \code{psReadout} frame, \code{L,M} define the position in the
+\code{psChip} frame, \code{P,Q} define the position in the
 \code{psFPA} frame, \code{R,D} define the position on the Celestial
 Sphere.  \tbd{re-write using psPlane and psSphere?}.  In addition, a
@@ -809,5 +809,5 @@
 determines the matched objects between the two lists.  The input
 sources must have been projected to the Focal Plane coordinates
-(\code{pmAstromObj.P,Q}), and the supplied \code{config} entry must
+(\code{pmAstromObj.L,M}), and the supplied \code{config} entry must
 contain the desired match radius (keyword:
 \code{ASTROM_MATCH_RADIUS}).  The output consists an array of
@@ -860,5 +860,5 @@
 \end{prototype}
 The input sources must have been projected to the Focal Plane
-coordinates (\code{pmAstromObj.P,Q}), and the supplied \code{config}
+coordinates (\code{pmAstromObj.L,M}), and the supplied \code{config}
 entry must contain the following user-defined parameters:
 \begin{itemize}
@@ -875,6 +875,6 @@
 typedef struct {
     double angle;
-    double dP;
-    double dQ;
+    double dL;
+    double dM;
     double minMetric;
     double minVar;
@@ -882,5 +882,5 @@
 } pmAstromGridMatchStats;
 \end{datatype}
-The elements \code{angle}, \code{dP}, \code{dQ} define the best
+The elements \code{angle}, \code{dL}, \code{dM} define the best
 rotation and offset; the element \code{nMatch} indicates the number of
 matched sources which fell within the match bin; the element
@@ -949,2 +949,49 @@
 linear terms and the higher-order terms of the polynomial fits.
 
+A mosaic represents a particular set of challenges when determining an
+astrometric solution.  There is substantial degeneracy between the
+astrometric terms which describe the transformationfrom the chip to
+the focal plane, and the tranformation from the focal plane to the
+tangent plane, in the presence of distortion.  The degeneracy can be
+broken by examining the distortion component in its effect on the
+gradient of the sources position residuals rather than in the source
+positions themselves.  The following function determines the position
+residual, in the tangent plane, as a function of position in the focal
+plane, for a collection of raw measurements and matched reference
+stars.  The configuration data must include the bin size over which
+the gradient is measured (keyword: \code{ASTROM_GRAD_BOX}).  The
+function returns an array of \code{pmAstromGradient} structures,
+defined below.
+\begin{prototype}
+psArray pmAstromMeasureGradients (psArray *st1, psArray *st2, psArray *match, psMetadata *config);
+\end{prototype}
+
+The following data structure carries the information about the
+residual gradient of source positions in the tangent plane
+(\code{P,Q}) as a function of position in the focal plane
+(\code{L,M}).
+\begin{datatype}
+typedef struct {
+    double L;
+    double M;
+    double dPdL;
+    double dPdM;
+    double dQdL;
+    double dQdM;
+} pmAstromGradient;
+\end{datatype}
+
+The gradient set measured above can be fitted with a pair of 2D
+polynomials.  The resulting fits can then be related back to the
+implied polynomials which represent the distortion.  The following
+function performs the fit and applies the result to the distortion
+transformation of the supplied \code{pmFPA} structure.  The
+configuration variable supplies the polynomial order (keyword:
+\code{ASTROM_DISTORT_ORDER}).
+\begin{prototype}
+psArray pmAstromFitDistortion (pmFPA *fpa, psArray *gradients, psMetadata *config);
+\end{prototype}
+
+\tbd{can we use the pmAstromFitMatch func above to fit the remaining
+  power in the chips?}
+
