Index: /branches/eam_branch_20081230/psModules/src/astrom/pmAstrometryObjects.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/astrom/pmAstrometryObjects.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/astrom/pmAstrometryObjects.c	(revision 21079)
@@ -8,6 +8,6 @@
 *  @author EAM, IfA
 *
-*  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2008-11-20 01:26:07 $
+*  @version $Revision: 1.42.6.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2009-01-02 05:13:00 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -227,5 +227,5 @@
 
     // constant errors
-    psVector *mask = psVectorAlloc (match->n, PS_TYPE_U8);
+    psVector *mask = psVectorAlloc (match->n, PS_TYPE_VECTOR_MASK);
     psVectorInit (mask, 0);
 
Index: /branches/eam_branch_20081230/psModules/src/camera/pmCellSquish.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmCellSquish.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmCellSquish.c	(revision 21079)
@@ -12,5 +12,5 @@
 
 
-bool pmCellSquish(pmCell *cell, psMaskType maskVal, bool useShifts)
+bool pmCellSquish(pmCell *cell, psImageMaskType maskVal, bool useShifts)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -116,5 +116,5 @@
     psImage *squishImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Squished image
     psImageInit(squishImage, 0.0);
-    psImage *squishMask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Squished mask
+    psImage *squishMask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Squished mask
     psImageInit(squishMask, 0);
 
@@ -159,5 +159,5 @@
                 squishImage->data.F32[ySquish][xSquish] += image->data.F32[y][x];
                 if (mask) {
-                    squishMask->data.PS_TYPE_MASK_DATA[ySquish][xSquish] |= mask->data.U8[y][x] & maskVal;
+                    squishMask->data.PS_TYPE_IMAGE_MASK_DATA[ySquish][xSquish] |= mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal;
                 }
             }
Index: /branches/eam_branch_20081230/psModules/src/camera/pmCellSquish.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmCellSquish.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmCellSquish.h	(revision 21079)
@@ -7,5 +7,5 @@
 /// already have been read) and masks.
 bool pmCellSquish(pmCell *cell,         ///< Cell to have readouts combined
-                  psMaskType maskVal,   ///< Value to be masked
+                  psImageMaskType maskVal,   ///< Value to be masked
                   bool useShifts        ///< Use the shifts when squishing?
     );
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPABin.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPABin.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPABin.c	(revision 21079)
@@ -9,5 +9,5 @@
 #include "pmFPABin.h"
 
