Index: trunk/psphot/src/psphotSourceFits.c
===================================================================
--- trunk/psphot/src/psphotSourceFits.c	(revision 9576)
+++ trunk/psphot/src/psphotSourceFits.c	(revision 9595)
@@ -3,5 +3,5 @@
 // given a source with an existing modelPSF, attempt a full PSF fit, subtract if successful
 
-bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf) { 
+bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf) {
 
     float x, y, dR;
@@ -9,6 +9,6 @@
     // 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);
-	return status;
+        bool status = psphotFitPSF (readout, source, psf);
+        return status;
     }
     psTrace ("psphot", 5, "trying blend...\n");
@@ -23,5 +23,5 @@
     psArray *modelSet = psArrayAlloc (source->blends->n + 1);
     psArrayAdd (modelSet, 16, PSF);
-    
+
     psArray *sourceSet = psArrayAlloc (source->blends->n + 1);
     psArrayAdd (sourceSet, 16, source);
@@ -30,28 +30,28 @@
     dR = 0;
     for (int i = 0; i < source->blends->n; i++) {
-	pmSource *blend = source->blends->data[i];
-
-	// find the blend which is furthest from source
-	dR = PS_MAX (dR, hypot (blend->peak->x - x, blend->peak->y - y));
-
-	// create the model and guess parameters for this blend
-	pmModel *model = pmModelAlloc (PSF->type);
-	for (int j = 0; j < model->params->n; j++) {
-	    model->params->data.F32[j] = PSF->params->data.F32[j];
-	    model->dparams->data.F32[j] = PSF->dparams->data.F32[j];
-	}
-
-	// XXX assume local sky is 0.0?
-	model->params->data.F32[1] = blend->moments->Peak - blend->moments->Sky;
-	if (isnan(model->params->data.F32[1])) psAbort ("psphot", "nan in blend fit");
-	model->params->data.F32[2] = blend->peak->x;
-	model->params->data.F32[3] = blend->peak->y;
-
-	// add this blend to the list
-	psArrayAdd (modelSet, 16, model);
-	psArrayAdd (sourceSet, 16, blend);
-
-	// free to avoid double counting model 
-	psFree (model);
+        pmSource *blend = source->blends->data[i];
+
+        // find the blend which is furthest from source
+        dR = PS_MAX (dR, hypot (blend->peak->x - x, blend->peak->y - y));
+
+        // create the model and guess parameters for this blend
+        pmModel *model = pmModelAlloc (PSF->type);
+        for (int j = 0; j < model->params->n; j++) {
+            model->params->data.F32[j] = PSF->params->data.F32[j];
+            model->dparams->data.F32[j] = PSF->dparams->data.F32[j];
+        }
+
+        // XXX assume local sky is 0.0?
+        model->params->data.F32[1] = blend->moments->Peak - blend->moments->Sky;
+        if (isnan(model->params->data.F32[1])) psAbort ("psphot", "nan in blend fit");
+        model->params->data.F32[2] = blend->peak->x;
+        model->params->data.F32[3] = blend->peak->y;
+
+        // add this blend to the list
+        psArrayAdd (modelSet, 16, model);
+        psArrayAdd (sourceSet, 16, blend);
+
+        // free to avoid double counting model
+        psFree (model);
     }
 
@@ -62,5 +62,5 @@
     psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_MASK_MARK);
     pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF);
-    psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", NOT_U8(PM_MASK_MARK));
+    psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", PS_NOT_U8(PM_MASK_MARK));
 
     // correct model chisq for flux trend
@@ -70,24 +70,24 @@
     // evaluate the blend objects, subtract if good, free otherwise
     for (int i = 1; i < modelSet->n; i++) {
-	pmSource *blend = sourceSet->data[i];
-	pmModel *model  = modelSet->data[i];
-
-	// correct model chisq for flux trend
-	chiTrend = psPolynomial1DEval (psf->ChiTrend, model->params->data.F32[1]);
-	model->chisqNorm = model->chisq / chiTrend;
-
-	// if this one failed, skip it
-	if (!psphotEvalPSF (blend, model)) {
-	    psTrace ("psphot", 5, "failed on blend %d of %ld\n", i, modelSet->n);
-	    continue;
-	}
-
-	// otherwise, supply the resulting model to the corresponding blend
-	psFree(blend->modelPSF);
-	blend->modelPSF = psMemIncrRefCounter (model);
-	psTrace ("psphot", 5, "fitted blend as PSF\n");
-	pmModelSub (source->pixels, source->mask, model, false, false);
-	blend->mode |=  PM_SOURCE_MODE_SUBTRACTED;
-	blend->mode &= ~PM_SOURCE_MODE_TEMPSUB;
+        pmSource *blend = sourceSet->data[i];
+        pmModel *model  = modelSet->data[i];
+
+        // correct model chisq for flux trend
+        chiTrend = psPolynomial1DEval (psf->ChiTrend, model->params->data.F32[1]);
+        model->chisqNorm = model->chisq / chiTrend;
+
+        // if this one failed, skip it
+        if (!psphotEvalPSF (blend, model)) {
+            psTrace ("psphot", 5, "failed on blend %d of %ld\n", i, modelSet->n);
+            continue;
+        }
+
+        // otherwise, supply the resulting model to the corresponding blend
+        psFree(blend->modelPSF);
+        blend->modelPSF = psMemIncrRefCounter (model);
+        psTrace ("psphot", 5, "fitted blend as PSF\n");
+        pmModelSub (source->pixels, source->mask, model, false, false);
+        blend->mode |=  PM_SOURCE_MODE_SUBTRACTED;
+        blend->mode &= ~PM_SOURCE_MODE_TEMPSUB;
     }
     psFree (modelSet);
