Index: /trunk/psLib/src/math/psMinimize.c
===================================================================
--- /trunk/psLib/src/math/psMinimize.c	(revision 4991)
+++ /trunk/psLib/src/math/psMinimize.c	(revision 4992)
@@ -10,6 +10,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.135 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-09-11 22:18:40 $
+ *  @version $Revision: 1.136 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:29 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -306,5 +306,5 @@
     PS_ASSERT_VECTOR_NON_NULL(beta, NAN);
     PS_ASSERT_VECTOR_NON_NULL(params, NAN);
-    PS_ASSERT_VECTOR_NON_NULL(x, NAN);
+    PS_ASSERT_PTR_NON_NULL(x, NAN);
     PS_ASSERT_VECTOR_NON_NULL(y, NAN);
     PS_ASSERT_VECTOR_NON_NULL(dy, NAN);
Index: /trunk/psModules/src/pmAstrometry.c
===================================================================
--- /trunk/psModules/src/pmAstrometry.c	(revision 4991)
+++ /trunk/psModules/src/pmAstrometry.c	(revision 4992)
@@ -8,6 +8,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-16 02:29:29 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-11 22:25:39 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -106,5 +106,5 @@
 }
 
-
+// XXX: Verify these default values for row0, col0, rowBins, colBins
 pmReadout *pmReadoutAlloc(pmCell *cell)
 {
@@ -707,4 +707,5 @@
 */
 
+// XXX: How should we handle errors?  What if psMetadataLookup() is NULL?
 psMetadataItem *pmReadoutGetConcept(pmReadout *readout, const char *concept)
 {
@@ -794,8 +795,8 @@
 }
 
-psRegion *pmCellGetTrimSec(pmCell *cell) // CELL.TRIMSEC
+psRegion pmCellGetTrimSec(pmCell *cell) // CELL.TRIMSEC
 {
     psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.TRIMSEC");
-    return((psRegion *) tmp->data.V);
+    return((psRegion) *((psRegion *) (tmp->data.V)));
 }
 
@@ -824,14 +825,15 @@
 }
 
-psPixelCoord *pmCellGetBin(pmCell *cell) // CELL.BIN
+
+psPixelCoord pmCellGetBin(pmCell *cell) // CELL.BIN
 {
     psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.BIN");
-    return((psPixelCoord *) tmp->data.V);
-}
-
-psPixelCoord *pmCellGetParity(pmCell *cell) // CELL.PARITY
+    return((psPixelCoord)  *((psPixelCoord *) (tmp->data.V)));
+}
+
+psPixelCoord pmCellGetParity(pmCell *cell) // CELL.PARITY
 {
     psMetadataItem *tmp = pmCellGetConcept(cell, "CELL.PARITY");
-    return((psPixelCoord *) tmp->data.V);
+    return((psPixelCoord)  *((psPixelCoord *) (tmp->data.V)));
 }
 
Index: /trunk/psModules/src/pmAstrometry.h
===================================================================
--- /trunk/psModules/src/pmAstrometry.h	(revision 4991)
+++ /trunk/psModules/src/pmAstrometry.h	(revision 4992)
@@ -8,6 +8,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-08-16 02:29:29 $
+*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-11 22:25:39 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -441,11 +441,11 @@
 psTime *pmCellGetTime(pmCell *cell); // CELL.TIME
 psList *pmCellGetBiasSec(pmCell *cell); // CELL.BIASSEC
-psRegion *pmCellGetTrimSec(pmCell *cell); // CELL.TRIMSEC
+psRegion pmCellGetTrimSec(pmCell *cell); // CELL.TRIMSEC
 float pmCellGetGain(pmCell *cell); // CELL.GAIN
 float pmCellGetReadNoise(pmCell *cell); // CELL.READNOISE
 float pmCellGetSaturation(pmCell *cell); // CELL.SATURATION
 float pmCellGetBad(pmCell *cell); // CELL.BAD