-bool pmReadoutRebin(pmReadout *out, const pmReadout *in, psMaskType maskVal, int xBin, int yBin)
+bool pmReadoutRebin(pmReadout *out, const pmReadout *in, psImageMaskType maskVal, int xBin, int yBin)
 {
     PM_ASSERT_READOUT_NON_NULL(out, false);
@@ -50,5 +50,5 @@
             for (int y = yStart; y < yStop; y++) {
                 for (int x = xStart; x < xStop; x++) {
-                    if (inMask && (inMask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) {
+                    if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {
                         continue;
                     }
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPABin.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPABin.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPABin.h	(revision 21079)
@@ -9,5 +9,5 @@
 bool pmReadoutRebin(pmReadout *out,     ///< Output readout
                     const pmReadout *in,///< Input readout
-                    psMaskType maskVal, ///< Value to mask
+                    psImageMaskType maskVal, ///< Value to mask
                     int xBin, int yBin  ///< Binning factors in x and y
     );
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPAMaskWeight.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPAMaskWeight.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPAMaskWeight.c	(revision 21079)
@@ -42,5 +42,5 @@
             continue;
         }
-        masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
+        masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK);
         psImageInit(masks->data[i], 0);
     }
@@ -98,5 +98,5 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmReadoutSetMask(pmReadout *readout, psMaskType satMask, psMaskType badMask)
+bool pmReadoutSetMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -124,5 +124,5 @@
     if (!readout->mask) {
         // Generate a (throwaway) mask image, if required
-        readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
+        readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK);
     }
     psImage *mask = readout->mask;      // The mask pixels
@@ -131,5 +131,5 @@
     // Dereference pointers for speed
     psF32 **imageData = image->data.F32;// The image
-    psU8  **maskData  = mask->data.U8;  // The mask
+    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA;  // The mask
 
     for (int i = 0; i < image->numRows; i++) {
@@ -153,5 +153,5 @@
 // pixels.  currently, it will set mask bits if (value <= BAD) or (value >= SATURATION)
 // should we optionally ignore these tests?
-bool pmReadoutGenerateMask(pmReadout *readout, psMaskType satMask, psMaskType badMask)
+bool pmReadoutGenerateMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -294,5 +294,5 @@
 }
 
-bool pmReadoutGenerateMaskWeight(pmReadout *readout, psMaskType satMask, psMaskType badMask, bool poisson)
+bool pmReadoutGenerateMaskWeight(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -306,5 +306,5 @@
 }
 
-bool pmCellGenerateMaskWeight(pmCell *cell, psMaskType satMask, psMaskType badMask, bool poisson)
+bool pmCellGenerateMaskWeight(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -321,5 +321,5 @@
 
 
-bool pmReadoutWeightRenormPixels(const pmReadout *readout, psMaskType maskVal,
+bool pmReadoutWeightRenormPixels(const pmReadout *readout, psImageMaskType maskVal,
                                  psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng)
 {
@@ -363,5 +363,5 @@
 
 
-bool pmReadoutWeightRenormPhot(const pmReadout *readout, psMaskType maskVal, int num, float width,
+bool pmReadoutWeightRenormPhot(const pmReadout *readout, psImageMaskType maskVal, int num, float width,
                                psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng)
 {
@@ -411,5 +411,5 @@
     psVector *source = psVectorAlloc(num, PS_TYPE_F32); // Measurements of fake sources
     psVector *guess = psVectorAlloc(num, PS_TYPE_F32); // Guess at significance
-    psVector *photMask = psVectorAlloc(num, PS_TYPE_MASK); // Mask for fluxes
+    psVector *photMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for fluxes
     for (int i = 0; i < num; i++) {
         // Coordinates of interest
@@ -433,5 +433,5 @@
             float yGauss = gauss->data.F32[v]; // Value of Gaussian in y
             for (int u = 0, x = xPix - size; u < fullSize; u++, x++) {
-                if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+                if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                     continue;
                 }
@@ -453,5 +453,5 @@
         }
 
-        photMask->data.PS_TYPE_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
+        photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
                                                 isfinite(sumWeight) && sumGauss > 0 && sumGauss2 > 0) ?
                                                0 : 0xFF);
@@ -493,5 +493,5 @@
         ratio->data.F32[i] = measuredSig / guess->data.F32[i];
         if (guess->data.F32[i] <= 0.0 || source->data.F32[i] <= 0.0 || !isfinite(ratio->data.F32[i])) {
-            photMask->data.PS_TYPE_MASK_DATA[i] = 0xFF;
+            photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xFF;
         }
         psTrace("psModules.camera", 9, "Ratio %d: %f, %f, %f\n",
@@ -523,5 +523,5 @@
 
 
-bool pmReadoutWeightRenorm(const pmReadout *readout, psMaskType maskVal, psStatsOptions meanStat,
+bool pmReadoutWeightRenorm(const pmReadout *readout, psImageMaskType maskVal, psStatsOptions meanStat,
                            psStatsOptions stdevStat, int width, psRandom *rng)
 {
@@ -591,5 +591,5 @@
 
 
-bool pmReadoutMaskNonfinite(pmReadout *readout, psMaskType maskVal)
+bool pmReadoutMaskNonfinite(pmReadout *readout, psImageMaskType maskVal)
 {
     PM_ASSERT_READOUT_NON_NULL(readout, false);
@@ -601,5 +601,5 @@
 
     if (!readout->mask) {
-        readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+        readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     }
     psImage *mask = readout->mask;      // Readout's mask
@@ -608,5 +608,5 @@
         for (int x = 0; x < numCols; x++) {
             if (!isfinite(image->data.F32[y][x]) || (weight && !isfinite(weight->data.F32[y][x]))) {
-                mask->data.PS_TYPE_MASK_DATA[y][x] |= maskVal;
+                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskVal;
             }
         }
@@ -618,5 +618,5 @@
 
 
-bool pmReadoutMaskApply(pmReadout *readout, psMaskType maskVal)
+bool pmReadoutMaskApply(pmReadout *readout, psImageMaskType maskVal)
 {
     PM_ASSERT_READOUT_NON_NULL(readout, false);
@@ -625,5 +625,5 @@
 
     int numCols = readout->image->numCols, numRows = readout->image->numRows; // Size of image
-    psMaskType **maskData = readout->mask->data.PS_TYPE_MASK_DATA; // Dereference mask
+    psImageMaskType **maskData = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask
     psF32 **imageData = readout->image->data.F32;// Dereference image
     psF32 **weightData = readout->weight ? readout->weight->data.F32 : NULL; // Dereference weight map
@@ -644,6 +644,6 @@
 
 
-bool pmReadoutInterpolateBadPixels(pmReadout *readout, psMaskType maskVal, psImageInterpolateMode mode,
-                                   float poorFrac, psMaskType maskPoor, psMaskType maskBad)
+bool pmReadoutInterpolateBadPixels(pmReadout *readout, psImageMaskType maskVal, psImageInterpolateMode mode,
+                                   float poorFrac, psImageMaskType maskPoor, psImageMaskType maskBad)
 {
     PM_ASSERT_READOUT_NON_NULL(readout, false);
@@ -667,14 +667,15 @@
     psVector *imagePix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for image
     psVector *weightPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for weight
-    psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_MASK); // Corresponding values for mask
+    psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_IMAGE_MASK); // Corresponding values for mask
+    // NOTE: maskPix carries the actual image mask values -- do NOT use
+    // PS_TYPE_VECTOR_MASK here; it is storage, and is not treated as a vector mask
 
     long numBad = 0;                    // Number of bad pixels interpolated
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                 double imageValue, weightValue; // Image and weight value from interpolation
-                psMaskType maskValue = 0; // Mask value from interpolation
-                psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue,
-                                                                     x, y, interp);
+                psImageMaskType maskValue = 0; // Mask value from interpolation
+                psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, x, y, interp);
                 if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) {
                     psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y);
@@ -697,5 +698,5 @@
                 imagePix->data.F32[numBad] = imageValue;
                 weightPix->data.F32[numBad] = weightValue;
-                maskPix->data.PS_TYPE_MASK_DATA[numBad] = maskValue;
+                maskPix->data.PS_TYPE_IMAGE_MASK_DATA[numBad] = maskValue;
                 numBad++;
             }
@@ -709,5 +710,5 @@
         image->data.F32[y][x] = imagePix->data.F32[i];
         weight->data.F32[y][x] = weightPix->data.F32[i];
-        mask->data.PS_TYPE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_MASK_DATA[i];
+        mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_IMAGE_MASK_DATA[i];
     }
 
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPAMaskWeight.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPAMaskWeight.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPAMaskWeight.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author Eugene Magnier, IfA
  *
- * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-10-31 21:50:16 $
+ * @version $Revision: 1.16.10.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -42,6 +42,6 @@
 /// iterating using pmReadoutReadNext, in which case the HDU can't be generated.
 bool pmReadoutSetMask(pmReadout *readout, ///< Readout for which to set mask
-                      psMaskType satMask, ///< Mask value to give saturated pixels
-                      psMaskType badMask  ///< Mask value to give bad (low) pixels
+                      psImageMaskType satMask, ///< Mask value to give saturated pixels
+                      psImageMaskType badMask  ///< Mask value to give bad (low) pixels
     );
 
@@ -62,6 +62,6 @@
 /// is suitable for output (complete with HDU entry).  This is intended for most operations.
 bool pmReadoutGenerateMask(pmReadout *readout, ///< Readout for which to generate mask
-                           psMaskType sat, ///< Mask value to give saturated pixels
-                           psMaskType bad ///< Mask value to give bad (low) pixels
+                           psImageMaskType sat, ///< Mask value to give saturated pixels
+                           psImageMaskType bad ///< Mask value to give bad (low) pixels
     );
 
@@ -79,6 +79,6 @@
 /// Calls pmReadoutGenerateMask and pmReadoutGenerateWeight for the readout
 bool pmReadoutGenerateMaskWeight(pmReadout *readout, ///< Readout for which to generate mask and weights
-                                 psMaskType sat, ///< Mask value to give saturated pixels
-                                 psMaskType bad, ///< Mask value to give bad (low) pixels
+                                 psImageMaskType sat, ///< Mask value to give saturated pixels
+                                 psImageMaskType bad, ///< Mask value to give bad (low) pixels
                                  bool poisson ///< Use poisson weights (in addition to read noise)?
                                 );
@@ -88,6 +88,6 @@
 /// Calls pmReadoutGenerateMaskWeight for each readout within the cell.
 bool pmCellGenerateMaskWeight(pmCell *cell, ///< Cell for which to generate mask and weights
-                              psMaskType sat, ///< Mask value to give saturated pixels
-                              psMaskType bad, ///< Mask value to give bad (low) pixels
+                              psImageMaskType sat, ///< Mask value to give saturated pixels
+                              psImageMaskType bad, ///< Mask value to give bad (low) pixels
                               bool poisson ///< Use poisson weights (in addition to read noise)?
                              );
@@ -98,5 +98,5 @@
 bool pmReadoutWeightRenormPixels(
     const pmReadout *readout,           ///< Readout to normalise
-    psMaskType maskVal,                 ///< Value to mask
+    psImageMaskType maskVal,                 ///< Value to mask
     psStatsOptions meanStat,            ///< Statistic to measure the mean (of the variance map)
     psStatsOptions stdevStat,           ///< Statistic to measure the stdev (of the image)
@@ -110,5 +110,5 @@
 bool pmReadoutWeightRenormPhot(
     const pmReadout *readout,           ///< Readout to normalise
-    psMaskType maskVal,                 ///< Value to mask
+    psImageMaskType maskVal,                 ///< Value to mask
     int num,                            ///< Number of instances to measure over the image
     float width,                        ///< Photometry width
@@ -123,5 +123,5 @@
 /// that patch corresponds.
 bool pmReadoutWeightRenorm(const pmReadout *readout, // Readout to normalise
-                           psMaskType maskVal, // Value to mask
+                           psImageMaskType maskVal, // Value to mask
                            psStatsOptions meanStat, // Statistic to measure the mean (of the variance map)
                            psStatsOptions stdevStat, // Statistic to measure the stdev (of the image)
@@ -136,5 +136,5 @@
 /// the provided value.
 bool pmReadoutMaskNonfinite(pmReadout *readout, ///< Readout to mask
-                            psMaskType maskVal ///< Mask value to give non-finite pixels
+                            psImageMaskType maskVal ///< Mask value to give non-finite pixels
     );
 
@@ -145,5 +145,5 @@
 /// sets masked areas to NAN in the image and weight.
 bool pmReadoutMaskApply(pmReadout *readout, ///< Readout to mask
-                        psMaskType maskVal ///< Mask value for which to apply mask
+                        psImageMaskType maskVal ///< Mask value for which to apply mask
     );
 
@@ -152,9 +152,9 @@
 /// Scan the mask image for bad pixels, and interpolate over them using the nominated options
 bool pmReadoutInterpolateBadPixels(pmReadout *readout, ///< Readout to work on
-                                   psMaskType maskVal, ///< Value to mask
+                                   psImageMaskType maskVal, ///< Value to mask
                                    psImageInterpolateMode mode, ///< Interpolation mode
                                    float poorFrac, ///< Maximum bad fraction of kernel for "poor" status
-                                   psMaskType maskPoor, ///< Mask value to give poor pixels
-                                   psMaskType maskBad ///< Mask value to give bad pixels
+                                   psImageMaskType maskPoor, ///< Mask value to give poor pixels
+                                   psImageMaskType maskBad ///< Mask value to give bad pixels
     );
 
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPAMosaic.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPAMosaic.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPAMosaic.c	(revision 21079)
@@ -471,6 +471,4 @@
         numImages++;
 
-        // Only implemented for F32 and U8 images so far.
-        assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8);
         // All input types must be the same
         if (type == 0) {
@@ -537,6 +535,14 @@
         if (xBinSource->data.S32[i] == xBinTarget && yBinSource->data.S32[i] == yBinTarget) {
             switch (type) {
+                COPY_WITH_PARITY_DIFFERENCE(U8);
+                COPY_WITH_PARITY_DIFFERENCE(U16);
+                COPY_WITH_PARITY_DIFFERENCE(U32);
+                COPY_WITH_PARITY_DIFFERENCE(U64);
+                COPY_WITH_PARITY_DIFFERENCE(S8);
+                COPY_WITH_PARITY_DIFFERENCE(S16);
+                COPY_WITH_PARITY_DIFFERENCE(S32);
+                COPY_WITH_PARITY_DIFFERENCE(S64);
                 COPY_WITH_PARITY_DIFFERENCE(F32);
-                COPY_WITH_PARITY_DIFFERENCE(U8);
+                COPY_WITH_PARITY_DIFFERENCE(F64);
               default:
                 psAbort("Should never get here.\n");
@@ -548,6 +554,14 @@
         // We have to do all of the hard work ourselves
         switch (type) {
-            FILL_IN(F32);
-            FILL_IN(U8);
+	    FILL_IN(U8);
+	    FILL_IN(U16);
+	    FILL_IN(U32);
+	    FILL_IN(U64);
+	    FILL_IN(S8);
+	    FILL_IN(S16);
+	    FILL_IN(S32);
+	    FILL_IN(S64);
+	    FILL_IN(F32);
+	    FILL_IN(F64);
           default:
             psAbort("Should never get here.\n");
@@ -730,5 +744,5 @@
                        const pmChip *chip, // Chip to mosaic
                        const pmCell *targetCell, // Cell to which to mosaic
-                       psMaskType blank // Mask value to give blank pixels
+                       psImageMaskType blank // Mask value to give blank pixels
                       )
 {
@@ -838,5 +852,5 @@
                       const pmChip *targetChip, // Chip to which to mosaic
                       const pmCell *targetCell, // Cell to which to mosaic
-                      psMaskType blank  // Mask value to give blank pixels
+                      psImageMaskType blank  // Mask value to give blank pixels
                      )
 {
@@ -994,5 +1008,5 @@
 // the mosaic image.
 
-bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psMaskType blank)
+bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psImageMaskType blank)
 {
     // Target exists, and has only a single cell
@@ -1225,5 +1239,5 @@
 
 
-bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psMaskType blank)
+bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psImageMaskType blank)
 {
     // Target exists, and has only a single chip with single cell
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPAMosaic.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPAMosaic.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPAMosaic.h	(revision 21079)
@@ -4,6 +4,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-06-20 02:22:26 $
+ * @version $Revision: 1.8.74.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
  */
@@ -24,5 +24,5 @@
                   const pmChip *source, ///< Source chip whose cells will be mosaicked
                   bool deepCopy,        ///< Require a deep copy (disregard 'nice' chip)
-                  psMaskType blank      ///< Mask value to give blank pixels
+                  psImageMaskType blank      ///< Mask value to give blank pixels
     );
 
@@ -36,5 +36,5 @@
                  const pmFPA *source,   ///< FPA whose chips and cells will be mosaicked
                  bool deepCopy,         ///< Require a deep copy (disregard 'nice' chip)
-                 psMaskType blank       ///< Mask value to give blank pixels
+                 psImageMaskType blank       ///< Mask value to give blank pixels
                 );
 /// @}
Index: /branches/eam_branch_20081230/psModules/src/camera/pmFPA_JPEG.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmFPA_JPEG.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmFPA_JPEG.c	(revision 21079)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-23 02:00:36 $
+ *  @version $Revision: 1.26.18.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -157,5 +157,5 @@
     psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
     stats->nSubsample = 10000;
-    psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
+    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     float mean = 0, delta = 0;          //
     if (!psImageBackground(stats, NULL, readout->image, readout->mask, maskVal, rng)) {
Index: /branches/eam_branch_20081230/psModules/src/camera/pmHDU.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmHDU.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmHDU.c	(revision 21079)
@@ -167,5 +167,5 @@
                      const psArray *images, // Images to write
                      const psArray *masks, // Masks to use when writing
-                     psMaskType maskVal,// Value to mask
+                     psImageMaskType maskVal,// Value to mask
                      psFits *fits       // FITS file to which to write
                     )
@@ -222,5 +222,5 @@
     PS_ASSERT_PTR_NON_NULL(fits, false);
 
-    psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
+    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     return hduWrite(hdu, hdu->images, hdu->masks, maskVal, fits);
 }
@@ -240,5 +240,5 @@
     PS_ASSERT_PTR_NON_NULL(fits, false);
 
-    psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
+    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     return hduWrite(hdu, hdu->weights, hdu->masks, maskVal, fits);
 }
Index: /branches/eam_branch_20081230/psModules/src/camera/pmReadoutStack.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmReadoutStack.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmReadoutStack.c	(revision 21079)
@@ -78,5 +78,5 @@
 
 // XXX for the moment, use col0, row0, numCols, numRows supplied from the outside
-bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psMaskType blank)
+bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psImageMaskType blank)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -94,5 +94,5 @@
 	// XXX is this an error?
         if (readout->mask) return false;
-	readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+	readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
 	psImageInit(readout->mask, blank);
     }
@@ -163,5 +163,5 @@
 bool pmReadoutUpdateSize(pmReadout *readout, int minCols, int minRows,
                          int numCols, int numRows, bool mask, bool weight,
-                         psMaskType blank)
+                         psImageMaskType blank)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -191,9 +191,9 @@
     if (mask) {
         if (!readout->mask) {
-            readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+            readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
             psImageInit(readout->mask, blank);
         }
         if (readout->mask->numCols < numCols || readout->mask->numRows < numRows) {
-            psImage *newMask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+            psImage *newMask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
             psImageInit(newMask, blank);
             psImageOverlaySection(newMask, readout->mask, readout->col0, readout->row0, "=");
Index: /branches/eam_branch_20081230/psModules/src/camera/pmReadoutStack.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/camera/pmReadoutStack.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/camera/pmReadoutStack.h	(revision 21079)
@@ -14,5 +14,5 @@
                          bool mask,     ///< Worry about the mask?
                          bool weight,   ///< Worry about the weight?
-                         psMaskType blank ///< Mask value to give to blank pixels
+                         psImageMaskType blank ///< Mask value to give to blank pixels
     );
 
@@ -47,5 +47,5 @@
 
 // XXX for the moment, use col0, row0, numCols, numRows supplied from the outside
-bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psMaskType blank);
+bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psImageMaskType blank);
 
 bool pmReadoutStackSetOutputSize(int *col0, int *row0, int *numCols, int *numRows, const psArray *inputs);
Index: /branches/eam_branch_20081230/psModules/src/concepts/pmConceptsStandard.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/concepts/pmConceptsStandard.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/concepts/pmConceptsStandard.c	(revision 21079)
@@ -16,4 +16,6 @@
 #include "pmConceptsWrite.h"
 #include "pmConceptsStandard.h"
+
+// XXX why are these functions not supporting all types (S64, U64 often missing)?
 
 // The functions in this file are intended to be called solely within the psModules concepts code.  For this
@@ -591,7 +593,9 @@
         TYPE_CASE(binning, concept, U16);
         TYPE_CASE(binning, concept, U32);