@@ -96,7 +96,7 @@
     // evaluate the primary object
     if (!psphotEvalPSF (source, PSF)) {
-	psTrace ("psphot", 5, "failed on blend 0 of %ld\n", modelSet->n);
-	psFree (PSF);
-	return false;
+        psTrace ("psphot", 5, "failed on blend 0 of %ld\n", modelSet->n);
+        psFree (PSF);
+        return false;
     }
 
@@ -110,5 +110,5 @@
 }
 
-bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf) { 
+bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf) {
 
     float x, y;
@@ -128,6 +128,6 @@
     psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_MASK_MARK);
     pmSourceFitModel (source, PSF, PM_SOURCE_FIT_PSF);
-    psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", NOT_U8(PM_MASK_MARK));
-    
+    psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", PS_NOT_U8(PM_MASK_MARK));
+
     // correct model chisq for flux trend
     chiTrend = psPolynomial1DEval (psf->ChiTrend, PSF->params->data.F32[1]);
@@ -136,6 +136,6 @@
     // does the PSF model succeed?
     if (!psphotEvalPSF (source, PSF)) {
-	psFree (PSF);
-	return false;
+        psFree (PSF);
+        return false;
     }
 
@@ -143,5 +143,5 @@
     pmModelSub (source->pixels, source->mask, PSF, false, false);
 
-    // free old model, save new model 
+    // free old model, save new model
     psFree (source->modelPSF);
     source->modelPSF = PSF;
@@ -173,5 +173,5 @@
 }
 
-bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf) { 
+bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf) {
 
     bool okEXT, okDBL;
@@ -216,11 +216,11 @@
     ONE->chisqNorm = ONE->chisq / chiTrend;
 
-    psFree (tmpSrc); 
+    psFree (tmpSrc);
 
     if (okEXT && okDBL) {
-	psTrace ("psphot", 5, "blob chisq: %f vs %f\n", chiEXT, chiDBL);
-	// XXX EAM : a bogus bias: need to examine this better 
-	if (3*chiEXT > chiDBL) goto keepDBL;
-	goto keepEXT;
+        psTrace ("psphot", 5, "blob chisq: %f vs %f\n", chiEXT, chiDBL);
+        // XXX EAM : a bogus bias: need to examine this better
+        if (3*chiEXT > chiDBL) goto keepDBL;
+        goto keepEXT;
     }
 
@@ -276,5 +276,5 @@
 
 // fit a double PSF source to an extended blob
-psArray *psphotFitDBL (pmReadout *readout, pmSource *source) { 
+psArray *psphotFitDBL (pmReadout *readout, pmSource *source) {
 
     float x, y, dx, dy;
@@ -284,5 +284,5 @@
     psEllipseMoments moments;
     psArray *modelSet;
-    
+
     // make a guess at the position of the two sources
     moments.x2 = source->moments->Sx;
@@ -320,15 +320,15 @@
     psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "OR", PM_MASK_MARK);
     pmSourceFitSet (source, modelSet, PM_SOURCE_FIT_PSF);
-    psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", NOT_U8(PM_MASK_MARK));
+    psImageKeepCircle (source->mask, x, y, PSF->radiusTMP, "AND", PS_NOT_U8(PM_MASK_MARK));
 
     return (modelSet);
 }
 
-pmModel *psphotFitEXT (pmReadout *readout, pmSource *source) { 
+pmModel *psphotFitEXT (pmReadout *readout, pmSource *source) {
 
     float x, y;
 
     // use the source moments, etc to guess basic model parameters
-    pmModel *EXT = pmSourceModelGuess (source, modelTypeEXT); 
+    pmModel *EXT = pmSourceModelGuess (source, modelTypeEXT);
     // if (isnan(EXT->params->data.F32[1])) psAbort ("psphot", "nan in ext fit");
 
@@ -339,5 +339,5 @@
 
     if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) {
-	psTrace ("psphot", 5, "problem source: moments: %f %f\n", source->moments->Sx, source->moments->Sy);
+        psTrace ("psphot", 5, "problem source: moments: %f %f\n", source->moments->Sx, source->moments->Sy);
     }
 
@@ -345,5 +345,5 @@
     psImageKeepCircle (source->mask, x, y, EXT->radiusTMP, "OR", PM_MASK_MARK);
     pmSourceFitModel (source, EXT, PM_SOURCE_FIT_EXT);
-    psImageKeepCircle (source->mask, x, y, EXT->radiusTMP, "AND", NOT_U8(PM_MASK_MARK));
+    psImageKeepCircle (source->mask, x, y, EXT->radiusTMP, "AND", PS_NOT_U8(PM_MASK_MARK));
 
     return (EXT);
