Index: /branches/eam_branches/ipp-20110213/ppStack/src/ppStackPrepare.c
===================================================================
--- /branches/eam_branches/ipp-20110213/ppStack/src/ppStackPrepare.c	(revision 30701)
+++ /branches/eam_branches/ipp-20110213/ppStack/src/ppStackPrepare.c	(revision 30702)
@@ -1,7 +1,9 @@
-#include "ppStack.h"
-
-#define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \
-                          PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
-                          PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources
+# include "ppStack.h"
+
+# define RE_PHOTOMETER 0
+
+# define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \
+			   PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
+			   PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources
 
 bool ppStackInputPhotometer(const pmReadout *ro, const psArray *sources, const pmConfig *config)
@@ -13,4 +15,5 @@
     psAssert(recipe, "We've thrown an error on this before.");
 
+# if (RE_PHOTOMETER)
     bool mdok;                          // Status of MD lookup
 
@@ -38,7 +41,6 @@
     psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
 
+    // Measure background
     psImage *image = ro->image, *mask = ro->mask; // Image and mask from readout
-
-    // Measure background
     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
     psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics
@@ -52,7 +54,7 @@
     psFree(stats);
     psFree(rng);
-
-    // Photometer sources
-    int numCols = image->numCols, numRows = image->numRows; // Size of image
+# endif
+
+    // Examine the sources (photometer if RE_PHOTOMETER is set)
     int numSources = sources->n; // Number of sources
     int numGood = 0;            // Number of good sources
@@ -64,5 +66,13 @@
             continue;
         }
-        float x = source->peak->xf, y = source->peak->yf; // Coordinates of source
+
+// This code re-measures the magnitude in the assumption that the warp analysis failed It would
+// be better to catch and correct such cases.  In any case, we should check on the validity of
+// this assumption (eg, compare the mean psf-ap offset) and raise an error on that?
+
+# if (RE_PHOTOMETER)
+	
+	int numCols = image->numCols, numRows = image->numRows; // Size of image
+	float x = source->peak->xf, y = source->peak->yf; // Coordinates of source
         int xCentral = x + 0.5, yCentral = y + 0.5; // Central pixel
         // Range of integration
@@ -96,4 +106,8 @@
             }
         }
+# else
+	numGood++;
+	maxMag = PS_MAX(maxMag, source->psfMag);
+# endif
     }
     psLogMsg("ppStack", PS_LOG_INFO, "Photometered %d good sources in image; max mag %f", numGood, maxMag);