+        // TYPE_CASE(binning, concept, U64);
         TYPE_CASE(binning, concept, S8);
         TYPE_CASE(binning, concept, S16);
         TYPE_CASE(binning, concept, S32);
+        // TYPE_CASE(binning, concept, S64);
       default:
         psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
Index: /branches/eam_branch_20081230/psModules/src/config/pmConfigMask.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/config/pmConfigMask.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/config/pmConfigMask.c	(revision 21079)
@@ -45,14 +45,14 @@
 };
 // Default values in case a bad mask name and its fallback is not defined
-static const psMaskType defaultMask[] = { 0x00, // DETECTOR
-                                          0x00, // DARK
-                                          0x01, // FLAT
-                                          0x01, // BLANK
-                                          0x00, // RANGE
-                                          0x01, // SAT
-                                          0x01, // LOW
-                                          0x01, // CONV
-                                          0x00, // CR
-                                          0x00  // GHOST
+static const psImageMaskType defaultMask[] = { 0x00, // DETECTOR
+					       0x00, // DARK
+					       0x01, // FLAT
+					       0x01, // BLANK
+					       0x00, // RANGE
+					       0x01, // SAT
+					       0x01, // LOW
+					       0x01, // CONV
+					       0x00, // CR
+					       0x00  // GHOST
 };
 // Other mask names to ensure exist; these shouldn't be combined in the MASK.VALUE
@@ -62,6 +62,6 @@
 };
 
-static bool maskSetValues(psMaskType *outMaskValue, // Value of MASK.VALUE, returned
-                          psMaskType *outMarkValue, // Value of MARK.VALUE, returned
+static bool maskSetValues(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned
+                          psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned
                           psMetadata *source  // Source of mask bits
                           )
@@ -70,5 +70,5 @@
 
     // Ensure all the bad mask names exist, and set the value to catch all bad pixels
-    psMaskType maskValue = 0;           // Value to mask to catch all the bad pixels
+    psImageMaskType maskValue = 0;           // Value to mask to catch all the bad pixels
     for (int i = 0; badMaskNames[i]; i++) {
         const char *name = badMaskNames[i]; // Name for mask
@@ -76,13 +76,13 @@
 
         bool mdok;                      // Status of MD lookup
-        psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask
+        psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); // Value of mask
         if (!value) {
             if (fallback) {
-                value = psMetadataLookupU8(&mdok, source, fallback);
+                value = psMetadataLookupImageMask(&mdok, source, fallback);
             }
             if (!value) {
                 value = defaultMask[i];
             }
-            psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value);
+            psMetadataAddImageMask(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value);
         }
         maskValue |= value;
@@ -93,19 +93,20 @@
         const char *name = otherMaskNames[i]; // Name for mask
         bool mdok;                      // Status of MD lookup
-        psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask
+        psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); // Value of mask
         if (!value) {
-            psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00);
+            psMetadataAddImageMask(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00);
         }
     }
 
     // search for an unset bit to use for MARK:
-    psMaskType markValue = 0x80;
-
-    int nBits = sizeof(psMaskType) * 8;
+    psImageMaskType markValue = 0x00;
+    psImageMaskType markTrial = 0x01;
+
+    int nBits = sizeof(psImageMaskType) * 8;
     for (int i = 0; !markValue && (i < nBits); i++) {
-        if (maskValue & markValue) {
-            markValue >>= 1;
+        if (maskValue & markTrial) {
+            markTrial <<= 1;
         } else {
-            markValue = markValue;
+            markValue = markTrial;
         }
     }
@@ -116,6 +117,6 @@
 
     // update the list with the results
-    psMetadataAddU8(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);
-    psMetadataAddU8(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);
+    psMetadataAddImageMask(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);
+    psMetadataAddImageMask(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);
 
     if (outMaskValue) {
@@ -130,9 +131,9 @@
 
 // Get a mask value by name(s)
-static psMaskType maskGet(psMetadata *source, // Source of masks
-                          const char *masks // Mask values to get
-                          )
-{
-    psMaskType mask = 0;                // Mask value, to return
+static psImageMaskType maskGet(psMetadata *source, // Source of masks
+			       const char *masks // Mask values to get
+			       )
+{
+    psImageMaskType mask = 0;                // Mask value, to return
 
     psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names
@@ -140,5 +141,5 @@
         const char *name = names->data[i]; // Symbolic name of interest
         bool mdok;                      // Status of MD lookup
-        psMaskType value = psMetadataLookupU8(&mdok, source, name);
+        psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name);
         if (!mdok) {
             // Try and generate the value if we can
@@ -148,5 +149,5 @@
                     return 0;
                 }
-                value = psMetadataLookupU8(&mdok, source, name);
+                value = psMetadataLookupImageMask(&mdok, source, name);
                 psAssert(mdok, "Should have generated mask value");
             } else {
@@ -187,5 +188,5 @@
 
 #if 0
-bool pmFPAMaskSetValues(psMaskType *outMaskValue, psMaskType *outMarkValue, pmFPA *fpa)
+bool pmFPAMaskSetValues(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, pmFPA *fpa)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, false);
@@ -194,5 +195,5 @@
 }
 
-psMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)
+psImageMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, 0);
@@ -206,5 +207,5 @@
 }
 
-bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psMaskType maskValue)
+bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psImageMaskType maskValue)
 {
     PS_ASSERT_PTR_NON_NULL(fpa, 0);
@@ -214,5 +215,5 @@
         fpa->masks = psMetadataAlloc();
     }
-    return psMetadataAddU8(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
+    return psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
 }
 
@@ -250,5 +251,5 @@
             continue;
         }
-        psU8 bit = psMetadataLookupU8(&mdok, header, valuekey);
+        psImageMaskType bit = psMetadataLookupImageMask(&mdok, header, valuekey);
         if (!mdok) {
             psWarning("Unable to find header keyword %s when parsing mask", namekey);
@@ -267,5 +268,5 @@
             }
         } else {
-            psMetadataAddU8(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);
+            psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);
         }
     }
@@ -286,5 +287,5 @@
         }
         if (!psMetadataLookup(fpa->masks, item->name)) {
-            psMetadataAddU8(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,
+            psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,
                             item->data.PS_TYPE_MASK_DATA);
         }
@@ -322,5 +323,5 @@
 
         psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
-        psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);
+        psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);
         numMask++;
     }
@@ -333,5 +334,5 @@
 
 
-psMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
+psImageMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
 {
     psAssert(config, "Require configuration");
@@ -348,5 +349,5 @@
 
 
-bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue)
+bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue)
 {
     psAssert(config, "Require configuration");
@@ -359,5 +360,5 @@
     }
 
-    return psMetadataAddU8(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
+    return psMetadataAddImageMask(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
 }
 
@@ -381,8 +382,8 @@
     // versions so that it won't complain later
     if (!psMetadataLookup(recipe, "MASK.VALUE")) {
-        psMetadataAddU8(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);
+        psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);
     }
     if (!psMetadataLookup(recipe, "MARK.VALUE")) {
-        psMetadataAddU8(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);
+        psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);
     }
 
@@ -408,5 +409,5 @@
             continue;
         }
-        psU8 bit = psMetadataLookupU8(&status, header, valuekey);
+        psImageMaskType bit = psMetadataLookupImageMask(&status, header, valuekey);
         if (!status) {
             psWarning("Unable to find header keyword %s when parsing mask", namekey);
@@ -427,7 +428,7 @@
 
         if (already) {
-            if (item && item->data.U8 != bit) {
+            if (item && item->data.PS_TYPE_IMAGE_MASK_DATA != bit) {
                 psWarning("New mask recipe entry doesn't match previously loaded entry: %x vs %x",
-                          bit, item->data.U8);
+                          bit, item->data.PS_TYPE_IMAGE_MASK_DATA);
             }
         } else {
@@ -437,7 +438,7 @@
         if (!item) {
             psWarning("Mask recipe entry %s not in recipe\n", name);
-            psMetadataAddU8(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
+            psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
         } else {
-            item->data.U8 = bit;
+            item->data.PS_TYPE_IMAGE_MASK_DATA = bit;
         }
 
@@ -481,5 +482,5 @@
         }
 
-        if (item->type != PS_DATA_U8) {
+        if (item->type != PS_TYPE_IMAGE_MASK) {
             psWarning("mask recipe entry %s is not a bit value\n", item->name);
             continue;
@@ -490,5 +491,5 @@
 
         psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
-        psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);
+        psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_IMAGE_MASK_DATA);
         nMask++;
     }
@@ -500,5 +501,5 @@
 
 
-bool pmConfigMaskSetBits(psMaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config)
+bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
Index: /branches/eam_branch_20081230/psModules/src/config/pmConfigMask.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/config/pmConfigMask.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/config/pmConfigMask.h	(revision 21079)
@@ -4,6 +4,6 @@
  *  @author Paul Price, IfA
  *
- *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-07-17 20:37:20 $
+ *  @version $Revision: 1.4.30.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *  Copyright 2007 Institute for Astronomy, University of Hawaii
  */
@@ -23,9 +23,9 @@
 ///
 /// The mask values are derived from the MASKS recipe
-psMaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited
+psImageMaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited
                            const pmConfig *config ///< Configuration
     );
 
-bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue);
+bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue);
 
 // replace the named masks in the recipe with values in the header:
@@ -36,5 +36,5 @@
 bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header);
 
-bool pmConfigMaskSetBits(psMaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config);
+bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config);
 
 #endif
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmBias.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmBias.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmBias.c	(revision 21079)
@@ -45,5 +45,5 @@
                 inImage->data.F32[i][j] -= subImage->data.F32[i+yOffset][j+xOffset];
                 if (inMask && subMask) {
-                    inMask->data.U8[i][j] |= subMask->data.U8[i+yOffset][j+xOffset];
+                    inMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] |= subMask->data.PS_TYPE_IMAGE_MASK_DATA[i+yOffset][j+xOffset];
                 }
             }
