Index: trunk/psModules/src/objects/pmPSFtry.c
===================================================================
--- trunk/psModules/src/objects/pmPSFtry.c	(revision 21173)
+++ trunk/psModules/src/objects/pmPSFtry.c	(revision 21183)
@@ -5,7 +5,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-01-27 00:01:33 $
- *
+ *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-01-27 06:39:38 $
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  *
@@ -115,5 +114,5 @@
     test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F32);
     test->fitMag    = psVectorAlloc (sources->n, PS_TYPE_F32);
-    test->mask      = psVectorAlloc (sources->n, PS_TYPE_U8);
+    test->mask      = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK);
 
     psVectorInit (test->mask,        0);
@@ -148,5 +147,5 @@
 
 // generate a pmPSFtry with a copy of the test PSF sources
-pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType markVal)
+pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal)
 {
     bool status;
@@ -176,9 +175,9 @@
         pmSource *source = psfTry->sources->data[i];
 	if (!source->moments) {
-            psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
+            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
 	    continue;
 	}
 	if (!source->moments->nPixels) {
-            psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
+            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
 	    continue;
 	}
@@ -186,5 +185,5 @@
         source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type);
         if (source->modelEXT == NULL) {
-            psfTry->mask->data.U8[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) : failed to generate model guess\n", i, source->peak->x, source->peak->y);
             continue;
@@ -198,9 +197,9 @@
 
         // clear object mask to define valid pixels
-        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
+        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
 
         // exclude the poor fits
         if (!status) {
-            psfTry->mask->data.U8[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;
@@ -231,5 +230,5 @@
 
         // masked for: bad model fit, outlier in parameters
-        if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL) {
+        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) {
             psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : source is masked\n", i, source->peak->x, source->peak->y);
             continue;
@@ -239,5 +238,5 @@
         source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf);
         if (source->modelPSF == NULL) {
-            psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_MODEL;
+            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL;
             abort();
             continue;
@@ -253,6 +252,6 @@
         // skip poor fits
         if (!status) {
-            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
-            psfTry->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
+            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
+            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL;
             psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
             continue;
@@ -261,6 +260,6 @@
         status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal);
         if (!status || isnan(source->apMag)) {
-            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
-            psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
+            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
+            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT;
             psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
             continue;
@@ -268,5 +267,5 @@
 
         // clear object mask to define valid pixels
-        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
+        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
 
         psfTry->fitMag->data.F32[i] = source->psfMag;
@@ -292,5 +291,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
@@ -300,9 +299,9 @@
             flux->data.F32[i] = 0.0;
             chisq->data.F32[i] = 0.0;
-            mask->data.U8[i] = 0xff;
+            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
         } else {
             flux->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_I0];
             chisq->data.F32[i] = source->modelPSF->chisq / source->modelPSF->nDOF;
-            mask->data.U8[i] = 0;
+            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0;
         }
     }
@@ -312,6 +311,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
@@ -370,5 +368,5 @@
 
     for (int i = 0; i < psfTry->sources->n; i++) {
-        if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL)
+        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL)
             continue;
         r2rflux->data.F32[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F32[i]);
@@ -379,5 +377,5 @@
         FILE *f = fopen ("apresid.dat", "w");
         for (int i = 0; i < psfTry->sources->n; i++) {
-            int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
+            int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL);
 
             pmSource *source = psfTry->sources->data[i];
@@ -427,5 +425,5 @@
         psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux);
         for (int i = 0; i < psfTry->sources->n; i++) {
-            int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
+            int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL);
 
             pmSource *source = psfTry->sources->data[i];
@@ -603,5 +601,5 @@
     for (int i = 0; i < sources->n; i++) {
 	// skip any masked sources (failed to fit one of the model steps or get a magnitude)
-	if (srcMask->data.U8[i]) continue;
+	if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
 	
         pmSource *source = sources->data[i];
@@ -624,5 +622,5 @@
 
         psVector *dz = NULL;
-        psVector *mask = psVectorAlloc (sources->n, PS_TYPE_U8);
+        psVector *mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK);
 
         // check the fit residuals and increase Nx,Ny until the error is minimized
@@ -632,5 +630,5 @@
 	    // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
 	    for (int i = 0; i < mask->n; i++) {
-		mask->data.U8[i] = srcMask->data.U8[i];
+		mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
 	    }
             if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
@@ -651,5 +649,5 @@
 	// copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
 	for (int i = 0; i < mask->n; i++) {
-	    mask->data.U8[i] = srcMask->data.U8[i];
+	    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
 	}
         if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
@@ -663,5 +661,5 @@
 	// copy mask back to srcMask
 	for (int i = 0; i < mask->n; i++) {
-	    srcMask->data.U8[i] = mask->data.U8[i];
+	    srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i];
 	}
 
@@ -736,5 +734,5 @@
                      pmTrend2DEval (psf->params->data[PM_PAR_E1], x->data.F32[i], y->data.F32[i]),
                      pmTrend2DEval (psf->params->data[PM_PAR_E2], x->data.F32[i], y->data.F32[i]),
-                     srcMask->data.U8[i]);
+                     srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
         }
         fclose (f);
@@ -851,8 +849,8 @@
 
     // the mask marks the values not used to calculate the ApTrend
-    psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_U8);
+    psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_VECTOR_MASK);
     // copy mask values to fitMask as a starting point
     for (int i = 0; i < fitMask->n; i++) {
-	fitMask->data.U8[i] = mask->data.U8[i];
+	fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i];
     }
 
@@ -943,5 +941,5 @@
     // XXX copy fitMask values back to mask
     for (int i = 0; i < fitMask->n; i++) {
-	mask->data.U8[i] = fitMask->data.U8[i];
+	mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
     }
     psFree (fitMask);
@@ -951,5 +949,5 @@
 
 // calculate the scatter of the parameters
-bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psMaskType maskValue, psStatsOptions stdevOpt)
+bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt)
 {
 
@@ -994,5 +992,5 @@
     psVector *dE1subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
     psVector *dE2subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
-    psVector *mkSubset  = psVectorAllocEmpty (nGroup, PS_TYPE_U8);
+    psVector *mkSubset  = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK);
 
     int n = 0;
@@ -1007,6 +1005,6 @@
             dE2subset->data.F32[j] = e2res->data.F32[N];
 
-            mkSubset->data.U8[j]   = mask->data.U8[N];
-	    if (!mask->data.U8[N]) nValid ++;
+            mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j]   = mask->data.PS_TYPE_VECTOR_MASK_DATA[N];
+	    if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[N]) nValid ++;
         }
 	if (nValid < 3) continue;
