Index: /branches/eam_branches/20091201/psphot/src/psphotMergeSources.c
===================================================================
--- /branches/eam_branches/20091201/psphot/src/psphotMergeSources.c	(revision 26644)
+++ /branches/eam_branches/20091201/psphot/src/psphotMergeSources.c	(revision 26645)
@@ -13,24 +13,24 @@
 
     // load data from input CMF file:
-    { 
-	pmReadout *readoutCMF = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CMF");
-	if (!readoutCMF) goto loadTXT;
+    {
+        pmReadout *readoutCMF = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CMF");
+        if (!readoutCMF) goto loadTXT;
 
-	extSourcesCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.SOURCES");
-	if (extSourcesCMF) {
-	    for (int i = 0; i < extSourcesCMF->n; i++) {
-		pmSource *source = extSourcesCMF->data[i];
-		source->mode |= PM_SOURCE_MODE_EXTERNAL;
+        extSourcesCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.SOURCES");
+        if (extSourcesCMF) {
+            for (int i = 0; i < extSourcesCMF->n; i++) {
+                pmSource *source = extSourcesCMF->data[i];
+                source->mode |= PM_SOURCE_MODE_EXTERNAL;
 
-		// the supplied peak flux needs to be re-normalized
-		source->peak->flux = 1.0;
-		source->peak->value = 1.0;
+                // the supplied peak flux needs to be re-normalized
+                source->peak->flux = 1.0;
+                source->peak->value = 1.0;
 
-		// drop the loaded source modelPSF
-		psFree (source->modelPSF);
-		source->modelPSF = NULL;
-	    }
-	    psphotMergeSources (sources, extSourcesCMF);
-	}
+                // drop the loaded source modelPSF
+                psFree (source->modelPSF);
+                source->modelPSF = NULL;
+            }
+            psphotMergeSources (sources, extSourcesCMF);
+        }
     }
 
@@ -38,20 +38,20 @@
 
     // load data from input TXT file:
-    { 
-	pmChip *chipTXT = pmFPAfileThisChip (config->files, view, "PSPHOT.INPUT");
-	if (!chipTXT) goto finish;
+    {
+        pmChip *chipTXT = pmFPAfileThisChip (config->files, view, "PSPHOT.INPUT");
+        if (!chipTXT) goto finish;
 
-	extSourcesTXT = psMetadataLookupPtr (NULL, chipTXT->analysis, "PSPHOT.SOURCES.TEXT");
-	if (extSourcesTXT) {
-	    for (int i = 0; i < extSourcesTXT->n; i++) {
-		pmSource *source = extSourcesTXT->data[i];
-		source->mode |= PM_SOURCE_MODE_EXTERNAL;
+        extSourcesTXT = psMetadataLookupPtr (NULL, chipTXT->analysis, "PSPHOT.SOURCES.TEXT");
+        if (extSourcesTXT) {
+            for (int i = 0; i < extSourcesTXT->n; i++) {
+                pmSource *source = extSourcesTXT->data[i];
+                source->mode |= PM_SOURCE_MODE_EXTERNAL;
 
-		// drop the loaded source modelPSF
-		psFree (source->modelPSF);
-		source->modelPSF = NULL;
-	    }
-	    psphotMergeSources (sources, extSourcesTXT);
-	}
+                // drop the loaded source modelPSF
+                psFree (source->modelPSF);
+                source->modelPSF = NULL;
+            }
+            psphotMergeSources (sources, extSourcesTXT);
+        }
     }
 
@@ -66,6 +66,6 @@
     int nTXT = extSourcesTXT ? extSourcesTXT->n : 0;
 
-    psLogMsg ("psphot", 3, "%d external sources (%d cmf, %d text) merged to yield %ld total sources", 
-	      nCMF + nTXT, nCMF, nTXT, sources->n);
+    psLogMsg ("psphot", 3, "%d external sources (%d cmf, %d text) merged to yield %ld total sources",
+              nCMF + nTXT, nCMF, nTXT, sources->n);
     return true;
 }
@@ -124,9 +124,10 @@
         }
 
-	// use the existing peak information, otherwise generate a new peak
-	if (source->peak) {
-	    psArrayAdd (detections->peaks, 100, source->peak);
-	    continue;
-	}
+        // use the existing peak information, otherwise generate a new peak
+        if (source->peak) {
+            source->peak->assigned = false; // So the moments will be measured
+            psArrayAdd (detections->peaks, 100, source->peak);
+            continue;
+        }
 
         float flux = powf(10.0, -0.4 * source->psfMag);
@@ -139,9 +140,9 @@
         peak->flux = flux; // this are being set wrong, but does it matter?
 
-	if (isfinite (source->errMag) && (source->errMag > 0.0)) {
-	  peak->SN = 1.0 / source->errMag; 
-	} else {
-	  peak->SN = 0.0;
-	}
+        if (isfinite (source->errMag) && (source->errMag > 0.0)) {
+          peak->SN = 1.0 / source->errMag;
+        } else {
+          peak->SN = 0.0;
+        }
 
         psArrayAdd (detections->peaks, 100, peak);
@@ -180,9 +181,9 @@
         peak->flux = flux; // this are being set wrong, but does it matter?
 
-	if (isfinite (source->errMag) && (source->errMag > 0.0)) {
-	  peak->SN = 1.0 / source->errMag; 
-	} else {
-	  peak->SN = 0.0;
-	}
+        if (isfinite (source->errMag) && (source->errMag > 0.0)) {
+          peak->SN = 1.0 / source->errMag;
+        } else {
+          peak->SN = 0.0;
+        }
 
         source->peak = peak;