@@ -54,5 +54,5 @@
                 inImage->data.F32[i][j] -= subImage->data.F32[i+yOffset][j+xOffset] * scale;
                 if (inMask && subMask) {
-                    inMask->data.U8[i][j] |= subMask->data.U8[i+yOffset][j+xOffset];
+                    inMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] |= subMask->data.PS_TYPE_IMAGE_MASK_DATA[i+yOffset][j+xOffset];
                 }
             }
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmDark.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmDark.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmDark.c	(revision 21079)
@@ -103,5 +103,5 @@
 {
     psArray *values = psArrayAlloc(inputs->n);
-    psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for bad readouts
+    psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for bad readouts
     psVector *norm = normConcept ? psVectorAlloc(inputs->n, PS_TYPE_F32) : NULL; // Normalizations for each
     psVector *orders = psVectorAlloc(ordinates->n, PS_TYPE_U8); // Orders for each concept
@@ -121,5 +121,5 @@
         if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) {
             psWarning("Unable to find value of %s for readout %d", normConcept, i);
-            roMask->data.U8[i] = 0xff;
+            roMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
             norm->data.F32[i] = NAN;
             numBadInputs++;
@@ -128,5 +128,5 @@
         if (normValue == 0.0) {
             psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i);
-            roMask->data.U8[i] = 0xff;
+            roMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
             norm->data.F32[i] = NAN;
             numBadInputs++;
@@ -151,5 +151,5 @@
         for (int j = 0; j < inputs->n; j++) {
             psVector *val = values->data[j]; // Value vector for readout
-            if (roMask->data.U8[j]) {
+            if (roMask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
                 val->data.F32[i] = NAN;
                 continue;
@@ -159,5 +159,5 @@
             float value = NAN;          // Value of ordinate
             if (!ordinateLookup(&value, &inRange, ord->name, ord->scale, ord->min, ord->max, readout)) {
-                roMask->data.U8[j] = 0xff;
+                roMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
                 val->data.F32[i] = NAN;
                 numBadInputs++;
@@ -165,5 +165,5 @@
             }
             if (!inRange) {
-                roMask->data.U8[j] = 0xff;
+                roMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
                 val->data.F32[i] = NAN;
                 numBadInputs++;
@@ -263,5 +263,5 @@
 
 // do the combine work for this portion of the output (range is set by input data)
-bool pmDarkCombine(pmCell *output, const psArray *inputs, int iter, float rej, psMaskType maskVal)
+bool pmDarkCombine(pmCell *output, const psArray *inputs, int iter, float rej, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(output, false);
@@ -314,5 +314,5 @@
     // Iterate over pixels, fitting polynomial
     psVector *pixels = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of pixels
-    psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_MASK); // Mask for stack
+    psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for stack
     for (int i = minInputRows; i < maxInputRows; i++) {
         int yOut = i - outReadout->row0; // y position on output readout
@@ -330,6 +330,6 @@
             psVectorInit(mask, 0);
             for (int r = 0; r < inputs->n; r++) {
-                if (roMask->data.U8[r]) {
-                    mask->data.PS_TYPE_MASK_DATA[r] = 0xff;
+                if (roMask->data.PS_TYPE_VECTOR_MASK_DATA[r]) {
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = 0xff;
                     continue;
                 }
@@ -343,10 +343,10 @@
                 }
                 if (readout->mask) {
-                    mask->data.PS_TYPE_MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal);
                 }
 
             }
 
-            if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, maskVal, values, iter, rej)) {
+            if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, 0xff, values, iter, rej)) {
                 psErrorClear();         // Nothing we can do about it
                 psVectorInit(poly->coeff, NAN);
@@ -376,5 +376,5 @@
     const psVector *values = job->args->data[3]; // Values for each ordinate
 
-    psMaskType bad = PS_SCALAR_VALUE(job->args->data[4], U8); // Mask value to give bad pixels
+    psImageMaskType bad = PS_SCALAR_VALUE(job->args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Mask value to give bad pixels
     bool doNorm    = PS_SCALAR_VALUE(job->args->data[5], U8); // Normalise values?
     float norm     = PS_SCALAR_VALUE(job->args->data[6], F32); // Value by which to normalise
@@ -386,5 +386,5 @@
 
 bool pmDarkApplyScan(pmReadout *readout, const pmCell *dark, const psVector *orders, const psVector *values,
-                     psMaskType bad, bool doNorm, float norm, int rowStart, int rowStop)
+                     psImageMaskType bad, bool doNorm, float norm, int rowStart, int rowStop)
 {
     int numCols = readout->image->numCols;
@@ -405,5 +405,5 @@
             readout->image->data.F32[y][x] -= value;
             if (readout->mask && !isfinite(value)) {
-                readout->mask->data.PS_TYPE_MASK_DATA[y][x] = bad;
+                readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = bad;
             }
         }
@@ -414,5 +414,5 @@
 }
 
-bool pmDarkApply(pmReadout *readout, pmCell *dark, psMaskType bad)
+bool pmDarkApply(pmReadout *readout, pmCell *dark, psImageMaskType bad)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -424,5 +424,5 @@
         PS_ASSERT_IMAGE_NON_NULL(readout->mask, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(readout->mask, readout->image, false);
-        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false);
     }
     int numTerms = dark->readouts->n;   // Number of polynomial terms
@@ -496,5 +496,5 @@
             psArrayAdd(job->args, 1, orders);
             psArrayAdd(job->args, 1, values);
-            PS_ARRAY_ADD_SCALAR(job->args, bad, PS_TYPE_MASK);
+            PS_ARRAY_ADD_SCALAR(job->args, bad, PS_TYPE_IMAGE_MASK);
             PS_ARRAY_ADD_SCALAR(job->args, doNorm, PS_TYPE_U8);
             PS_ARRAY_ADD_SCALAR(job->args, norm, PS_TYPE_F32);
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmDark.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmDark.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmDark.h	(revision 21079)
@@ -37,5 +37,5 @@
                    int iter,            // Number of rejection iterations
                    float rej,           // Rejection threshold (standard deviations)
-                   psMaskType maskVal   // Value to mask
+                   psImageMaskType maskVal   // Value to mask
     );
 
@@ -49,5 +49,5 @@
                      const psVector *orders, // Polynomial orders for each ordinate
                      const psVector *values, // Values for each ordinate
-                     psMaskType bad,    // Value to give bad pixels
+                     psImageMaskType bad,    // Value to give bad pixels
                      bool doNorm,       // Normalise values?
                      float norm,        // Value by which to normalise
@@ -58,5 +58,5 @@
 bool pmDarkApply(pmReadout *readout,    // Readout to which to apply dark
                  pmCell *dark,    // Dark to apply
-                 psMaskType bad         // Mask value to give bad pixels
+                 psImageMaskType bad         // Mask value to give bad pixels
     );
 
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmFlatField.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmFlatField.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmFlatField.c	(revision 21079)
@@ -22,5 +22,5 @@
     const psImage *flatMask  = job->args->data[3]; // Flat-field mask
 
-    psMaskType badFlat = PS_SCALAR_VALUE(job->args->data[4],U8);
+    psImageMaskType badFlat = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
     int xOffset        = PS_SCALAR_VALUE(job->args->data[5],S32);
     int yOffset        = PS_SCALAR_VALUE(job->args->data[6],S32);
@@ -38,7 +38,7 @@
             ps##TYPE flatValue = flatImage->data.TYPE[j + yOffset][i + xOffset]; \
             if (!isfinite(flatValue) || flatValue <= 0.0 || \
-                (flatMask && flatMask->data.U8[j + yOffset][i + xOffset])) { \
+                (flatMask && flatMask->data.PS_TYPE_IMAGE_MASK_DATA[j + yOffset][i + xOffset])) { \
                 if (inMask) { \
-                    inMask->data.PS_TYPE_MASK_DATA[j][i] |= badFlat; \
+                    inMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= badFlat; \
                 } \
                 inImage->data.TYPE[j][i] = SPECIAL; \
@@ -51,5 +51,5 @@
 
 bool pmFlatFieldScan(psImage *inImage, psImage *inMask, const psImage *flatImage, const psImage *flatMask,
-                     psMaskType badFlat, int xOffset, int yOffset, int rowStart, int rowStop)
+                     psImageMaskType badFlat, int xOffset, int yOffset, int rowStart, int rowStop)
 {
     switch (inImage->type.type) {
@@ -72,5 +72,5 @@
 }
 
-bool pmFlatField(pmReadout *in, const pmReadout *flat, psMaskType badFlat)
+bool pmFlatField(pmReadout *in, const pmReadout *flat, psImageMaskType badFlat)
 {
     PS_ASSERT_PTR_NON_NULL(in, false);
@@ -81,10 +81,10 @@
     PS_ASSERT_IMAGE_NON_EMPTY(flat->image, false);
     if (in->mask) {
-        PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_IMAGE_MASK, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(in->mask, in->image, false);
     }
     PS_ASSERT_IMAGE_TYPE(flat->image, in->image->type.type, false);
     if (flat->mask) {
-        PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_IMAGE_MASK, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(flat->mask, flat->image, false);
     }
@@ -148,5 +148,5 @@
           psArrayAdd(job->args, 1, flatImage);
           psArrayAdd(job->args, 1, flatMask);
-          PS_ARRAY_ADD_SCALAR(job->args, badFlat, PS_TYPE_U8);
+          PS_ARRAY_ADD_SCALAR(job->args, badFlat, PS_TYPE_IMAGE_MASK);
           PS_ARRAY_ADD_SCALAR(job->args, xOffset, PS_TYPE_S32);
           PS_ARRAY_ADD_SCALAR(job->args, yOffset, PS_TYPE_S32);
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmFlatField.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmFlatField.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmFlatField.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-09-09 04:10:14 $
+ * @version $Revision: 1.14.16.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004-2006 Institute for Astronomy, University of Hawaii
  */
@@ -25,5 +25,5 @@
 bool pmFlatField(pmReadout *in,         ///< Readout with input image
                  const pmReadout *flat,  ///< Readout with flat image
-                 psMaskType badFlat     ///< Mask value to give bad flat pixels
+                 psImageMaskType badFlat     ///< Mask value to give bad flat pixels
                 );
 
@@ -38,5 +38,5 @@
     const psImage *flatImage,           ///< Flat-field image
     const psImage *flatMask,            ///< Flat-field mask
-    psMaskType badFlag,                 ///< Mask value to give bad pixels
+    psImageMaskType badFlag,                 ///< Mask value to give bad pixels
     int xOffset, int yOffset,           ///< Offset between input and flat-field
     int rowStart, int rowStop           ///< Scan range
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmFlatNormalize.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmFlatNormalize.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmFlatNormalize.c	(revision 21079)
@@ -9,4 +9,6 @@
 
 #include "pmFlatNormalize.h"
+
+// XXX this function should take the abstract mask names and set bad values in a more precise way
 
 // I'm not sure that many many iterations are required, but rather suspect that the system converges within a
@@ -55,9 +57,9 @@
     // Take the logarithms
     psImage *flux = psImageCopy(NULL, bgMatrix, PS_TYPE_F32); // Copy of the input flux levels matrix
-    psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_U8); // Mask for bad measurements
+    psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_IMAGE_MASK); // Mask for bad measurements
     psImageInit(fluxMask, 0);
-    psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_U8); // Mask for bad gains
+    psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_VECTOR_MASK); // Mask for bad gains
     psVectorInit(gainMask, 0);
-    psVector *expMask = psVectorAlloc(numExps, PS_TYPE_U8); // Mask for bad exposures
+    psVector *expMask = psVectorAlloc(numExps, PS_TYPE_VECTOR_MASK); // Mask for bad exposures
     psVectorInit(expMask, 0);
     for (int i = 0; i < numChips; i++) {
@@ -75,5 +77,5 @@
             } else {
                 // Blank out this measurement
-                fluxMask->data.U8[j][i] = 1;
+                fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] = 1;
                 flux->data.F32[j][i] = NAN;
             }
