Index: /trunk/doc/ipptools/outline.tex
===================================================================
--- /trunk/doc/ipptools/outline.tex	(revision 5058)
+++ /trunk/doc/ipptools/outline.tex	(revision 5059)
@@ -351,4 +351,15 @@
     - update MasterDetrendRun
 
+Missing Modules
+
+  load from DVO
+  load PS astrom table
+  load guide-star table
+  imastro
+  mosastro
+  read WCS / write WCS
+  detrend-image selection
+  measure fringe pattern
+
 \end{verbatim}
 \end{document}
Index: /trunk/doc/pslib/ChangeLogSDRS.tex
===================================================================
--- /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 5058)
+++ /trunk/doc/pslib/ChangeLogSDRS.tex	(revision 5059)
@@ -1,3 +1,3 @@
-%%% $Id: ChangeLogSDRS.tex,v 1.171 2005-09-13 21:28:03 eugene Exp $
+%%% $Id: ChangeLogSDRS.tex,v 1.172 2005-09-16 01:56:17 eugene Exp $
 
 \subsection{Changes from version 00 to version 01}
@@ -793,2 +793,13 @@
 \end{itemize}
 
+\subsection{Changes from Revision 16 (13 Sept 2005) to present}
+
+\begin{itemize}
+\item moved param constraints to \code{psMinConstrain}
+\item changed type requirement on psMinimize functions to just F64
+\item changed psMinimize input arguments to accept weight not sigma
+\item changed psPolynomial masks from char to psU8.
+\item changed \code{psImage.col0,row0} changed from const.
+
+\end{itemize}
+
Index: /trunk/doc/pslib/psLibADD.tex
===================================================================
--- /trunk/doc/pslib/psLibADD.tex	(revision 5058)
+++ /trunk/doc/pslib/psLibADD.tex	(revision 5059)
@@ -1,3 +1,3 @@
-%%% $Id: psLibADD.tex,v 1.85 2005-07-12 04:18:56 eugene Exp $
+%%% $Id: psLibADD.tex,v 1.86 2005-09-16 01:56:17 eugene Exp $
 \documentclass[panstarrs]{panstarrs}
 
@@ -324,18 +324,55 @@
 
 \begin{itemize}
-\item Perform the Robust Histogram Statistics algorithm above
-\item Smooth the resulting histogram with a Gaussian with $\sigma_s$ =
-  1 bin.
+\item Perform the Robust Histogram Statistics algorithm above,
+  yielding an estimated standard deviation, $\sigma$.
+
+\item Generate a new histogram for the data sample setting a bin size,
+  $d\sigma$, based on the estimated standard deviation and the number
+  of data points in the inner 50 percentile ($N_{\rm 50}$) as follows:
+
+\begin{itemize}
+\item let $dN = (\sigma / d\sigma) = 0.017 N_{50}$
+\item limit $dN$ to the range 1 to 5.
+\item set the bin size $d\sigma = \sigma / dN$
+\end{itemize}
+
+\item Smooth the resulting histogram with a Gaussian with $\sigma_x$ =
+  1 bin in this new histogram.
 \item Find the bin with the peak value in the range $\pm 2 \sigma$ of
   the robust histogram median.
-\item Fit a Gaussian to the bins in the range $\pm 2 \sigma$ of
-  the robust histogram median.
+
+\item Fit a Gaussian to the bins in the range $\pm 20 \sigma$ of the
+  robust histogram median. Limit the fit range to the data range, if
+  the latter is less then $\pm 20 \sigma$.  If the data range is small
+  compared to the estimated $\sigma$, fit at least 4 bins of the
+  hisgram centered on the robust histogram median.
+
 \item The robust mean $\mbox{mean}_r$ is derived directly from the
   fitted Gaussian mean.  
 \item The robust standard deviation, $\sigma_r$, is determined by
   subtracting the smoothing scale in quadrature: $\sigma_r^2 =
-  \sigma^2 - \sigma_s^2$
+  \sigma_{\rm fit}^2 - \sigma_s^2$
 \end{itemize}
 
