Index: trunk/psphot/src/psphotBasicDeblend.c
===================================================================
--- trunk/psphot/src/psphotBasicDeblend.c	(revision 5772)
+++ trunk/psphot/src/psphotBasicDeblend.c	(revision 5828)
@@ -8,6 +8,4 @@
     pmSource *source, *testSource;
 
-    FILE *f = fopen ("deblend.dat", "w");
-    if (f == NULL) psAbort ("psphot", "can't open deblend.dat output file");
     int Nblend = 0;
 
@@ -82,8 +80,5 @@
 	    // XXX EAM : should the contour input coordinate be in parent or subimage coords? parent, for now
 	    psArray *contour = pmSourceContour_EAM (source->pixels, source->peak->x, source->peak->y, threshold);
-	    if (contour == NULL) {
-		fprintf (stderr, "below threshold? invalid peak?\n");
-		continue;
-	    }
+	    if (contour == NULL) continue;
 
 	    // the source contour consists of two vectors, xv and yv.  the contour is 
@@ -102,4 +97,5 @@
 		    if (xv->data.F32[j+1] < testSource->peak->x) break;
 
+		    # if (0)
 		    int xp0 = source->moments->x - source->pixels->col0;
 		    int xp1 = source->peak->x - source->pixels->col0;
@@ -111,13 +107,22 @@
 		    int yp2 = testSource->moments->y - testSource->pixels->row0;
 		    int yp3 = testSource->peak->y - testSource->pixels->row0;
+		    
+		    fprintf (f, "%d %d (%f, %f) :  %d %d (%f, %f)  vs %f\n",
+			     source->peak->x, source->peak->y,
+			     source->pixels->data.F32[yp0][xp0], source->pixels->data.F32[yp1][xp1],
+			     testSource->peak->x, testSource->peak->y,
+			     testSource->pixels->data.F32[yp2][xp2], testSource->pixels->data.F32[yp3][xp3], threshold
+		       );
+		    # endif
+		    
+		    testSource->mode |= PM_SOURCE_BLEND;
 
-		    fprintf (f, "%d %d (%f, %f) :  %d %d (%f, %f)  vs %f\n", 
-			     source->peak->x, source->peak->y, 
-			     source->pixels->data.F32[yp0][xp0], source->pixels->data.F32[yp1][xp1], 
-			     testSource->peak->x, testSource->peak->y, 
-			     testSource->pixels->data.F32[yp2][xp2], testSource->pixels->data.F32[yp3][xp3], threshold
-			     );
+		    // add this to the list of source->blends
+		    if (source->blends == NULL) {
+			source->blends = psArrayAlloc (16);
+			source->blends->n = 0;
+		    }
+		    psArrayAdd (source->blends, 16, testSource);
 
-		    testSource->mode |= PM_SOURCE_BLEND;
 		    Nblend ++;
 		    j = xv->n;
@@ -126,9 +131,5 @@
 	}
     }
-    fclose (f);
-    psLogMsg ("psphot.deblend", 3, "identified %d blended objects (%f)\n", Nblend, psTimerMark ("psphot"));
+    psLogMsg ("psphot.deblend", 3, "identified %d blended objects (%f sec)\n", Nblend, psTimerMark ("psphot"));
     return true;
 }
-
-
-