@@ -90,5 +92,5 @@
         int numFluxes = 0;              // Number of fluxes
         for (int i = 0; i < numExps; i++) {
-            if (expMask->data.U8[i]) {
+            if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
                 psTrace("psModules.detrend", 7, "Flux for exposure %d is masked.\n", i);
                 continue;
@@ -98,5 +100,5 @@
             int number = 0;             // Number of chips contributing
             for (int j = 0; j < numChips; j++) {
-                if (!gainMask->data.U8[j] && !fluxMask->data.U8[i][j]) {
+                if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && !fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
                     sum += flux->data.F32[i][j] - chipGains->data.F32[j];
                     number++;
@@ -106,5 +108,5 @@
                 expFluxes->data.F32[i] = sum / (float)number;
             } else {
-                expMask->data.U8[i] = 1;
+                expMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
                 expFluxes->data.F32[i] = NAN;
             }
@@ -116,5 +118,5 @@
         int numGains = 0;               // Number of gains
         for (int i = 0; i < numChips; i++) {
-            if (gainMask->data.U8[i]) {
+            if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
                 continue;
             }
@@ -122,5 +124,5 @@
             int number = 0;             // Numer of sources contributing
             for (int j = 0; j < numExps; j++) {
-                if (!fluxMask->data.U8[j][i]) {
+                if (!fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i]) {
                     sum += flux->data.F32[j][i] - expFluxes->data.F32[j];
                     number++;
@@ -130,5 +132,5 @@
                 chipGains->data.F32[i] = sum / (float)number;
             } else {
-                gainMask->data.U8[i] = 1;
+                gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
                 chipGains->data.F32[i] = NAN;
             }
@@ -144,5 +146,5 @@
             diff = 0.0;
             for (int i = 0; i < numChips; i++) {
-                if (gainMask->data.U8[i]) {
+                if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
                     continue;
                 }
@@ -151,5 +153,5 @@
             }
             for (int i = 0; i < numExps; i++) {
-                if (expMask->data.U8[i]) {
+                if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
                     continue;
                 }
@@ -171,10 +173,10 @@
     // Un-log the vectors
     for (int i = 0; i < numChips; i++) {
-        if (!gainMask->data.U8[i]) {
+        if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             chipGains->data.F32[i] = expf(chipGains->data.F32[i]);
         }
     }
     for (int i = 0; i < numExps; i++) {
-        if (!expMask->data.U8[i]) {
+        if (!expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             expFluxes->data.F32[i] = expf(expFluxes->data.F32[i]);
         }
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmFringeStats.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmFringeStats.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmFringeStats.c	(revision 21079)
@@ -70,5 +70,5 @@
     fringe->x = psVectorRecycle(fringe->x, fringe->nRequested, PS_TYPE_F32);
     fringe->y = psVectorRecycle(fringe->y, fringe->nRequested, PS_TYPE_F32);
-    fringe->mask = psVectorRecycle(fringe->mask, fringe->nRequested, PS_TYPE_U8);
+    fringe->mask = psVectorRecycle(fringe->mask, fringe->nRequested, PS_TYPE_VECTOR_MASK);
     fringe->x->n = fringe->y->n = fringe->mask->n = fringe->nRequested;
     psVectorInit(fringe->mask, 0);
@@ -115,5 +115,5 @@
     if (mask) {
         PS_ASSERT_VECTOR_NON_NULL(mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
         PS_ASSERT_VECTOR_SIZE(mask, (long)numRows, false);
     }
@@ -142,9 +142,9 @@
         psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]);
         psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]);
-        psU8 maskValue = 0;
-        if (mask && mask->data.U8[i]) {
+        psVectorMaskType maskValue = 0;
+        if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             maskValue = 0xff;
         }
-        psMetadataAddU8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
+        psMetadataAddVectorMask(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
         table->data[i] = row;
     }
@@ -207,11 +207,11 @@
     psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position
     psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
-    psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
+    psVector *mask = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); // mask
     regions->x = x;
     regions->y = y;
     regions->mask = mask;
 
-    #define READ_REGIONS_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \
-    VECTOR->data.TYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
+    #define READ_REGIONS_ROW(VECTOR, TYPE, DATATYPE, NAME, DESCRIPTION) \
+    VECTOR->data.DATATYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
     if (!mdok) { \
         psError(PS_ERR_IO, true, "Unable to find " #DESCRIPTION " .\n"); \
@@ -224,7 +224,7 @@
     for (long i = 0; i < numRows; i++) {
         psMetadata *row = table->data[i]; // Table row
-        READ_REGIONS_ROW(x, F32, "x", "x position");
-        READ_REGIONS_ROW(y, F32, "y", "y position");
-        READ_REGIONS_ROW(mask, U8, "mask", "mask");
+        READ_REGIONS_ROW(x, F32, F32, "x", "x position");
+        READ_REGIONS_ROW(y, F32, F32, "y", "y position");
+        READ_REGIONS_ROW(mask, VectorMask, PS_TYPE_VECTOR_MASK_DATA, "mask", "mask");
     }
     psFree(table);
@@ -259,5 +259,5 @@
 }
 
-pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, psMaskType maskVal)
+pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(fringe, NULL);
@@ -490,5 +490,5 @@
     newRegions->x = psVectorAlloc(numPoints, PS_TYPE_F32);
     newRegions->y = psVectorAlloc(numPoints, PS_TYPE_F32);
-    newRegions->mask = psVectorAlloc(numPoints, PS_TYPE_U8);
+    newRegions->mask = psVectorAlloc(numPoints, PS_TYPE_VECTOR_MASK);
     pmFringeStats *newStats = pmFringeStatsAlloc(newRegions); // The new list of statistics
 
@@ -500,5 +500,5 @@
         memcpy(&newRegions->x->data.F32[offset], regions->x->data.F32, regions->x->n * sizeof(psF32));
         memcpy(&newRegions->y->data.F32[offset], regions->y->data.F32, regions->y->n * sizeof(psF32));
-        memcpy(&newRegions->mask->data.U8[offset], regions->mask->data.U8, regions->mask->n * sizeof(psU8));
+        memcpy(&newRegions->mask->data.PS_TYPE_VECTOR_MASK_DATA[offset], regions->mask->data.PS_TYPE_VECTOR_MASK_DATA, regions->mask->n * sizeof(psVectorMaskType));
         memcpy(&newStats->f->data.F32[offset], fringe->f->data.F32, fringe->f->n * sizeof(psF32));
         memcpy(&newStats->df->data.F32[offset], fringe->df->data.F32, fringe->df->n * sizeof(psF32));
@@ -549,5 +549,5 @@
     if (mask) {
         PS_ASSERT_VECTOR_NON_NULL(mask, false);
-        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
+        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
         PS_ASSERT_VECTOR_SIZE(mask, (long)numRows, false);
     }
@@ -580,6 +580,6 @@
         psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]);
         psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]);
-        psU8 maskValue = 0;             // Mask value
-        if (mask && mask->data.U8[i]) {
+        psVectorMaskType maskValue = 0;             // Mask value
+        if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             maskValue = 0xff;
         }
@@ -601,5 +601,5 @@
         psFree(df);
 
-        psMetadataAddU8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
+        psMetadataAddVectorMask(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
         table->data[i] = row;
     }
@@ -648,5 +648,5 @@
     psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position
     psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
-    psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
+    psVector *mask = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); // mask
     regions->x = x;
     regions->y = y;
@@ -656,7 +656,7 @@
     psArray *fringes = NULL; // Array of fringes, to return
 