+To explain the choice of the histogram bin size: a histogram of a
+Gaussian distribution with bin size $d\sigma$ will have approximately
+$(2.35 \sigma/d\sigma)$ bins covering the range LQ to UQ.  Thus, the
+average number of points per bin ($N_{\rm bin}$) in that interval will
+be $N_{50} / (2.35 \sigma/d\sigma)$.  The value of $d\sigma$ should be
+no larger than $\sigma$, regardless of the number of points, to avoid
+too much undersampling.  The value of $d\sigma$ should also be no
+smaller than $5\sigma$, again regardless of the number of points, to
+avoid excessive oversample.  Intermediate to those two values, the bin
+size is choosen to keep about 25 points per bin.  Thus, the bin size
+($d\sigma$) is set to about:
+\[
+d\sigma = 2.35 \sigma (N_{\rm bin}/N_{50}) = (25 \times 2.35) (\sigma/N_{50})
+\]
+With the limitation that $\sigma/d\sigma$ should be limited on one end
+to the value 1, and the other to the value 5.  The easiest way to set
+this limit is to define dN to be:
+\[
+dN = (\sigma / d\sigma) = (N_{50} / N_{\rm bin}) / 2.35 = 0.017 * N_{50}
+\]
 \subsubsection{Histograms}
 
Index: /trunk/doc/pslib/psLibSDRS.tex
===================================================================
--- /trunk/doc/pslib/psLibSDRS.tex	(revision 5058)
+++ /trunk/doc/pslib/psLibSDRS.tex	(revision 5059)
@@ -1,3 +1,3 @@
-%%% $Id: psLibSDRS.tex,v 1.339 2005-09-15 20:53:06 price Exp $
+%%% $Id: psLibSDRS.tex,v 1.340 2005-09-16 01:56:17 eugene Exp $
 \documentclass[panstarrs,spec]{panstarrs}
 
@@ -3449,6 +3449,6 @@
     const int numCols;                  ///< Number of columns in image
     const int numRows;                  ///< Number of rows in image.
-    const int col0;                     ///< Column position relative to parent.
-    const int row0;                     ///< Row position relative to parent.
+    int col0;                           ///< Column position relative to parent.
+    int row0;                           ///< Row position relative to parent.
     union {
         psS8  **S8;                     ///< Pointers to char data
@@ -4488,5 +4488,5 @@
     psF64 *coeff;                       ///< Coefficients
     psF64 *coeffErr;                    ///< Error in coefficients
-    char *mask;                         ///< Coefficient mask
+    psMaskType *mask;                   ///< Coefficient mask
 } psPolynomial1D;
 \end{datatype}
@@ -4500,5 +4500,5 @@
     psF64 **coeff;                      ///< Coefficients
     psF64 **coeffErr;                   ///< Error in coefficients
-    char **mask;                        ///< Coefficients mask
+    psMaskType **mask;                  ///< Coefficients mask
 } psPolynomial2D;
 \end{datatype}
@@ -4669,6 +4669,21 @@
 the minimization analysis.  The maximum number of iterations is
 specified by \code{maxIter}, while the maximum tolerance for
-convergence is \code{tol}.  Four parameter vectors describe the
-behavior of individual parameters.  The \code{paramMask} vector
+convergence is \code{tol}.  The output information carried by the
+structure consists of the value of the function at the minimum
+(\code{value}), the number of iterations performed (\code{iter}) and
+last change in tolerance before returning (\code{lastDelta}).
+
+\begin{datatype}
+typedef struct {
+    const int maxIter;                  ///< Maximum number of iterations
+    const float tol;                    ///< Tolerance to reach
+    float value;                        ///< Value after minimization
+    int iter;                           ///< Actual number of iterations performed
+    float lastDelta;                    ///< Last change before quitting
+} psMinimization;
+\end{datatype}
+
+We define the \code{psMinConstrain} structure to define values which
+constrain the allowed parameter values.  The \code{paramMask} vector
 defines the free (0) or frozen (not 0) parameters.  The
 \code{paramMin} defines the minimum allowed value for each parameter,
@@ -4680,16 +4695,8 @@
 swing is saturated to the limit (with the correct sign).  Any of these
 parameter vectors may be set to \code{NULL}, in which case the concept
