Index: trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 31451)
+++ trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 31670)
@@ -134,5 +134,5 @@
     // measure PSF model photometry
     status = pmSourcePhotometryModel (&source->psfMag, &source->psfFlux, modelPSF);
-    source->psfFluxErr = source->psfFlux * source->psfMagErr;
+    source->psfFluxErr = fabs(source->psfFlux * source->psfMagErr);
 
 # if (0)
@@ -191,4 +191,6 @@
     }
 
+    pmSourceNeighborFlags (source);
+
     // measure the aperture magnitude, if (SN > AP_MIN_SN)
     if (!isfinite(SN)) {
@@ -264,4 +266,41 @@
 
 */
+
+bool pmSourceNeighborFlags (pmSource *source) {
+
+    return false;
+
+    // source must have a peak to have a footprint
+    if (!source) return false;
+    if (!source->peak) return false;
+    if (!source->peak->footprint) return false;
+    if (!source->peak->footprint->peaks) return false;
+    if (!source->peak->footprint->peaks->n) return false;
+
+    // find the brightest peak (first peak)
+    pmPeak *brightPeak = source->peak->footprint->peaks->data[0];
+
+    // are we the brightest peak?
+    if (source->peak == brightPeak) return true;
+
+    // if not, raise a flag:
+    source->mode2 |= PM_SOURCE_MODE2_HAS_BRIGHTER_NEIGHBOR;
+
+    // but, this is a common situation.  more interesting is if the ratio flux_n / (r^2 flux_o) is large
+
+    float radius2 = PS_SQR(source->peak->xf - brightPeak->xf) + PS_SQR(source->peak->yf - brightPeak->yf);
+
+    float ratio = brightPeak->rawFlux / (source->peak->rawFlux * radius2);
+
+    if (ratio > 1) {
+	source->mode2 |= PM_SOURCE_MODE2_BRIGHT_NEIGHBOR_1;
+    }
+
+    if (ratio > 10) {
+	source->mode2 |= PM_SOURCE_MODE2_BRIGHT_NEIGHBOR_10;
+    }
+
+    return true;
+}
 
 // return source model magnitude