-psPixelCoord *pmCellGetBin(pmCell *cell); // CELL.BIN
-psPixelCoord *pmCellGetParity(pmCell *cell); // CELL.PARITY
+psPixelCoord pmCellGetBin(pmCell *cell); // CELL.BIN
+psPixelCoord pmCellGetParity(pmCell *cell); // CELL.PARITY
 float pmReadoutGetExposure(pmReadout *readout); // READOUT.EXPOSURE
 float pmReadoutGetDarkTime(pmReadout *readout); // READOUT.DARKTIME
Index: /trunk/psModules/src/pmImageCombine.c
===================================================================
--- /trunk/psModules/src/pmImageCombine.c	(revision 4991)
+++ /trunk/psModules/src/pmImageCombine.c	(revision 4992)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-29 01:39:10 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
@@ -308,9 +308,11 @@
 /******************************************************************************
 XXX: Directly from Paul Price
-XXX: Must add mask parameter, use it in gradient calculation.
  *****************************************************************************/
-static psF32 CalcGradient(psImage *image,
-                          psS32 x,
-                          psS32 y)
+static psF32 CalcGradient(
+    psImage *image,
+    psImage *imageMask,
+    psS32 x,
+    psS32 y
+)
 {
     psTrace("ImageCombine.CalcGradient", 4, "Calling CalcGradient(%d, %d)\n", x, y);
@@ -324,13 +326,34 @@
     int yMin = PS_MAX(y - 1, 0);
     int yMax = PS_MIN(y + 1, image->numRows - 1);
-    for (int j = yMin; j <= yMax; j++) {
-        for (int i = xMin; i <= xMax; i++) {
-            if ((i != x) && (j != y)) {
-                pixels->data.F32[num] = image->data.F32[j][i];
-                mask->data.U8[num] = 0;
-                num++;
+    if (imageMask != NULL) {
+        for (int j = yMin; j <= yMax; j++) {
+            for (int i = xMin; i <= xMax; i++) {
+                if ((i != x) && (j != y) && (0 == imageMask->data.U8[j][i])) {
+                    pixels->data.F32[num] = image->data.F32[j][i];
+                    mask->data.U8[num] = 0;
+                    num++;
+                } else {
+                    mask->data.U8[num] = 1;
+                }
             }
         }
-    }
+    } else {
+        //
+        // This code is simply the previous loop without the imageMask.
+        // XXX: Consider restructuring this.
+        //
+        for (int j = yMin; j <= yMax; j++) {
+            for (int i = xMin; i <= xMax; i++) {
+                if ((i != x) && (j != y)) {
+                    pixels->data.F32[num] = image->data.F32[j][i];
+                    mask->data.U8[num] = 0;
+                    num++;
+                } else {
+                    mask->data.U8[num] = 1;
+                }
+            }
+        }
+    }
+
     pixels->n = num;
     mask->n = num;
@@ -472,16 +495,32 @@
 XXX: The inToOut and outToIn transforms are confusing.  Verify that what
      I think they mean syncs with PWP.
-XXX: Must add mask parameter, use it in gradient calculation.
  *****************************************************************************/
-psArray *pmRejectPixels(const psArray *images,          ///< Array of input images
-                        const psArray *errors,          ///< The pixels which were rejected in the combination
-                        const psArray *inToOut,         ///< Transformation from input to output system
-                        const psArray *outToIn,         ///< Transformation from output to input system
-                        psF32 rejThreshold,             ///< Rejection threshold
-                        psF32 gradLimit                 ///< Gradient limit
-                       )
+psArray *pmRejectPixels(
+    const psArray *images,              ///< Array of input images
+    const psArray *masks,               ///< Array of input image masks
+    const psArray *errors,              ///< The pixels which were rejected in the combination
+    const psArray *inToOut,             ///< Transformation from input to output system
+    const psArray *outToIn,             ///< Transformation from output to input system
+    psF32 rejThreshold,                 ///< Rejection threshold
+    psF32 gradLimit                     ///< Gradient limit
+)
 {
     psTrace("ImageCombine.pmRejectPixels", 3, "Calling pmRejectPixels()\n");
     PS_ASSERT_PTR_NON_NULL(images, NULL);
+    for (psS32 im = 0 ; im < images->n ; im++) {
+        psImage *tmpImage = (psImage *) images->data[im];
+        PS_ASSERT_IMAGE_NON_NULL(tmpImage, NULL);
+        PS_ASSERT_IMAGE_NON_EMPTY(tmpImage, NULL);
+        PS_ASSERT_IMAGE_TYPE(tmpImage, PS_TYPE_F32, NULL);
+        if (masks != NULL) {
+            PS_ASSERT_INT_EQUAL(images->n, masks->n, NULL);
+            psImage *tmpMask = (psImage *) masks->data[im];
+            PS_ASSERT_IMAGE_NON_NULL(tmpMask, NULL);
+            PS_ASSERT_IMAGE_NON_EMPTY(tmpMask, NULL);
+            PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL);
+            PS_ASSERT_IMAGES_SIZE_EQUAL(tmpImage, tmpMask, NULL);
+        }
+        PS_ASSERT_IMAGES_SIZE_EQUAL(((psImage *) images->data[0]), tmpImage, NULL);
+    }
     PS_ASSERT_PTR_NON_NULL(errors, NULL);
     PS_ASSERT_PTR_NON_NULL(inToOut, NULL);
@@ -492,5 +531,4 @@
     PS_ASSERT_INT_EQUAL(numImages, inToOut->n, NULL);
     PS_ASSERT_INT_EQUAL(numImages, outToIn->n, NULL);
-    // XXX: Loop through all images, ensure their sizes are equal
 
     //
@@ -570,4 +608,8 @@
                     if (im != otherImg) {
                         // Map the outCoords to inCoords that for otherImg space.
+                        psImage *tmpMask = NULL;
+                        if (masks != NULL) {
+                            tmpMask = masks->data[otherImg];
+                        }
                         psPlaneTransformApply(inCoords,
                                               (psPlaneTransform * )outToIn->data[otherImg],
@@ -577,5 +619,5 @@
                         if ((xPix >= 0) && (xPix <= ((psImage*)(images->data[otherImg]))->numCols - 1) &&
                                 (yPix >= 0) && (yPix <= ((psImage*)(images->data[otherImg]))->numRows - 1)) {
-                            meanGrads += CalcGradient(images->data[otherImg], xPix, yPix);
+                            meanGrads += CalcGradient(images->data[otherImg], tmpMask, xPix, yPix);
                             numGrads++;
                         }
Index: /trunk/psModules/src/pmImageCombine.h
===================================================================
--- /trunk/psModules/src/pmImageCombine.h	(revision 4991)
+++ /trunk/psModules/src/pmImageCombine.h	(revision 4992)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-13 19:36:12 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -26,22 +26,25 @@
 #include "pslib.h"
 
-psImage *pmCombineImages(psImage *combine,              ///< Combined image (output)
-                         psArray **questionablePixels,  ///< Array of rejection masks
-                         const psArray *images,         ///< Array of input images
-                         const psArray *errors,         ///< Array of input error images
-                         const psArray *masks,          ///< Array of input masks
-                         psU32 maskVal,                 ///< Mask value
-                         const psPixels *pixels,        ///< Pixels to combine
-                         psS32 numIter,                 ///< Number of rejection iterations
-                         psF32 sigmaClip,               ///< Number of standard deviations at which to reject
-                         const psStats *stats           ///< Statistics to use in the combination
-                        );
+psImage *pmCombineImages(
+    psImage *combine,                   ///< Combined image (output)
+    psArray **questionablePixels,       ///< Array of rejection masks
+    const psArray *images,              ///< Array of input images
+    const psArray *errors,              ///< Array of input error images
+    const psArray *masks,               ///< Array of input masks
+    psU32 maskVal,                      ///< Mask value
+    const psPixels *pixels,             ///< Pixels to combine
+    psS32 numIter,                      ///< Number of rejection iterations
+    psF32 sigmaClip,                    ///< Number of standard deviations at which to reject
+    const psStats *stats                ///< Statistics to use in the combination
+);
 
-psArray *pmRejectPixels(const psArray *images,          ///< Array of input images
-                        const psArray *errors,          ///< The pixels which were rejected in the combination
-                        const psArray *inToOut,         ///< Transformation from input to output system
-                        const psArray *outToIn,         ///< Transformation from output to input system
-                        psF32 rejThreshold,             ///< Rejection threshold
-                        psF32 gradLimit                 ///< Gradient limit
-                       );
+psArray *pmRejectPixels(
+    const psArray *images,              ///< Array of input images
+    const psArray *masks,               ///< Array of input image masks
+    const psArray *errors,              ///< The pixels which were rejected in the combination
+    const psArray *inToOut,             ///< Transformation from input to output system
+    const psArray *outToIn,             ///< Transformation from output to input system
+    psF32 rejThreshold,                 ///< Rejection threshold
+    psF32 gradLimit                     ///< Gradient limit
+);
 #endif
Index: /trunk/psModules/src/pmImageSubtract.c
===================================================================
--- /trunk/psModules/src/pmImageSubtract.c	(revision 4991)
+++ /trunk/psModules/src/pmImageSubtract.c	(revision 4992)
@@ -7,6 +7,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-07-19 01:44:48 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -124,6 +124,6 @@
     tmp->subIndex = 0;
     tmp->preCalc = NULL;
-    tmp->p_size = size;
-    tmp->p_spatialOrder = spatialOrder;
+    tmp->size = size;
+    tmp->spatialOrder = spatialOrder;
 
     //
@@ -220,6 +220,6 @@
     tmp->yOrder = psVectorAlloc(nBF, PS_TYPE_F32);
     tmp->subIndex = 0;
-    tmp->p_size = size;
-    tmp->p_spatialOrder = spatialOrder;
+    tmp->size = size;
+    tmp->spatialOrder = spatialOrder;
     tmp->preCalc = psArrayAlloc(nBF);
 
@@ -499,6 +499,6 @@
     psTrace("ImageSubtract.IsisKernelConvolve", 4,
             "Calling IsisKernelConvolve(%d, %d, %d)\n", kernelID, col, row);
-    psS32 spatialOrder = kernels->p_spatialOrder;
-    psS32 kernelSize = kernels->p_size;
+    psS32 spatialOrder = kernels->spatialOrder;
+    psS32 kernelSize = kernels->size;
     psS32 xOrder = (psS32) kernels->xOrder->data.F32[kernelID];
     psS32 yOrder = (psS32) kernels->yOrder->data.F32[kernelID];
@@ -557,5 +557,5 @@
     psF32 numRowsHalf = 0.5 * (psF32) input->numRows;
     psF32 background = solution->data.F64[solution->n-1];
-    psS32 spatialOrder = kernels->p_spatialOrder;
+    psS32 spatialOrder = kernels->spatialOrder;
     psF32 conv = background; // Initial convolved value
 
@@ -671,5 +671,5 @@
     psS32 numCols = input->numCols;
     psS32 numRows = input->numRows;
-    psS32 kernelSize = kernels->p_size;
+    psS32 kernelSize = kernels->size;
 
     psImage *convolved = psImageAlloc(numCols, numRows, PS_TYPE_F32);
@@ -746,5 +746,5 @@
         PS_ASSERT_VECTORS_SIZE_EQUAL(kernels->u, kernels->preCalc, false);
     }
-    psS32 kernelSize = kernels->p_size;
+    psS32 kernelSize = kernels->size;
     PS_ASSERT_INT_NONNEGATIVE(footprint, false);
     //
@@ -777,5 +777,5 @@
     psS32 numHalfRows = reference->numRows;
     psS32 numHalfCols = reference->numCols;
-    psS32 spatialOrder = kernels->p_spatialOrder;
+    psS32 spatialOrder = kernels->spatialOrder;
 
     //
@@ -1163,5 +1163,5 @@
     PS_ASSERT_VECTOR_SIZE(solution, nBF+1, NULL);
 
-    psS32 kernelSize = kernels->p_size;
+    psS32 kernelSize = kernels->size;
     int xSize = footprint + kernelSize;
     int ySize = footprint + kernelSize;
@@ -1332,6 +1332,6 @@
 
     psS32 nBF = kernels->u->n;
-    psS32 spatialOrder = kernels->p_spatialOrder;
-    psS32 kernelSize = kernels->p_size;
+    psS32 spatialOrder = kernels->spatialOrder;
+    psS32 kernelSize = kernels->size;
 
     if (out != NULL) {
Index: /trunk/psModules/src/pmImageSubtract.h
===================================================================
--- /trunk/psModules/src/pmImageSubtract.h	(revision 4991)
+++ /trunk/psModules/src/pmImageSubtract.h	(revision 4992)
@@ -7,6 +7,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-06-28 23:23:55 $
+ *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,41 +27,45 @@
 
 typedef enum {
-    PM_SUBTRACTION_KERNEL_POIS,    ///< POIS kernel --- delta functions
-    PM_SUBTRACTION_KERNEL_ISIS     ///< ISIS kernel --- gaussians modified by polynomials
+    PM_SUBTRACTION_KERNEL_POIS,         ///< POIS kernel --- delta functions
+    PM_SUBTRACTION_KERNEL_ISIS          ///< ISIS kernel --- gaussians modified by polynomials
 } pmSubtractionKernelsType;
 
 typedef struct
 {
-    pmSubtractionKernelsType type;   ///< Type ofKernels --- allowing the use of multiple kernels
-    psVector *u, *v;                 ///< Offset (for POIS) or polynomial order (for ISIS)
-    psVector *sigma;                 ///< Width of Gaussian (for ISIS)
-    psVector *xOrder, *yOrder;       ///< Spatial Polynomial order (for all)
-    int subIndex;                    ///< Index of kernel to be subtracted to maintain flux conservation
-    psArray *preCalc;                ///< Array of images containing pre-calculated kernel (to
+    pmSubtractionKernelsType type;      ///< Type ofKernels --- allowing the use of multiple kernels
+    psVector *u, *v;                    ///< Offset (for POIS) or polynomial order (for ISIS)
+    psVector *sigma;                    ///< Width of Gaussian (for ISIS)
+    psVector *xOrder, *yOrder;          ///< Spatial Polynomial order (for all)
+    int subIndex;                       ///< Index of kernel to be subtracted to maintain flux conservation
+    psArray *preCalc;                   ///< Array of images containing pre-calculated kernel (to
     ///< accelerate ISIS; don't use for POIS)
-    psS32 p_size;                    ///< The halfsize of the kernel
-    psS32 p_spatialOrder;            ///< The spatial order of the kernels
+    psS32 size;                         ///< The halfsize of the kernel
+    psS32 spatialOrder;                 ///< The spatial order of the kernels
 }
 psSubtractionKernels;
 
-psSubtractionKernels *pmSubtractionKernelsAllocPOIS(int size,
-        int SpatialOrder);
+psSubtractionKernels *pmSubtractionKernelsAllocPOIS(
+    int size,
+    int SpatialOrder
+);
 
-psSubtractionKernels *pmSubtractionKernelsAllocISIS(const psVector *sigmas,
-        const psVector *orders,
-        int size,
-        int SpatialOrder);
+psSubtractionKernels *pmSubtractionKernelsAllocISIS(
+    const psVector *sigmas,
+    const psVector *orders,
+    int size,
+    int SpatialOrder
+);
 
 typedef enum {
-    PM_STAMP_INIT,                   ///< Initial state
-    PM_STAMP_USED,                   ///< Use this stamp
-    PM_STAMP_REJECTED,               ///< This stamp has been rejected
-    PM_STAMP_RECALC,                 ///< Having been reset, this stamp is to be recalculated
-    PM_STAMP_NONE                    ///< No stamp in this region
+    PM_STAMP_INIT,                      ///< Initial state
+    PM_STAMP_USED,                      ///< Use this stamp
+    PM_STAMP_REJECTED,                  ///< This stamp has been rejected
+    PM_STAMP_RECALC,                    ///< Having been reset, this stamp is to be recalculated
+    PM_STAMP_NONE                       ///< No stamp in this region
 } pmStampStatus;
 
 typedef struct
 {
-    int x, y;      ///< Position
+    int x, y;                           ///< Position
     int p_xSize;
     int p_ySize;
@@ -70,49 +74,54 @@
     int p_yMin;
     int p_yMax;
-    psImage *matrix;     ///< Associated matrix
-    psVector *vector;     ///< Assoicated vector
-    pmStampStatus status;    ///< Status ofstamp
+    psImage *matrix;                    ///< Associated matrix
+    psVector *vector;                   ///< Assoicated vector
+    pmStampStatus status;               ///< Status ofstamp
 }
 pmStamp;
 
-psArray *pmSubtractionFindStamps(psArray *stamps, ///< Output stamps, or NULL
-                                 const psImage *image, ///< Image for which to find stamps
-                                 const psImage *mask, ///< Mask
-                                 psU32 maskVal,  ///< Value for mask
-                                 psF32 threshold, ///< Threshold for stamps in the image
-                                 psS32 xNum,  ///< Number of stamps in x
-                                 psS32 yNum,  ///< Number of stamps in y
-                                 psS32 border  ///< Border around image to ignore (should be size of kernel)
-                                );
+psArray *pmSubtractionFindStamps(
+    psArray *stamps,                    ///< Output stamps, or NULL
+    const psImage *image,               ///< Image for which to find stamps
+    const psImage *mask,                ///< Mask
+    psU32 maskVal,                      ///< Value for mask
+    psF32 threshold,                    ///< Threshold for stamps in the image
+    psS32 xNum,                         ///< Number of stamps in x
+    psS32 yNum,                         ///< Number of stamps in y
+    psS32 border                        ///< Border around image to ignore (should be size of kernel)
+);
 
-bool pmSubtractionCalculateEquation(psArray *stamps, ///< The stamps for which to calculate the equation,
-                                    const psImage *reference, ///< Reference image
-                                    const psImage *input, ///< Input image
-                                    const psSubtractionKernels *kernels, ///< The kernel basis functions
-                                    psS32 footprint ///< Half-size of region over which to calculate equation
-                                   );
+bool pmSubtractionCalculateEquation(
+    psArray *stamps,                    ///< The stamps for which to calculate the equation,
+    const psImage *reference,           ///< Reference image
+    const psImage *input,               ///< Input image
+    const psSubtractionKernels *kernels,///< The kernel basis functions
+    psS32 footprint                     ///< Half-size of region over which to calculate equation
+);
 
 
-psVector *pmSubtractionSolveEquation(psVector *solution, ///< Solution vector, or NULL
-                                     const psArray *stamps ///< Array of stamps
-                                    );
+psVector *pmSubtractionSolveEquation(
+    psVector *solution,                 ///< Solution vector, or NULL
+    const psArray *stamps               ///< Array of stamps
+);
 
-bool pmSubtractionRejectStamps(psArray *stamps,  ///< Array of stamps to check for rejection
-                               psImage *mask,  ///< Mask image
-                               psU32 badStampMaskVal, ///< Value to use in mask for bad stamp
-                               psS32 footprint,  ///< Region to mask if stamp is bad
-                               psF32 sigmaRej,  ///< Number of RMS deviations above zero at which to reject
-                               const psImage *refImage, ///< Reference image
-                               const psImage *inImage, ///< Input image
-                               const psVector *solution, ///< Solution vector
-                               const psSubtractionKernels *kernels ///< Array of kernel parameters
-                              );
+bool pmSubtractionRejectStamps(
+    psArray *stamps,                    ///< Array of stamps to check for rejection
+    psImage *mask,                      ///< Mask image
+    psU32 badStampMaskVal,              ///< Value to use in mask for bad stamp
+    psS32 footprint,                    ///< Region to mask if stamp is bad
+    psF32 sigmaRej,                     ///< Number of RMS deviations above zero at which to reject
+    const psImage *refImage,            ///< Reference image
+    const psImage *inImage,             ///< Input image
+    const psVector *solution,           ///< Solution vector
+    const psSubtractionKernels *kernels ///< Array of kernel parameters
+);
 
-psImage *pmSubtractionKernelImage(psImage *out,
-                                  const psVector *solution,
-                                  const psSubtractionKernels *kernels,
-                                  psF32 x,
-                                  psF32 y
-                                 );
+psImage *pmSubtractionKernelImage(
+    psImage *out,
+    const psVector *solution,
+    const psSubtractionKernels *kernels,
+    psF32 x,
+    psF32 y
+);
 
 #endif
Index: /trunk/psModules/src/pmObjects.c
===================================================================
--- /trunk/psModules/src/pmObjects.c	(revision 4991)
+++ /trunk/psModules/src/pmObjects.c	(revision 4992)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-16 01:10:34 $
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -491,13 +491,13 @@
 
 // XXX: Macro this.
-static bool isItInThisRegion(const psRegion *valid,
+static bool isItInThisRegion(const psRegion valid,
                              psS32 x,
                              psS32 y)
 {
 
-    if ((x >= valid->x0) &&
-            (x <= valid->x1) &&
-            (y >= valid->y0) &&
-            (y <= valid->y1)) {
+    if ((x >= valid.x0) &&
+            (x <= valid.x1) &&
+            (y >= valid.y0) &&
+            (y <= valid.y1)) {
         return(true);
     }
@@ -519,5 +519,5 @@
 psList *pmCullPeaks(psList *peaks,
                     psF32 maxValue,
-                    const psRegion *valid)
+                    const psRegion valid)
 {
     PS_ASSERT_PTR_NON_NULL(peaks, NULL);
@@ -531,6 +531,5 @@
         pmPeak *tmpPeak = (pmPeak *) tmpListElem->data;
         if ((tmpPeak->counts > maxValue) ||
-                ((valid != NULL) &&
-                 (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y)))) {
+                (true == isItInThisRegion(valid, tmpPeak->x, tmpPeak->y))) {
             psListRemoveData(peaks, (psPtr) tmpPeak);
         }
@@ -545,5 +544,5 @@
 // XXX EAM: I changed this to return a new, subset array
 //          rather than alter the existing one
-psArray *pmPeaksSubset(psArray *peaks, psF32 maxValue, const psRegion *valid)
+psArray *pmPeaksSubset(psArray *peaks, psF32 maxValue, const psRegion valid)
 {
     PS_ASSERT_PTR_NON_NULL(peaks, NULL);
@@ -558,8 +557,6 @@
         if (tmpPeak->counts > maxValue)
             continue;
-        if (valid != NULL) {
-            if (isItInThisRegion(valid, tmpPeak->x, tmpPeak->y))
-                continue;
-        }
+        if (isItInThisRegion(valid, tmpPeak->x, tmpPeak->y))
+            continue;
         psArrayAdd (output, 200, tmpPeak);
     }
Index: /trunk/psModules/src/pmObjects.h
===================================================================
--- /trunk/psModules/src/pmObjects.h	(revision 4991)
+++ /trunk/psModules/src/pmObjects.h	(revision 4992)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-16 01:10:34 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -42,6 +42,4 @@
 /** pmPeak data structure
  *  
- *  
- *  
  */
 typedef struct
@@ -55,6 +53,4 @@
 
 /** pmMoments data structure
- *  
- *  
  *  
  */
@@ -75,6 +71,4 @@
 /** pmModelType enumeration
  *  
- *  
- *  
  */
 typedef enum {
@@ -89,6 +83,4 @@
 
 /** pmModel data structure
- *  
- *  
  *  
  */
@@ -194,5 +186,5 @@
     psList *peaks,                      ///< The psList of peaks to be culled
     float maxValue,                     ///< Cull peaks above this value
-    const psRegion *valid               ///< Cull peaks otside this psRegion
+    const psRegion valid               ///< Cull peaks otside this psRegion
 );
 
@@ -399,4 +391,7 @@
 pmModelFromPSFFunc pmModelFromPSFFunc_GetFunction (pmModelType type);
 pmModelRadius pmModelRadius_GetFunction (pmModelType type);
+psS32 pmModelParameterCount(pmModelType type);
+psS32 pmModelSetType(char *name);
+char *pmModelGetType(pmModelType type);
 
 #endif
Index: /trunk/psModules/src/pmReadoutCombine.c
===================================================================
--- /trunk/psModules/src/pmReadoutCombine.c	(revision 4991)
+++ /trunk/psModules/src/pmReadoutCombine.c	(revision 4992)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-16 01:10:34 $
+ *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -102,4 +102,5 @@
         PS_ASSERT_READOUT_NON_EMPTY(tmpReadout, output);
         PS_ASSERT_READOUT_TYPE(tmpReadout, PS_TYPE_F32, output);
+
         outputType = tmpReadout->image->type.type;
 
@@ -242,4 +243,5 @@
             // At this point, we have scanned all input readouts for this
             // one output pixel.
+            //            for (psS32 r = 0; r < numInputs ; r++) printf("(0)tmpPixels->data.F32[%d] is %f\n", r, tmpPixels->data.F32[r]);
 
             // Determine how many pixels lie between fracLow and fracHigh.
@@ -311,4 +313,5 @@
                 }
                 // Calculate the specified statistic on the stack of pixels.
+                //                for (psS32 r = 0; r < numInputs ; r++) printf("(1)tmpPixels->data.F32[%d] is %f\n", r, tmpPixels->data.F32[r]);
                 psStats *rc = psVectorStats(stats,
                                             tmpPixels,
@@ -335,4 +338,5 @@
 
                 // Calculate the specified statistic on the stack of pixels.
+                //                for (psS32 r = 0; r < numInputs ; r++) printf("(2)tmpPixels->data.F32[%d] is %f\n", r, tmpPixels->data.F32[r]);
                 psStats *rc = psVectorStats(stats,
                                             tmpPixels,
Index: /trunk/psModules/test/Makefile.am
===================================================================
--- /trunk/psModules/test/Makefile.am	(revision 4991)
+++ /trunk/psModules/test/Makefile.am	(revision 4992)
@@ -12,5 +12,7 @@
 	tst_pmImageSubtract \
 	tst_pmImageCombine \
-	tst_pmObjects01
+	tst_pmObjects01 \
+	tst_psAstrometry \
+	tst_psAstrometry01
 
 check_PROGRAMS = $(TESTS)
@@ -33,4 +35,6 @@
 tst_pmImageCombine_SOURCES = tst_pmImageCombine.c
 tst_pmObjects01_SOURCES = tst_pmObjects01.c
+tst_psAstrometry_SOURCES = tst_psAstrometry.c
+tst_psAstrometry01_SOURCES = tst_psAstrometry01.c
 
 test: check
Index: /trunk/psModules/test/tst_pmImageCombine.c
===================================================================
--- /trunk/psModules/test/tst_pmImageCombine.c	(revision 4991)
+++ /trunk/psModules/test/tst_pmImageCombine.c	(revision 4992)
@@ -8,7 +8,8 @@
  *
  *  XXX: Must verify the results internally.  Don't use stdout file.
- *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-16 01:10:36 $
+ *  XXX: Must test masks with pmRejectPixels()
+ *
+ *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-11 22:25:39 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -304,9 +305,9 @@
     //
     printf("\n\n\nCalling pmRejectPixels() with acceptable data.  Should generate a psArray.\n");
-    psArray *pixelRejects = pmRejectPixels(images, questionablePixels, expandTransforms,
+    psArray *pixelRejects = pmRejectPixels(images, NULL, questionablePixels, expandTransforms,
                                            contractTransforms, TST00_REJECTION_THRESHOLD,
                                            TST00_GRADIENT_LIMIT);
     if (pixelRejects == NULL) {
-        printf("TEST ERROR: pmCombineImages() returned a NULL psArray.\n");
+        printf("TEST ERROR: pmRejectPixels() returned a NULL psArray.\n");
         testStatus = true;
     } else {
