Index: /branches/eam_branches/20090715/psphot/src/psphotSourceFits.c
===================================================================
--- /branches/eam_branches/20090715/psphot/src/psphotSourceFits.c	(revision 25617)
+++ /branches/eam_branches/20090715/psphot/src/psphotSourceFits.c	(revision 25618)
@@ -90,6 +90,9 @@
     psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, dR);
 
-    // fit PSF model (set/unset the pixel mask)
+    // fit PSF model
     pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF, maskVal);
+
+    // clear the circular mask
+    psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 
 
     // correct model chisq for flux trend
@@ -120,5 +123,4 @@
         pmSourceCacheModel (blend, maskVal);
         pmSourceSub (blend, PM_MODEL_OP_FULL, maskVal);
-        blend->tmpFlags |=  PM_SOURCE_TMPF_SUBTRACTED;
         blend->mode |=  PM_SOURCE_MODE_BLEND_FIT;
     }
@@ -144,5 +146,4 @@
     pmSourceCacheModel (source, maskVal);
     pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
-    source->tmpFlags |=  PM_SOURCE_TMPF_SUBTRACTED;
     source->mode |=  PM_SOURCE_MODE_BLEND_FIT;
     return true;
@@ -167,4 +168,7 @@
     // fit PSF model (set/unset the pixel mask)
     pmSourceFitModel (source, PSF, PM_SOURCE_FIT_PSF, maskVal);
+
+    // clear the circular mask
+    psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 
 
     // correct model chisq for flux trend
@@ -186,5 +190,4 @@
     pmSourceCacheModel (source, maskVal);
     pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
-    source->tmpFlags |=  PM_SOURCE_TMPF_SUBTRACTED;
     return true;
 }
@@ -223,4 +226,5 @@
     if (source->peak->SN < EXT_MIN_SN) return false;
 
+    // set the radius based on the footprint (also sets the mask pixels)
     float radius = psphotSetRadiusEXT (readout, source, markVal);
 
@@ -228,7 +232,5 @@
     // recalculate the source moments using the larger extended-source moments radius
     // at this stage, skip Gaussian windowing, and do not clip pixels by S/N
-    // XXX use the deteremined value of PSF_MOMENTS_RADIUS and SIGMA and scale up?
-    // XXX increase the moments radius iteratively until the measured sigma / input < f?
-    // XXX use the footprint somehow to judge both radius and aperture?
+    // this uses the footprint to judge both radius and aperture?
     if (!pmSourceMoments (source, radius, 0.0, 0.0)) return false;
 
@@ -251,4 +253,7 @@
     okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
     // XXX should I keep / save the flags set in the eval functions?
+
+    // clear the circular mask
+    psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 
 
     // correct first model chisqs for flux trend
@@ -301,5 +306,4 @@
     pmSourceCacheModel (source, maskVal);
     pmSourceSub (source, PM_MODEL_OP_FULL, maskVal);
-    source->tmpFlags |=  PM_SOURCE_TMPF_SUBTRACTED;
 
 # if (PS_TRACE_ON)   
@@ -322,5 +326,4 @@
     psFree (source->modelPSF);
     source->modelPSF = psMemIncrRefCounter (DBL->data[0]);
-    source->tmpFlags |= PM_SOURCE_TMPF_SUBTRACTED;
     source->mode     |= PM_SOURCE_MODE_PAIR;
     source->modelPSF->fitRadius = radius;
@@ -389,5 +392,4 @@
     // save the PSF model from the Ensemble fit
     PSF = source->modelPSF;
-    // psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0);
     if (isnan(PSF->params->data.F32[1])) psAbort("nan in dbl fit");
 
@@ -422,7 +424,4 @@
     PS_ASSERT (EXT, NULL);
 
-    // if (isnan(EXT->params->data.F32[1])) psAbort("nan in ext fit");
-    // psphotCheckRadiusEXT (readout, source, EXT, markVal);
-
     if ((source->moments->Mxx < 1e-3) || (source->moments->Myy < 1e-3)) {
         psTrace ("psphot", 5, "problem source: moments: %f %f\n", source->moments->Mxx, source->moments->Myy);