-    #define READ_FRINGES_VECTOR_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \
+    #define READ_FRINGES_VECTOR_ROW(VECTOR, TYPE, DATATYPE, NAME, DESCRIPTION) \
     { \
-        VECTOR->data.TYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
+        VECTOR->data.DATATYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
         if (!mdok) { \
             psError(PS_ERR_IO, true, "Unable to find " #DESCRIPTION " for row %ld.\n", i); \
@@ -686,10 +686,11 @@
     }
 
+    // XXX : need to extend this to support arbitrary types for the vectors on disk
     // Translate the table into vectors
     for (long i = 0; i < numRows; i++) {
         psMetadata *row = table->data[i]; // Table row
-        READ_FRINGES_VECTOR_ROW(x, F32, "x", "x position");
-        READ_FRINGES_VECTOR_ROW(y, F32, "y", "y position");
-        READ_FRINGES_VECTOR_ROW(mask, U8, "mask", "mask");
+        READ_FRINGES_VECTOR_ROW(x, F32, F32, "x", "x position");
+        READ_FRINGES_VECTOR_ROW(y, F32, F32, "y", "y position");
+        READ_FRINGES_VECTOR_ROW(mask, VectorMask, PS_TYPE_VECTOR_MASK_DATA, "mask", "mask");
         READ_FRINGES_ARRAY_ROW(f, F32, "f", "fringe measurement");
         READ_FRINGES_ARRAY_ROW(df, F32, "df", "fringe error");
@@ -782,5 +783,5 @@
             double matrix = 0.0;        // The matrix sum
             for (int k = 0; k < numPoints; k++) {
-                if (!mask->data.U8[k]) {
+                if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[k]) {
                     psF32 f1 = (fringe1) ? fringe1->data.F32[k] : 1.0; // Contribution from i fringe
                     psF32 f2 = (fringe2) ? fringe2->data.F32[k] : 1.0; // Contribution from j fringe
@@ -799,5 +800,5 @@
         double vector = 0.0;            // The vector sum
         for (int k = 0; k < numPoints; k++) {
-            if (!mask->data.U8[k]) {
+            if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[k]) {
                 psF32 f1 = (fringe1) ? fringe1->data.F32[k] : 1.0; // Contribution from fringe 1
                 psF32 s = science->f->data.F32[k]; // Contribution from science measurement
@@ -855,5 +856,5 @@
 
     for (int i = 0; i < diff->n; i++) {
-        if (!mask->data.U8[i]) {
+        if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
             float difference = science->f->data.F32[i] - scale->coeff->data.F32[0];
             for (int j = 0; j < fringes->n; j++) {
@@ -877,5 +878,5 @@
     assert(diffs->type.type == PS_TYPE_F32);
     assert(mask);
-    assert(mask->type.type == PS_TYPE_U8);
+    assert(mask->type.type == PS_TYPE_VECTOR_MASK);
     assert(diffs->n == mask->n);
 
@@ -888,8 +889,8 @@
     int numClipped = 0;                 // Number clipped
     for (int i = 0; i < diffs->n; i++) {
-        psTrace("psModules.detrend", 10, "Region %d (%d): %f\n", i, mask->data.U8[i], diffs->data.F32[i]);
-        if (!mask->data.U8[i] && fabs(diffs->data.F32[i]) > middle + thresh) {
+        psTrace("psModules.detrend", 10, "Region %d (%d): %f\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i], diffs->data.F32[i]);
+        if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] && fabs(diffs->data.F32[i]) > middle + thresh) {
             psTrace("psModules.detrend", 5, "Masking %d: %f\n", i, diffs->data.F32[i]);
-            mask->data.U8[i] = 1;
+            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
             numClipped++;
         }
@@ -931,5 +932,5 @@
     // Set up the mask
     if (!regions->mask) {
-        regions->mask = psVectorAlloc(numRegions, PS_TYPE_U8);
+        regions->mask = psVectorAlloc(numRegions, PS_TYPE_VECTOR_MASK);
         psVectorInit(regions->mask, 0);
     }
@@ -946,5 +947,5 @@
         for (int j = 0; j < numRegions; j++) {
             if (!isfinite(fringe->f->data.F32[j])) {
-                mask->data.U8[j] = 1;
+                mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 1;
                 psTrace("psModules.detrend", 9, "Masking region %d because not finite in fringe %d.\n", j, i);
             }
@@ -956,5 +957,5 @@
     FILE *f = fopen ("fringe.dat", "w");
     for (int j = 0; j < numRegions; j++) {
-	if (mask->data.U8[j]) continue;
+	if (mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) continue;
 	fprintf (f, "%d %f %f ", j, science->f->data.F32[j], science->df->data.F32[j]);
 	for (int i = 0; i < fringes->n; i++) {
@@ -1014,5 +1015,5 @@
 // XXX note that this modifies the input fringe images
 psImage *pmFringeCorrect(pmReadout *readout, pmFringeRegions *fringes, psArray *fringeImages,
-                         psArray *fringeStats, psMaskType maskVal, float rej,
+                         psArray *fringeStats, psImageMaskType maskVal, float rej,
                          unsigned int nIter, float keepFrac)
 {
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmFringeStats.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmFringeStats.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmFringeStats.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-01-24 02:54:15 $
+ * @version $Revision: 1.12.78.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004-2006 Institute for Astronomy, University of Hawaii
  */
@@ -102,5 +102,5 @@
 pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, ///< Fringe regions at which to measure
                                     const pmReadout *readout, ///< Readout for which to measure
-                                    psMaskType maskVal ///< Mask value for image
+                                    psImageMaskType maskVal ///< Mask value for image
                                    );
 
@@ -206,5 +206,5 @@
                          psArray *fringeImages, ///< Fringe template images to use in correction
                          psArray *fringeStats, ///< Fringe stats (for templates) to use in correction
-                         psMaskType maskVal, ///< Value to mask for science image
+                         psImageMaskType maskVal, ///< Value to mask for science image
                          float rej,     ///< Rejection threshold, for pmFringeScaleMeasure
                          unsigned int nIter, ///< Maximum number of iterations, for pmFringeScaleMeasure
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmMaskBadPixels.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmMaskBadPixels.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmMaskBadPixels.c	(revision 21079)
@@ -14,13 +14,13 @@
 #include "pmMaskBadPixels.h"
 
-bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psMaskType maskVal)
+bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(input, false);
     PS_ASSERT_PTR_NON_NULL(input->mask, false);
-    PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_MASK, false);
+    PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_IMAGE_MASK, false);
 
     PS_ASSERT_PTR_NON_NULL(mask, false);
     PS_ASSERT_PTR_NON_NULL(mask->mask, false);
-    PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_MASK, false);
+    PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_IMAGE_MASK, false);
 
     psImage *inMask = input->mask;
@@ -53,7 +53,7 @@
     int offRow = input->row0 - mask->row0;
 
-    // masks are both of type PS_TYPE_MASK
-    psMaskType **exVal = exMask->data.U8;
-    psMaskType **inVal = inMask->data.U8;
+    // masks are both of type PS_TYPE_IMAGE_MASK
+    psImageMaskType **exVal = exMask->data.PS_TYPE_IMAGE_MASK_DATA;
+    psImageMaskType **inVal = inMask->data.PS_TYPE_IMAGE_MASK_DATA;
 
     // apply exMask values
@@ -82,5 +82,5 @@
 
 bool pmMaskFlagSuspectPixels(pmReadout *output, const pmReadout *readout, float median, float stdev,
-                             float rej, psMaskType maskVal)
+                             float rej, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -92,5 +92,5 @@
         PS_ASSERT_IMAGE_NON_EMPTY(readout->mask, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, readout->mask, false);
-        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false);
     }
     PS_ASSERT_PTR_NON_NULL(output, false);
@@ -128,5 +128,5 @@
         for (int x = 0; x < image->numCols; x++) {
             if (fabs((image->data.F32[y][x] - median) / stdev) < rej) continue;
-	    if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) continue;
+	    if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue;
 	    suspect->data.F32[y][x] += 1.0;
         }
@@ -142,5 +142,5 @@
 
 // the maskVal supplied here is the value SET for this mask (ie, it is not used to avoid pixels)
-bool pmMaskIdentifyBadPixels(pmReadout *output, psMaskType maskVal, float thresh, pmMaskIdentifyMode mode)
+bool pmMaskIdentifyBadPixels(pmReadout *output, psImageMaskType maskVal, float thresh, pmMaskIdentifyMode mode)
 {
     PS_ASSERT_PTR_NON_NULL(output, false);
@@ -155,7 +155,7 @@
         PS_ASSERT_IMAGE_NON_EMPTY(output->mask, false);
         PS_ASSERT_IMAGES_SIZE_EQUAL(output->mask, suspects, false);
-        PS_ASSERT_IMAGE_TYPE(output->mask, PS_TYPE_MASK, false);
+        PS_ASSERT_IMAGE_TYPE(output->mask, PS_TYPE_IMAGE_MASK, false);
     } else {
-        output->mask = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_MASK);
+        output->mask = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_IMAGE_MASK);
     }
     int num = psMetadataLookupS32(NULL, output->analysis, PM_MASK_ANALYSIS_NUM); // Number of inputs
@@ -246,5 +246,5 @@
         for (int x = 0; x < suspects->numCols; x++) {
             if (suspects->data.F32[y][x] >= limit) {
-                badpix->data.PS_TYPE_MASK_DATA[y][x] = maskVal;
+                badpix->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskVal;
             }
         }
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmMaskBadPixels.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmMaskBadPixels.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmMaskBadPixels.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author Eugene Magnier, IfA
  *
- * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-03-29 03:10:17 $
+ * @version $Revision: 1.16.44.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Institute for Astronomy, University of Hawaii
  */
@@ -40,5 +40,5 @@
 bool pmMaskBadPixels(pmReadout *input,  ///< Input science image
                      const pmReadout *mask, ///< Mask image to apply
-                     psMaskType maskVal ///< Mask value to apply
+                     psImageMaskType maskVal ///< Mask value to apply
                     );
 
@@ -56,5 +56,5 @@
                              float stdev, ///< Image standard deviation
                              float rej, ///< Rejection threshold (standard deviations)
-                             psMaskType maskVal ///< Mask value for statistics
+                             psImageMaskType maskVal ///< Mask value for statistics
     );
 
@@ -64,5 +64,5 @@
 /// according to the chosen mode.
 bool pmMaskIdentifyBadPixels(pmReadout *output, ///< Output readout, with suspect pixels imageOut
-                             psMaskType maskVal, ///< Value to set for bad pixels
+                             psImageMaskType maskVal, ///< Value to set for bad pixels
                              float thresh, ///< Threshold for bad pixel
                              pmMaskIdentifyMode mode ///< Mode for identifying bad pixels
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmOverscan.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmOverscan.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmOverscan.c	(revision 21079)
@@ -67,10 +67,10 @@
     psVector *reduced = psVectorAlloc(pixels->n, PS_TYPE_F32); // Overscan for each row
     psVector *ordinate = psVectorAlloc(pixels->n, PS_TYPE_F32); // Ordinate
-    psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_U8); // Mask for fitting
+    psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_VECTOR_MASK); // Mask for fitting
 
     for (int i = 0; i < pixels->n; i++) {
         psVector *values = pixels->data[i]; // Vector with overscan values
         if (values->n > 0) {
-            mask->data.U8[i] = 0;
+            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0;
             ordinate->data.F32[i] = 2.0*(float)i/(float)pixels->n - 1.0; // Scale to [-1,1]
             psVectorStats(myStats, values, NULL, NULL, 0);
@@ -82,5 +82,5 @@
         } else {
             // We'll fit this one out
-            mask->data.U8[i] = 1;
+            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
         }
     }
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmRemnance.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmRemnance.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmRemnance.c	(revision 21079)
@@ -13,6 +13,6 @@
 
 bool pmRemnance(pmReadout *ro,           ///< Readout with input image
-                psMaskType maskVal,      ///< Value of mask
-                psMaskType maskRem,       ///< Value to give remance
+                psImageMaskType maskVal,      ///< Value of mask
+                psImageMaskType maskRem,       ///< Value to give remance
                 int size,               ///< Size of accumulation patches
                 float threshold         ///< Threshold for masking
@@ -23,5 +23,7 @@
     PM_ASSERT_READOUT_MASK(ro, false);
 
-    psImage *image = ro->image, *mask = ro->mask; // Mask and image from readout
+    psImage *image = ro->image;
+    psImage *mask = ro->mask; // Mask and image from readout
+
     int numCols = image->numCols, numRows = image->numRows; // Size of image
 
@@ -33,5 +35,5 @@
         psErrorClear();
         psWarning("Unable to calculate image statistics: masking entire readout.");
-        psBinaryOp(mask, mask, "|", psScalarAlloc(maskRem, PS_TYPE_MASK));
+        psBinaryOp(mask, mask, "|", psScalarAlloc(maskRem, PS_TYPE_IMAGE_MASK));
         psFree(stats);
         psFree(rng);
@@ -57,5 +59,5 @@
             }
             for (int y = min; y < max; y++) {
-                if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
+                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
                     continue;
                 }
@@ -84,5 +86,5 @@
             }
             for (int y = 0; y < maxMask; y++) {
-                mask->data.PS_TYPE_MASK_DATA[y][x] |= maskRem;
+                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskRem;
             }
             numMasked += maxMask;
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmRemnance.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmRemnance.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmRemnance.h	(revision 21079)
@@ -13,6 +13,6 @@
 // GPC1 leaves remnance that flows down from where the annoyed pixels are.
 bool pmRemnance(pmReadout *ro,           ///< Readout with input image
-                psMaskType maskVal,      ///< Value of mask
-                psMaskType maskRem,       ///< Value to give remance
+                psImageMaskType maskVal,      ///< Value of mask
+                psImageMaskType maskRem,       ///< Value to give remance
                 int size,               ///< Size of accumulation patches
                 float threshold         ///< Threshold for masking
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmShifts.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmShifts.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmShifts.c	(revision 21079)
@@ -412,5 +412,5 @@
 }
 
-bool pmShiftsConvolve(pmReadout *detrend, const pmCell *source, psMaskType maskVal)
+bool pmShiftsConvolve(pmReadout *detrend, const pmCell *source, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR(detrend, false);
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmShifts.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmShifts.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmShifts.h	(revision 21079)
@@ -46,5 +46,5 @@
 bool pmShiftsConvolve(pmReadout *detrend, ///< Detrend readout to convolve
                       const pmCell *source, ///< Science exposure, containing a shifts kernel
-                      psMaskType maskVal ///< Mask value to smear
+                      psImageMaskType maskVal ///< Mask value to smear
                       );
 
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmShutterCorrection.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmShutterCorrection.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmShutterCorrection.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author Paul Price, IfA
  *
- * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-09-09 04:10:14 $
+ * @version $Revision: 1.21.16.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2006 Institute for Astronomy, University of Hawaii
  */
@@ -91,6 +91,5 @@
     float offref,                       ///< Reference time offset
     int nIter,                          ///< Number of iterations
-    float rej,                          ///< Rejection threshold (sigma)
-    psMaskType maskVal                  ///< Mask value
+    float rej				///< Rejection threshold (sigma)
     );
 
@@ -121,5 +120,5 @@
     int nIter,                          ///< Number of iterations
     float rej,                          ///< Rejection threshold (sigma)
-    psMaskType maskVal                  ///< Mask value
+    psImageMaskType maskVal                  ///< Mask value
     );
 
@@ -135,5 +134,5 @@
     psImage *mask,                      ///< Input mask image
     float exptime,                      ///< Exposure time to which to correct
-    psMaskType blank,                   ///< Mask value to give blank pixels
+    psImageMaskType blank,                   ///< Mask value to give blank pixels
     int rowStart, int rowStop           ///< Range of scan
     );
@@ -145,5 +144,5 @@
     pmReadout *readout,                 ///< Readout to which to apply shutter correction
     const pmReadout *shutter,           ///< Shutter correction readout, with dT for each pixel
-    psMaskType blank                    ///< Value to give blank pixels
+    psImageMaskType blank                    ///< Value to give blank pixels
     );
 
@@ -181,5 +180,5 @@
     psStatsOptions meanStat,            ///< Statistic to use for mean
     psStatsOptions stdevStat,           ///< Statistic to use for stdev
-    psMaskType maskVal,                 ///< Mask value
+    psImageMaskType maskVal,                 ///< Mask value
     psRandom *rng                       ///< Random number generator
     );
@@ -201,10 +200,10 @@
     int nIter,                          ///< Number of iterations
     float rej,                          ///< Rejection threshold (sigma)
-    psMaskType maskVal                  ///< Mask value
+    psImageMaskType maskVal                  ///< Mask value
     );
 
 // prepare outputs for shutter correction
 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs,
-                                        psMaskType maskVal);
+                                        psImageMaskType maskVal);
 
 /// @}
Index: /branches/eam_branch_20081230/psModules/src/detrend/pmSkySubtract.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/detrend/pmSkySubtract.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/detrend/pmSkySubtract.c	(revision 21079)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-04 22:42:48 $
+ *  @version $Revision: 1.3.74.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -114,5 +114,5 @@
 
     psVector *binVector = psVectorAlloc(binFactor * binFactor, PS_TYPE_F32);
-    psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_U8);
+    psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_VECTOR_MASK);
     psStats *myStats = psStatsAlloc(statOptions);
 
@@ -126,8 +126,8 @@
                         binVector->data.F32[count] =
                             origImage->data.F32[row + binRow][col + binCol];
