Index: /tags/ipp-20141224/psphot/src/psphotExtendedSourceAnalysis.c
===================================================================
--- /tags/ipp-20141224/psphot/src/psphotExtendedSourceAnalysis.c	(revision 37774)
+++ /tags/ipp-20141224/psphot/src/psphotExtendedSourceAnalysis.c	(revision 37775)
@@ -38,11 +38,11 @@
 
 /*** for the moment, this test code : it is not thread safe ***/
-int    Nall = 0;
-int  Nskip1 = 0;
-int  Nskip2 = 0;
-int  Nskip3 = 0;
-int  Nskip4 = 0;
-int  Nskip5 = 0;
-int  Nskip6 = 0;
+static int    Nall = 0;
+static int  Nskip1 = 0;
+static int  Nskip2 = 0;
+static int  Nskip3 = 0;
+static int  Nskip4 = 0;
+static int  Nskip5 = 0;
+static int  Nskip6 = 0;
 
 # define SKIP(VALUE) { VALUE++; continue; }
Index: /tags/ipp-20141224/psphot/src/psphotGalaxyParams.c
===================================================================
--- /tags/ipp-20141224/psphot/src/psphotGalaxyParams.c	(revision 37774)
+++ /tags/ipp-20141224/psphot/src/psphotGalaxyParams.c	(revision 37775)
@@ -1,5 +1,6 @@
 # include "psphotInternal.h"
 
-#define USE_FOOTPRINTS 1
+# define PRINT_STUFF 0
+# define USE_FOOTPRINTS 1
 
 // measure some properties on the exended objects
@@ -40,19 +41,19 @@
 }
 
-#ifdef notdef
+// # define COUNT_SKIPS
+# ifdef COUNT_SKIPS
 /*** for the moment, this test code : it is not thread safe ***/
-int  Nall = 0;
-int  Nskip1 = 0;
-int  Nskip2 = 0;
-int  Nskip3 = 0;
-int  Nskip4 = 0;
-int  Nskip5 = 0;
-int  Nskip6 = 0;
-
+static int  Nskip1 = 0;
+static int  Nskip2 = 0;
+static int  Nskip3 = 0;
+static int  Nskip4 = 0;
+static int  Nskip5 = 0;
+static int  Nskip6 = 0;
+static int  Nskip7 = 0;
+static int  Nskip8 = 0;
 # define SKIP(VALUE) { VALUE++; continue; }
-
-#endif //notdef
-
-#define SKIP(VALUE) {continue;}
+# else
+# define SKIP(VALUE) {continue;}
+# endif //notdef
 
 // aperture-like measurements for extended sources
@@ -107,5 +108,5 @@
     footprintImage = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_S32);
     psImageInit(footprintImage, 0);
-    pmSetFootprintArrayIDsForImage(footprintImage, detections->footprints, true);
+    pmSetFootprintArrayIDsForImage(footprintImage, detections->footprints, false);
 #endif
 
@@ -207,5 +208,5 @@
 
 // # if (PS_TRACE_ON)
-# if (0)
+# ifdef COUNT_SKIPS
     fprintf (stderr, "ext analysis skipped @ 1  : %d\n", Nskip1);
     fprintf (stderr, "ext analysis skipped @ 2  : %d\n", Nskip2);
@@ -214,4 +215,6 @@
     fprintf (stderr, "ext analysis skipped @ 5  : %d\n", Nskip5);
     fprintf (stderr, "ext analysis skipped @ 6  : %d\n", Nskip6);
+    fprintf (stderr, "ext analysis skipped @ 7  : %d\n", Nskip7);
+    fprintf (stderr, "ext analysis skipped @ 8  : %d\n", Nskip8);
 #endif
 
@@ -221,4 +224,7 @@
 
     // psphotVisualShowPetrosians (sources);
+
+    // XXX TEST: SAVE IMAGE:
+    // psphotSaveImage (NULL, readout->image, "resid.fits");
 
     return true;
@@ -291,4 +297,13 @@
 
 	// Nall ++;
+
+	bool testObject = FALSE;
+	// testObject = testObject || ((fabs(source->peak->xf - 5788) < 10) && (fabs(source->peak->yf - 5711) < 10));
+	// testObject = testObject || ((fabs(source->peak->xf -   96) < 10) && (fabs(source->peak->yf - 5550) < 10));
+	// testObject = testObject || ((fabs(source->peak->xf -  300) < 10) && (fabs(source->peak->yf - 5988) < 10));
+	if (testObject) {
+	  fprintf (stderr, "test object: %f, %f\n", source->peak->xf, source->peak->yf);
+	  testObject = TRUE;
+	}
 
 	// rules for measuring petrosian parameters for specific objects are set in
@@ -437,11 +452,17 @@
 
 #ifdef USE_FOOTPRINTS
-                if (vFootprint[yImage][xImage]) {
-#else
-                if (fabs(pixel) >= threshold) {
-#endif
+		// this is a pixel in the object
+                if (vFootprint[yImage][xImage] == source->peak->footprint->id) {
                     SET_MARK(MARK_SOURCE);
                     continue;
+		}
+		// this is a pixel in another object
+                if (vFootprint[yImage][xImage] > 0.0) continue;
+#else
+		// this is a pixel in an object (this or the other)
+                if (fabs(pixel) >= threshold) {
+		  continue
                 }
+#endif
                 // we have a background pixel.
                 // Check whether it's mirror is a background pixel as well.
@@ -583,8 +604,12 @@
 #ifdef PRINT_STUFF
         if (Ngood % 40 == 1) {
-            printf("   id  sumI rHL rad   sumI     gRT   gRA       sumRt      sumBt         numPixels numBGPixels\n");
-        }
-        printf("%5d %5.2e %3.1f %10.1f %6.3f %6.3f %5.2e %5.2e %10d %6ld\n",
-            source->id, sumI, source->extpars->ghalfLightRadius, radius, source->extpars->gRT, source->extpars->gRA, sumRt, sumBt, numPixels, bgPixels->n);
+	  fprintf (stderr, "   id  sumI rHL rad   sumI     gRT   gRA       sumRt      sumBt         numPixels numBGPixels\n");
+        }
+        fprintf (stderr, "%5d %5.1f %5.1f : %5.2e %4.1f %10.1f %6.3f %6.3f %5.2e %5.2e %10d %6ld\n",
+		 source->id, source->peak->xf, source->peak->yf, 
+		 sumI, source->extpars->ghalfLightRadius, 
+		 radius, 
+		 source->extpars->gRT, 
+		 source->extpars->gRA, sumRt, sumBt, numPixels, bgPixels->n);
 #endif
 
@@ -592,5 +617,10 @@
 restoreModel:
 
-        if ((extModel != sersicModel) || !isExtended) {
+	if (testObject) {
+	  fprintf (stderr, "done with %d\n", source->id);
+	}
+
+	// XXX TEST: Keep the sersic model regardless
+        if (FALSE && ((extModel != sersicModel) || !isExtended)) {
             // add the sersic model back in
             if (source->tmpFlags & PM_SOURCE_TMPF_SUBTRACTED) {
