Index: trunk/doc/modules/ModulesSDRS.tex
===================================================================
--- trunk/doc/modules/ModulesSDRS.tex	(revision 4091)
+++ trunk/doc/modules/ModulesSDRS.tex	(revision 4176)
@@ -1,3 +1,3 @@
-%%% $Id: ModulesSDRS.tex,v 1.43 2005-06-02 21:22:40 price Exp $
+%%% $Id: ModulesSDRS.tex,v 1.44 2005-06-09 05:15:49 eugene Exp $
 \documentclass[panstarrs]{panstarrs}
 
@@ -204,4 +204,6 @@
 psRegion *pmConfigLookupRegion (psMetadata *config, psMetadata *header, char *name);
 \end{prototype}
+
+\input{CameraImages.tex}
 
 \section{Camera Data Organization \& Camera Geometry}
@@ -573,4 +575,72 @@
 \end{prototype}
 
+\section{Photometry}
+
+\tbd{This section is to be deferred, and for now consists only of
+place holders, with no functional items.}
+
+Photometric observations are performed in an instrumental photometric
+system, and must be related to other photometric systems.  We
+require a data structure which defines a photometric system, as well
+as a structure to define the transformation between photometric
+systems.
+
+The photometric system is defined by the psPhotSystem structure.  
+A photometric system is identified by a human-readable \code{name}
+(ie, SDSS.g, Landolt92.B, GPC1.OTA32.r).  Each photometric system is
+given a unique identifier \code{ID}.  Observations taken with a
+specific camera, detector, and filter represent their own photometric
+system, and it may be necessary to perform transformations between
+these systems.  Photometric systems associated with observations from
+a specific camera/detector/filter combination can be associated with
+those components.
+\begin{datatype}
+typedef struct {
+    const int ID;                       ///< ID number for this photometric system
+    const char *name;                   ///< Name of photometric system
+    const char *camera;                 ///< Camera for photometric system
+    const char *filter;                 ///< Filter used for photometric system
+    const char *detector;               ///< Detector used for photometric system
+} psPhotSystem;
+\end{datatype}
+
+The following structure defines the transformation between two
+photometric systems.
+\begin{datatype}
+typedef struct {
+    psPhotSystem src;                   ///< Source photometric system
+    psPhotSystem dst;                   ///< Destination photometric system
+    psPhotSystem pP, pM;                ///< Primary color reference
+    psPhotSystem sP, sM;                ///< Secondary color reference
+    float pA, sA;                       ///< Color offset for references
+    psPolynomial3D transform;           ///< Transformation from source to destination
+} psPhotTransform;
+\end{datatype}
+
+The transformation between two photometric systems may depend on the
+airmass of the observation and on the colors of the object of
+interest.  For a specific observation, such a transformations can be
+defined as a polynomial function of the color of the star and the
+airmass of the observations.  If sufficient data exists, the
+transformation between the photometric systems may include more than
+one color, constraining the curvature of the stellar spectral energy
+distributions.  This latter term may be significant for stars which
+are highly reddened, for example.  Derived photometric quantities may
+have been corrected for airmass variations, in which case only color
+terms may be measurable.  The structure defines the transformation
+between a source photometric system (\code{src}) and a target
+photometric system (\code{dst}).  The photometric system of a primary
+color is defined by \code{pP, pM} such that the color is constructed
+as $pP - pM$.  A secondary color is defined by \code{sP, sM}.  For
+both, a reference color is specified (\code{pA, sA}): the polynomial
+transformation terms refer to colors in the form $pP - pM - pA$.  The
+transformation is specified as a 3D polynomial.  For a star of
+magnitude $M_{\rm src}$ in the source photometric system, with
+additional magnitude information in the other systems $M_{\rm pP}$,
+$M_{\rm pM}$, $M_{\rm sP}$, $M_{\rm sM}$, observed at an airmass of
+$z$, the magnitude of the star in the target system $M_{\rm dst}$ is
+given by: $M_{\rm dst} = M_{\rm src} + transform(z, M_{\rm pP} -
+M_{\rm pM} - pA, M_{\rm sP} - M_{\rm sM} - sA)$.
+
 \section{Phase 2}
 
@@ -1112,5 +1182,6 @@
   psImage *mask;           // mask to mark pixels associated with object in region
   pmMoments *moments;      // basic moments measure for the object
-  pmModel *models;         // model parameters and type
+  pmModel *modelPSF;       // PSF model parameters and type
+  pmModel *modelFLT;       // FLT model parameters and type
   pmSourceType type;       // best identification of object
 } pmSource;
@@ -1173,27 +1244,33 @@
 function.  The description of the model includes the model parameters
 and their errors, along with the fit $\chi^2$.  The model type is