-is ignored in the analysis.  The output information carried by the
-structure consists of the value of the function at the minimum
-(\code{value}), the number of iterations performed (\code{iter}) and
-last change in tolerance before returning (\code{lastDelta}).
+is ignored in the analysis.
 
 \begin{datatype}
 typedef struct {
-    const int maxIter;                  ///< Maximum number of iterations
-    const float tol;                    ///< Tolerance to reach
-    float value;                        ///< Value after minimization
-    int iter;                           ///< Actual number of iterations performed
-    float lastDelta;                    ///< Last change before quitting
     psVector *paramMask;                ///< valid / invalid parameters
     psVector *paramMax;                 ///< max allowed parameters
@@ -4699,7 +4706,8 @@
 \end{datatype}
 
-The corresponding allocator is:
+The corresponding allocators are:
 \begin{prototype}
 psMinimization *psMinimizationAlloc(int maxIter, float tol);
+psMinConstrain *psMinConstrainAlloc();
 \end{prototype}
 and the parameter vectors are initially set to \code{NULL}.  
@@ -4717,5 +4725,5 @@
 
 Then \code{psMinimizeLMChi2} shall fit the specified function,
-\code{func}, to a set of measurements, \code{x,y,yErr}, using the
+\code{func}, to a set of measurements, \code{x,y,yWt}, using the
 Levenberg-Marquardt method:
 
@@ -4724,7 +4732,8 @@
                       psImage *covar, 
                       psVector *params,
+		      psMinConstrain *constrain,
                       const psArray  *x, 
                       const psVector *y,
-                      const psVector *yErr, 
+                      const psVector *yWt, 
                       psMinimizeLMChi2Func func);
 \end{prototype}
@@ -4755,16 +4764,16 @@
 The measurement ordinates, \code{x}, shall consist of multiple
 vectors, each of which may be passed to the model \code{func}.  If the
-measurement coordinates, \code{y}, and errors, \code{yErr}, are not of
+measurement coordinates, \code{y}, and weights, \code{yWt}, are not of
 the same length as the ordinates array, \code{x}, then the function
 shall generate a warning, and truncate the longest of the
 array/vectors to match the length of the shortest.  The vectors
-contained within the \code{x} array, and the \code{y} and \code{yErr}
-vectors must be of type \code{psF32}.  The \code{yErr} vector may be
+contained within the \code{x} array, and the \code{y} and \code{yWt}
+vectors must be of type \code{psF64}.  The \code{yWt} vector may be
 \code{NULL}, in which case the errors shall be assumed to be
 identical.
 
-\code{paramMask} must be of type \code{psMaskType}, while \code{params}
-must be of type \code{psF32}.  The \code{func} function must be valid
-only for types \code{psF32}, \code{psF64}.
+\code{paramMask} must be of type \code{psMaskType}, while
+\code{params} must be of type \code{psF64}.  The \code{func} function
+must be valid only for type \code{psF64}.
 
 \begin{prototype}
@@ -4785,27 +4794,4 @@
 of the distances.  This vector must be pre-allocated to the
 dimenstions of \code{params}.
-
-%% \subsubsubsection{Pre-defined Functions for LM}
-%% 
-%% We define some commonly used functions for use with the LM
-%% minimization, used for the purpose of performing $\chi^2$ fitting:
-%% 
-%% \begin{prototype}
-%% psMinimizeLMChi2Func psMinimizeLMChi2Gauss1D;
-%% psMinimizeLMChi2Func psMinimizeLMChi2Gauss2D;
-%% \end{prototype}
-%% 
-%% \code{psMinimizeChi2LMGauss1D} shall take as \code{params}, the
-%% normalization, center, and standard deviation of a Gaussian to be fit,
-%% and as \code{x}, a vector containing a single value.  It shall return
-%% the value of the Gaussian at the value, and the derivatives
-%% (\code{deriv}) with respect to each of the parameters.
-%% 
-%% \code{psMinimizeChi2LMGauss2D} shall take, as \code{params}, the
-%% normalization, center (two values), standard deviation (two values)
-%% and position angle of a 2-dimensional Gaussian, and as \code{x}, a
-%% vector containing a position, $(x,y)$.  It shall return the value of
-%% the 2-dimensional Gaussian at the specified point, along with the
-%% derivatives with respect to each of the parameters.
 
 \subsubsection{Powell}
@@ -4827,5 +4813,5 @@
 bool psMinimizePowell(psMinimization *min, 
                       psVector *params, 
-                      const psVector *paramMask,
+		      const psVector *paramMask,
                       const psArray *coords, 
                       psMinimizePowellFunc func);
@@ -4848,5 +4834,5 @@
 bool psMinimizeChi2Powell(psMinimization *min, 
                           psVector *params, 
-			  const psVector *paramMask,
+			  psMinConstrain *constrain,
                           const psArray *coords, 
 			  const psVector *value, 
