Index: trunk/psphot/src/psphotSourceFits.c
===================================================================
--- trunk/psphot/src/psphotSourceFits.c	(revision 17396)
+++ trunk/psphot/src/psphotSourceFits.c	(revision 18555)
@@ -21,11 +21,14 @@
 }
 
-bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal) {
+bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
 
     float x, y, dR;
+
+    // maskVal is used to test for rejected pixels, and must include markVal
+    maskVal |= markVal;
 
     // if this source is not a possible blend, just fit as PSF
     if ((source->blends == NULL) || (source->mode & PM_SOURCE_MODE_SATSTAR)) {
-        bool status = psphotFitPSF (readout, source, psf, maskVal);
+        bool status = psphotFitPSF (readout, source, psf, maskVal, markVal);
         return status;
     }
@@ -80,5 +83,5 @@
 
     // extend source radius as needed
-    psphotCheckRadiusPSFBlend (readout, source, PSF, dR);
+    psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, dR);
 
     // fit PSF model (set/unset the pixel mask)
@@ -139,7 +142,10 @@
 }
 
-bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal) {
+bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
 
     double chiTrend;
+
+    // maskVal is used to test for rejected pixels, and must include markVal
+    maskVal |= markVal;
 
     NfitPSF ++;
@@ -150,5 +156,5 @@
 
     // extend source radius as needed
-    psphotCheckRadiusPSF (readout, source, PSF);
+    psphotCheckRadiusPSF (readout, source, PSF, markVal);
 
     // fit PSF model (set/unset the pixel mask)
@@ -197,5 +203,5 @@
 }
 
-bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal) {
+bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
 
     bool okEXT, okDBL;
@@ -215,14 +221,15 @@
     psTrace ("psphot", 5, "trying blob...\n");
 
-    // psTraceSetLevel("psModules.objects.pmSourceFitSet", 5);
+    // maskVal is used to test for rejected pixels, and must include markVal
+    maskVal |= markVal;
 
     // this temporary source is used as a place-holder by the psphotEval functions below
     pmSource *tmpSrc = pmSourceAlloc ();
 
-    pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal);
+    pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);
     okEXT = psphotEvalEXT (tmpSrc, EXT);
     chiEXT = EXT->chisq / EXT->nDOF;
 
-    psArray *DBL = psphotFitDBL (readout, source, maskVal);
+    psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal);
     okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
     okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
@@ -306,5 +313,5 @@
 
 // fit a double PSF source to an extended blob
-psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal) {
+psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal) {
 
     float dx, dy;
@@ -317,4 +324,7 @@
     NfitDBL ++;
 
+    // maskVal is used to test for rejected pixels, and must include markVal
+    maskVal |= markVal;
+
     // make a guess at the position of the two sources
     moments.x2 = source->moments->Sx;
@@ -329,5 +339,5 @@
     // save the PSF model from the Ensemble fit
     PSF = source->modelPSF;
-    psphotCheckRadiusPSFBlend (readout, source, PSF, 8.0);
+    psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0);
     if (isnan(PSF->params->data.F32[1])) psAbort("nan in dbl fit");
 
@@ -351,7 +361,10 @@
 }
 
-pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal) {
+pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal) {
 
     NfitEXT ++;
+
+    // maskVal is used to test for rejected pixels, and must include markVal
+    maskVal |= markVal;
 
     // use the source moments, etc to guess basic model parameters
@@ -361,5 +374,5 @@
     // if (isnan(EXT->params->data.F32[1])) psAbort("nan in ext fit");
 
-    psphotCheckRadiusEXT (readout, source, EXT);
+    psphotCheckRadiusEXT (readout, source, EXT, markVal);
 
     if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) {