-specified by the enum \code{pmObjectModel}, specified below.  We
-discuss the details of these models in section~\ref{ObjectModels}.
+identified by code \code{type}, dynamically assigned based on the
+available models (see below).  We discuss the details of these models
+in section~\ref{ObjectModels}.  The model parameters have 4 special
+elements.  The first four elements represent aspects of the source
+which are not specified by the image PSF, even for point sources.  
+These consist of, in order:
+\begin{itemize}
+\item the local sky
+\item the object normalization
+\item the x-coordinate
+\item the y-coordinate
+\end{itemize}
+
+Every source may have two types of models: a PSF model and a FLT
+(floating) model.  The PSF model represents the best fit of the image
+PSF to the specific object.  In this case, the PSF-dependent
+parameters are specified for the object by the PSF, not by the fit.
+The FLT model represents the best fit of the given model to the
+object, with all parameters floating in the fit.
 
 \begin{datatype}
 typedef struct {
-  pmObjectModel type;       // model to be used
-  psVector *params;            // parameter values
-  psVector *dparams;           // parameter errors
+  psS32 type;               // model to be used
+  psVector *params;         // parameter values
+  psVector *dparams;        // parameter errors
   psF32 chisq;              // fit chisq
-  psS32 nDOF;		// number of degrees of freedom
-  psS32 nIter;          // number of iterations
+  psS32 nDOF;		    // number of degrees of freedom
+  psS32 nIter;              // number of iterations
 } pmModel;
-\end{datatype}
-
-\begin{datatype}
-typedef enum {
-  PM_MODEL_GAUSS;
-  PM_MODEL_PGAUSS;
-  PM_MODEL_TWIST_GAUSS;
-  PM_MODEL_WAUSS;
-  PM_MODEL_SERSIC;
-  PM_MODEL_SERSIC_CORE;
-} pmModelType; 
 \end{datatype}
 
@@ -1217,4 +1294,23 @@
 \end{datatype}
 
+It is useful to generate a model to define the point-spread-function
+which describes the flux distribution for unresolved sources in an
+image.  In general, the PSF varies with position in the image.  We
+allow any of the source models defined for the \code{pmModel} to
+represent the PSF.  For a given source model, the 2D spatial variation
+of all of the source parameters, except the first four PSF-independent
+parameters, are represented as polynomial, stored in a \code{psArray}.
+The other elements of the structure define the quality of the PSF
+determination.
+
+\begin{datatype}
+typedef struct {
+    psS32 type;             ///< PSF Model in use
+    psArray *params;	    ///< Model parameters (psPolynomial2D)
+    psF32 chisq;            ///< PSF goodness statistic
+    psS32 nPSFstars;	    ///< number of stars used to measure PSF
+} pmPSF;
+\end{datatype}
+
 \begin{datatype}
 typedef enum {
@@ -1230,4 +1326,70 @@
 pmModel    *pmModelAlloc (pmModelType type);
 \end{prototype}
+
+\subsection{Object Model Abstraction}
+
+The object model functions are defined to allow for the flexible
+addition of new object models.  Every object model, with parameters
+represented by \code{pmModel}, has an associated set of functions
+which provide necessary support operations.  A set of abstract
+functions allow the programmer to select the approriate function or
+property for a specific named object model.
+
+The following function concepts are provided by each model.
+
+\begin{prototype}
+typedef psMinimizeLMChi2Func psModelFunc;
+\end{prototype}
+This function is the model chi-square minimization function for this
+model.
+
+\begin{prototype}
+typedef psF64 (*psModelFlux)(const psVector *params);
+\end{prototype}
+This function returns the integrated flux for the given model
+parameters.
+
+\begin{prototype}
+typedef bool (*psModelGuessFunc)(psModel *model, psSource *source);
+\end{prototype}
+This function provides the model guess parameters based on the details
+of the given source.
+
+\begin{prototype}
+typedef bool (*psModelFromPSFFunc)(psModel *modelPSF, psModel *modelFLT, pmPSF *psf);
+\end{prototype}
+This function constructs the PSF model for the given source based on
+the supplied \code{psf} and the FLT model for the object.  
+
+\begin{prototype}
+typedef psF64 (*psModelRadius)(const psVector *params, double flux);
+\end{prototype}
+This function returns the radius at which the given model and
+parameters achieves the given flux.
+
+Each of the function types above has a corresponding function which
+returns the function given the model type:
+\begin{prototype}
+psModelFunc psModelFunc_GetFunction (psModelType type);
+psModelFlux psModelFlux_GetFunction (psModelType type);
+psModelGuessFunc psModelGuessFunc_GetFunction (psModelType type);
+psModelFromPSFFunc psModelFromPSFFunc_GetFunction (psModelType type);
+psModelRadius psModelRadius_GetFunction (psModelType type);
+\end{prototype}
+
+In addition, the following utility functions return information about
+the specified model:
+
+\begin{prototype}
+psS32 psModelParameterCount (psModelType type);
+psS32 psModelSetType (char *name);
+char *psModelGetType (psModelType type);
+\end{prototype}
+\code{psModelParameterCount} returns the number of parameters for the
+given model.  The remaining functions lookup the name or identifying
+code for the model from the other concept.  Model names are character
+strings in all caps of the form \code{GAUSS}.  Names are invarient
+between multiple compliations of the library, but the model numbers
+are not and should only be used within programs.
 
 \subsection{Basic Object Detection APIs}