-                        binMask->data.U8[count] = 0;
+                        binMask->data.PS_TYPE_VECTOR_MASK_DATA[count] = 0;
                     } else {
                         binVector->data.F32[count] = 0.0;
-                        binMask->data.U8[count] = 1;
+                        binMask->data.PS_TYPE_VECTOR_MASK_DATA[count] = 1;
                     }
                     count++;
@@ -313,5 +313,5 @@
     PS_ASSERT_IMAGE_NON_NULL(maskImage, NULL);
     PS_ASSERT_IMAGE_NON_EMPTY(maskImage, NULL);
-    PS_ASSERT_IMAGE_TYPE(maskImage, PS_TYPE_U8, NULL);
+    PS_ASSERT_IMAGE_TYPE(maskImage, PS_TYPE_IMAGE_MASK, NULL);
     PS_ASSERT_IMAGES_SIZE_EQUAL(dataImage, maskImage, NULL);
     psS32 oldPolyX = -1;
@@ -361,5 +361,5 @@
     for (x=0;x<dataImage->numRows;x++) {
         for (y=0;y<dataImage->numCols;y++) {
-            if (maskImage->data.U8[x][y] == 0) {
+            if (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[x][y] == 0) {
                 buildSums((psF64) x, (psF64) y, myPoly->nX, myPoly->nY);
 
@@ -572,5 +572,5 @@
 
         if (in->mask != NULL) {
-            binnedMaskImage = psImageCopy(binnedMaskImage, in->mask, PS_TYPE_U8);
+            binnedMaskImage = psImageCopy(binnedMaskImage, in->mask, PS_TYPE_IMAGE_MASK);
             if (binnedMaskImage == NULL) {
                 psError(PS_ERR_UNKNOWN, false, "psImageCopy() returned NULL.  Returning in image.\n");
@@ -581,5 +581,5 @@
             binnedMaskImage = psImageAlloc(binnedImage->numCols,
                                            binnedImage->numRows,
-                                           PS_TYPE_U8);
+                                           PS_TYPE_IMAGE_MASK);
             psImageInit(binnedMaskImage, 0);
         }
@@ -592,5 +592,5 @@
         binnedMaskImage = psImageAlloc(binnedImage->numCols,
                                        binnedImage->numRows,
-                                       PS_TYPE_U8);
+                                       PS_TYPE_IMAGE_MASK);
         psImageInit(binnedMaskImage, 0);
     }
@@ -625,5 +625,5 @@
                 if (fabs(binnedImage->data.F32[row][col] - binnedMean) >
                         (clipSD * binnedStdev)) {
-                    binnedMaskImage->data.U8[row][col] = 1;
+                    binnedMaskImage->data.PS_TYPE_IMAGE_MASK_DATA[row][col] = 1;
                 }
             }
Index: /branches/eam_branch_20081230/psModules/src/imcombine/pmImageCombine.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/imcombine/pmImageCombine.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/imcombine/pmImageCombine.c	(revision 21079)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-04 22:42:48 $
+ *  @version $Revision: 1.12.78.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *
  *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
@@ -17,4 +17,6 @@
  */
 
+// XXX this is somewhat messy and unclear on the masking.
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -53,5 +55,5 @@
 
     buffer->pixels = psVectorAlloc(numImages, PS_TYPE_F32);
-    buffer->masks = psVectorAlloc(numImages, PS_TYPE_MASK);
+    buffer->masks = psVectorAlloc(numImages, PS_TYPE_VECTOR_MASK);
     buffer->errors = psVectorAlloc(numImages, PS_TYPE_F32);
     buffer->stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
@@ -67,5 +69,5 @@
                           const psArray *errors, // Array of input error images
                           const psArray *masks, // Array of input masks
-                          psU32 maskVal, // Mask value
+                          psImageMaskType maskVal, // Mask value
                           psS32 numIter, // Number of rejection iterations
                           psF32 sigmaClip, // Number of standard deviations at which to reject
@@ -115,6 +117,7 @@
         if (masks) {
             psImage *mask = masks->data[i]; // Mask of interest
-            pixelMasks->data.U8[i] = mask->data.U8[y][x];
-        }        // Set the pixel error data, if necessary
+            pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal);
+        }        
+	// Set the pixel error data, if necessary
         if (errors) {
             psImage *error = errors->data[i]; // Error image of interest
@@ -128,5 +131,5 @@
     for (int iter = 0; iter < numIter; iter++) {
         // Combine all the pixels, using the specified stat.
-        if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, maskVal)) {
+        if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, 0xff)) {
             combine->data.F32[y][x] = NAN;
             psFree(buffer);
@@ -148,9 +151,9 @@
         float stdev = stats->sampleStdev;
         for (int i = 0; i < numImages; i++) {
-            if (!(pixelMasks->data.U8[i] & maskVal) &&
+            if (!(pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i] & 0xff) &&
                     fabs(pixelData->data.F32[i] - combinedPixel) > sigmaClip * stdev) {
                 // Reject pixel as questionable
                 numRejects++;
-                pixelMasks->data.U8[i] = maskVal;
+                pixelMasks->data.PS_TYPE_IMAGE_MASK_DATA[i] = 0xff;
                 if (questionablePixels) {
                     // Mark the pixel as questionable
@@ -191,5 +194,5 @@
     const psArray *errors,              ///< Array of input error images
     const psArray *masks,               ///< Array of input masks
-    psU32 maskVal,                      ///< Mask value
+    psImageMaskType maskVal,                      ///< Mask value
     const psPixels *pixels,             ///< Pixels to combine
     psS32 numIter,                      ///< Number of rejection iterations
@@ -231,5 +234,5 @@
             psImage *mask  = masks->data[i];
             PS_ASSERT_IMAGE_SIZE(mask, numCols, numRows, NULL);
-            PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
+            PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
         }
     }
@@ -319,5 +322,5 @@
     int num = 0;
     psVector *pixels = psVectorAlloc(8, PS_TYPE_F32); // Array of pixels
-    psVector *mask = psVectorAlloc(8, PS_TYPE_U8); // Corresponding mask
+    psVector *mask = psVectorAlloc(8, PS_TYPE_VECTOR_MASK); // Corresponding mask
 
     // Get limits
@@ -329,10 +332,10 @@
         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])) {
+                if ((i != x) && (j != y) && (0 == imageMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i])) {
                     pixels->data.F32[num] = image->data.F32[j][i];
-                    mask->data.U8[num] = 0;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0;
                     num++;
                 } else {
-                    mask->data.U8[num] = 1;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 1;
                 }
             }
@@ -347,8 +350,8 @@
                 if ((i != x) && (j != y)) {
                     pixels->data.F32[num] = image->data.F32[j][i];
-                    mask->data.U8[num] = 0;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0;
                     num++;
                 } else {
-                    mask->data.U8[num] = 1;
+                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 1;
                 }
             }
@@ -473,5 +476,5 @@
     for (psS32 i = 0 ; i < image->numRows ; i++) {
         for (psS32 j = 0 ; j < image->numCols ; j++) {
-            imgF32->data.F32[i][j] = (psF32) image->data.U8[i][j];
+            imgF32->data.F32[i][j] = (psF32) image->data.PS_TYPE_IMAGE_MASK_DATA[i][j];
         }
     }
@@ -518,5 +521,5 @@
             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_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL); // XXX really F32??
             PS_ASSERT_IMAGES_SIZE_EQUAL(tmpImage, tmpMask, NULL);
         }
@@ -571,5 +574,5 @@
 
         //
-        // Create a psU8 mask image from the list of cosmic pixels.
+        // Create a psImageMaskType mask image from the list of cosmic pixels.
         //
         psImage *maskImage = NULL;
Index: /branches/eam_branch_20081230/psModules/src/imcombine/pmStack.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/imcombine/pmStack.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/imcombine/pmStack.h	(revision 21079)
@@ -8,6 +8,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-11-01 02:59:33 $
+ * @version $Revision: 1.9.8.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  *
  * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -43,6 +43,6 @@
 bool pmStackCombine(pmReadout *combined,///< Combined readout (output)
                     psArray *input,     ///< Input array of pmStackData
-                    psMaskType maskVal, ///< Mask value of bad pixels
-                    psMaskType bad,     ///< Mask value to give rejected pixels
+                    psImageMaskType maskVal, ///< Mask value of bad pixels
+                    psImageMaskType bad,     ///< Mask value to give rejected pixels
                     int kernelSize,     ///< Half-size of the convolution kernel
                     int numIter,        ///< Number of iterations
Index: /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtraction.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtraction.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtraction.h	(revision 21079)
@@ -6,6 +6,6 @@
  * @author GLG, MHPCC
  *
- * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-11-07 00:03:18 $
+ * @version $Revision: 1.34.6.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004-207 Institute for Astronomy, University of Hawaii
  */
@@ -104,6 +104,6 @@
                            psImage *subMask, ///< Subtraction mask (or NULL)
                            int stride,  ///< Size of convolution patches
-                           psMaskType maskBad, ///< Mask value to give bad pixels
-                           psMaskType maskPoor, ///< Mask value to give poor pixels
+                           psImageMaskType maskBad, ///< Mask value to give bad pixels
+                           psImageMaskType maskPoor, ///< Mask value to give poor pixels
                            float poorFrac, ///< Fraction for "poor"
                            float sysError, ///< Relative systematic error
Index: /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtractionMask.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtractionMask.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtractionMask.h	(revision 21079)
@@ -7,5 +7,5 @@
 psImage *pmSubtractionMask(const psImage *refMask, ///< Mask for the reference image (will be convolved)
                            const psImage *inMask, ///< Mask for the input image, or NULL
-                           psMaskType maskVal, ///< Value to mask out
+                           psImageMaskType maskVal, ///< Value to mask out
                            int size, ///< Half-size of the kernel (pmSubtractionKernels.size)
                            int footprint, ///< Half-size of the kernel footprint
@@ -19,5 +19,5 @@
                          psImage *mask, ///< Mask (or NULL)
                          int size,      ///< Kernel half-size
-                         psMaskType blank ///< Mask value for blank regions
+                         psImageMaskType blank ///< Mask value for blank regions
     );
 
Index: /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtractionMatch.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtractionMatch.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/imcombine/pmSubtractionMatch.h	(revision 21079)
@@ -40,7 +40,7 @@
                         float rej,      ///< Rejection threshold
                         float sysError, ///< Relative systematic error
-                        psMaskType maskVal, ///< Value to mask for input
-                        psMaskType maskBad, ///< Mask for output bad pixels
-                        psMaskType maskPoor, ///< Mask for output poor pixels
+                        psImageMaskType maskVal, ///< Value to mask for input
+                        psImageMaskType maskBad, ///< Mask for output bad pixels
+                        psImageMaskType maskPoor, ///< Mask for output poor pixels
                         float poorFrac, ///< Fraction for "poor"
                         float badFrac,   ///< Maximum fraction of bad input pixels to accept
Index: /branches/eam_branch_20081230/psModules/src/objects/pmModel.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmModel.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmModel.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-12-09 21:16:09 $
+ * @version $Revision: 1.17.4.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  *
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -150,5 +150,5 @@
     pmModel *model,                     ///< The input pmModel
     pmModelOpMode mode,                 ///< mode to control how the model is added into the image
-    psMaskType maskVal                  ///< Value to mask
+    psImageMaskType maskVal		///< Value to mask
 );
 
@@ -168,5 +168,5 @@
     pmModel *model,                     ///< The input pmModel
     pmModelOpMode mode,                 ///< mode to control how the model is added into the image
-    psMaskType maskVal                  ///< Value to mask
+    psImageMaskType maskVal		///< Value to mask
 );
 
@@ -175,5 +175,5 @@
                           pmModel *model,
                           pmModelOpMode mode,
-                          psMaskType maskVal,
+                          psImageMaskType maskVal,
                           int dx,
                           int dy);
@@ -183,5 +183,5 @@
                           pmModel *model,
                           pmModelOpMode mode,
-                          psMaskType maskVal,
+                          psImageMaskType maskVal,
                           int dx,
                           int dy);
Index: /branches/eam_branch_20081230/psModules/src/objects/pmPSF.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmPSF.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmPSF.h	(revision 21079)
@@ -6,6 +6,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-12-09 21:16:09 $
+ * @version $Revision: 1.21.4.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -102,5 +102,5 @@
 double pmPSF_SXYtoModel (psF32 *fittedPar);
 
-bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark);
+bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType mark);
 pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...);
 
Index: /branches/eam_branch_20081230/psModules/src/objects/pmPSFtry.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmPSFtry.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmPSFtry.c	(revision 21079)
@@ -5,6 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.67.4.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-12-31 20:31:29 $
+ *  @version $Revision: 1.67.4.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -193,5 +193,5 @@
         // exclude the poor fits
         if (!status) {
-            psfTry->mask->data.PS_TYPE_IMAGE_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
+            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
             psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y);
             continue;
@@ -283,5 +283,5 @@
     psVector *flux  = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32);
     psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32);
-    psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK);
+    psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_VECTOR_MASK);
 
     // generate the x and y vectors, and mask missing models
@@ -303,6 +303,5 @@
 
     // linear clipped fit of chisq trend vs flux
-    bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask,
-                                              0xff, chisq, NULL, flux);
+    bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 0xff, chisq, NULL, flux);
     psStatsOptions meanStat = psStatsMeanOption(options->stats->options); // Statistic for mean
     psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev
Index: /branches/eam_branch_20081230/psModules/src/objects/pmPSFtry.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmPSFtry.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmPSFtry.h	(revision 21079)
@@ -6,6 +6,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-10-13 02:00:25 $
+ * @version $Revision: 1.20.10.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -48,5 +48,5 @@
     pmPSF      *psf;                    ///< Add comment.
     psArray    *sources;                ///< pointers to the original sources
-    psVector   *mask;                   ///< Add comment.
+    psVector   *mask;                   ///< PS_TYPE_VECTOR_MASK to flag good and bad sources 
     psVector   *metric;                 ///< Add comment.
     psVector   *metricErr;              ///< Add comment.
@@ -89,5 +89,5 @@
  *
  */
-pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType mark);
+pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType mark);
 
 /** pmPSFtryMetric()
Index: /branches/eam_branch_20081230/psModules/src/objects/pmResiduals.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmResiduals.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmResiduals.c	(revision 21079)
@@ -4,6 +4,6 @@
  *
  * @author EAM, IfA
- * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-11-10 01:09:20 $
+ * @version $Revision: 1.3.52.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 IfA, University of Hawaii
  */
@@ -44,4 +44,6 @@
     resid->weight = psImageAlloc (nX, nY, PS_TYPE_F32);
     resid->mask   = psImageAlloc (nX, nY, PS_TYPE_U8);
+    // NOTE : the residual mask is internal only : 1 byte is sufficient
+    // XXX abstract the resid->mask type??
 
     resid->xBin = xBin;
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSource.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSource.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSource.h	(revision 21079)
@@ -3,6 +3,6 @@
  * @author EAM, IfA; GLG, MHPCC
  *
- * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-12-09 21:16:09 $
+ * @version $Revision: 1.26.4.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -210,5 +210,5 @@
     psMetadata *metadata,               ///< Contains classification parameters
     pmPSFClump clump,                   ///< Statistics about the PSF clump
-    psMaskType maskSat                  ///< Mask value for saturated pixels
+    psImageMaskType maskSat		///< Mask value for saturated pixels
 );
 
@@ -231,12 +231,12 @@
 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source);
 
-bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal);
-bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal);
-bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psMaskType maskVal, int dx, int dy);
-bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psMaskType maskVal, int dx, int dy);
-
-bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal, int dx, int dy);
-bool pmSourceCacheModel (pmSource *source, psMaskType maskVal);
-bool pmSourceCachePSF (pmSource *source, psMaskType maskVal);
+bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal);
+bool pmSourceSub (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal);
+bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy);
+bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy);
+
+bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy);
+bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal);
+bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal);
 
 int             pmSourceSortBySN (const void **a, const void **b);
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitModel.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitModel.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitModel.c	(revision 21079)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.28.4.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-12-31 20:31:29 $
+ *  @version $Revision: 1.28.4.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -121,5 +121,5 @@
     // create the minimization constraints
     psMinConstraint *constraint = psMinConstraintAlloc();
-    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK_DATA);
+    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
     constraint->checkLimits = model->modelLimits;
 
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitModel.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitModel.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitModel.h	(revision 21079)
@@ -3,6 +3,6 @@
  * @author EAM, IfA; GLG, MHPCC
  *
- * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-06-20 02:22:26 $
+ * @version $Revision: 1.6.66.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -41,5 +41,5 @@
     pmModel *model,   ///< model to be fitted
     pmSourceFitMode mode,  ///< define parameters to be fitted
-    psMaskType maskVal                  ///< Value to mask
+    psImageMaskType maskVal		///< Value to mask
 );
 
@@ -71,5 +71,5 @@
     psArray *modelSet,   ///< model to be fitted
     pmSourceFitMode mode,  ///< define parameters to be fitted
-    psMaskType maskVal                  ///< Vale to mask
+    psImageMaskType maskVal		///< Vale to mask
 
 );
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitSet.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitSet.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceFitSet.h	(revision 21079)
@@ -3,6 +3,6 @@
  * @author EAM, IfA; GLG, MHPCC
  *
- * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-11-10 01:09:20 $
+ * @version $Revision: 1.6.52.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -44,8 +44,8 @@
  */
 bool pmSourceFitSet(
-    pmSource *source,   ///< The input pmSource
-    psArray *modelSet,   ///< model to be fitted
-    pmSourceFitMode mode,  ///< define parameters to be fitted
-    psMaskType maskVal                  ///< Vale to mask
+    pmSource *source,			///< The input pmSource
+    psArray *modelSet,			///< model to be fitted
+    pmSourceFitMode mode,		///< define parameters to be fitted
+    psImageMaskType maskVal		///< Vale to mask
 
 );
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceMatch.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceMatch.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceMatch.c	(revision 21079)
@@ -122,5 +122,5 @@
     match->image = psVectorAllocEmpty(num, PS_TYPE_U32);
     match->index = psVectorAllocEmpty(num, PS_TYPE_U32);
-    match->mask = psVectorAllocEmpty(num, PS_TYPE_MASK);
+    match->mask = psVectorAllocEmpty(num, PS_TYPE_VECTOR_MASK);
 
     return match;
@@ -143,5 +143,5 @@
     match->image->data.S32[num] = image;
     match->index->data.S32[num] = index;
-    match->index->data.PS_TYPE_MASK_DATA[num] = 0;
+    match->index->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0; // XXXX EAM : I think this should be match->mask not match->index
     match->num++;
 
@@ -316,5 +316,5 @@
         double star = 0.0, starErr = 0.0; // Accumulators for star
         for (int j = 0; j < match->num; j++) {
-            if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
+            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
                 continue;
             }
@@ -347,5 +347,5 @@
         pmSourceMatch *match = matches->data[i]; // Matched stars
         for (int j = 0; j < match->num; j++) {
-            if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
+            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
                 continue;
             }
@@ -373,5 +373,5 @@
         pmSourceMatch *match = matches->data[i]; // Matched stars
         for (int j = 0; j < match->num; j++) {
-            if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
+            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
                 continue;
             }
@@ -474,5 +474,5 @@
         pmSourceMatch *match = matches->data[i]; // Matched stars
         for (int j = 0; j < match->num; j++) {
-            if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
+            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
                 continue;
             }
@@ -488,5 +488,5 @@
             if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) {
                 numRejected++;
-                match->mask->data.PS_TYPE_MASK_DATA[j] = 0xFF;
+                match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF;
             }
         }
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceMoments.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceMoments.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceMoments.c	(revision 21079)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-12-08 02:51:14 $
+ *  @version $Revision: 1.6.4.1 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-02 05:13:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -100,5 +100,5 @@
         psF32 *vPix = source->pixels->data.F32[row];
         psF32 *vWgt = source->weight->data.F32[row];
-        psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
+        psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
 
         for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
@@ -190,5 +190,5 @@
         psF32 *vPix = source->pixels->data.F32[row];
         psF32 *vWgt = source->weight->data.F32[row];
-        psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
+        psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
 
         for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
@@ -342,5 +342,5 @@
         psF32 *vPix = source->pixels->data.F32[row];
         psF32 *vWgt = source->weight->data.F32[row];
-        psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
+        psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
 
         for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourcePhotometry.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourcePhotometry.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourcePhotometry.h	(revision 21079)
@@ -4,6 +4,6 @@
  * @author EAM, IfA; GLG, MHPCC
  *
- * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-07-15 20:25:00 $
+ * @version $Revision: 1.11.32.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -46,11 +46,11 @@
     psImage *image,                     ///< image pixels to be used
     psImage *mask,                      ///< mask of pixels to ignore
-    psMaskType maskVal                  ///< Value to mask
+    psImageMaskType maskVal		///< Value to mask
 );
 
 bool pmSourceMagnitudesInit (psMetadata *config);
-bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal);
-bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal);
-bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal);
+bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal);
+bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal);
+bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal);
 
 
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceSky.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceSky.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceSky.h	(revision 21079)
@@ -2,6 +2,6 @@
  * @author EAM, IfA; GLG, MHPCC
  *
- * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-06-20 02:22:26 $
+ * @version $Revision: 1.4.66.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -30,6 +30,6 @@
     psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
     float Radius,   ///< The inner radius of the square annulus to exclude
-    psMaskType maskVal,                 ///< Value to mask
-    psMaskType mark                     ///< Mask value for marking
+    psImageMaskType maskVal,                 ///< Value to mask
+    psImageMaskType mark                     ///< Mask value for marking
 );
 
@@ -40,6 +40,6 @@
     psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
     float Radius,   ///< The inner radius of the square annulus to exclude
-    psMaskType maskVal,                 ///< Value to mask
-    psMaskType mark                     ///< Mask value for marking
+    psImageMaskType maskVal,                 ///< Value to mask
+    psImageMaskType mark                     ///< Mask value for marking
 );
 
Index: /branches/eam_branch_20081230/psModules/src/objects/pmSourceVisual.c
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmSourceVisual.c	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmSourceVisual.c	(revision 21079)
@@ -57,5 +57,5 @@
 	model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]);
 	resid->data.F32[i] = param->data.F32[i] - model->data.F32[i];
-	if (mask->data.U8[i]) continue;
+	if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
 	min = PS_MIN (min, resid->data.F32[i]);
 	max = PS_MAX (max, resid->data.F32[i]);
Index: /branches/eam_branch_20081230/psModules/src/objects/pmTrend2D.h
===================================================================
--- /branches/eam_branch_20081230/psModules/src/objects/pmTrend2D.h	(revision 21078)
+++ /branches/eam_branch_20081230/psModules/src/objects/pmTrend2D.h	(revision 21079)
@@ -5,6 +5,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- * @date $Date: 2008-10-07 22:47:04 $
+ * @version $Revision: 1.7.14.1 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2009-01-02 05:13:00 $
  * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
@@ -80,5 +80,5 @@
 bool pmTrend2DFit(pmTrend2D *trend,
                   psVector *mask,       // Warning: mask is modified!
-                  psMaskType maskVal,
+                  psVectorMaskType maskVal,
                   const psVector *x,
                   const psVector *y,
