Index: trunk/psphot/src/psphotFindPeaks.c
===================================================================
--- trunk/psphot/src/psphotFindPeaks.c	(revision 26894)
+++ trunk/psphot/src/psphotFindPeaks.c	(revision 31154)
@@ -4,5 +4,5 @@
 // image must be constructed to represent (S/N)^2.  If nMax is non-zero, only return a maximum
 // of nMax peaks
-psArray *psphotFindPeaks (psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int nMax) {
+psArray *psphotFindPeaks (pmReadout *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int nMax) {
 
     bool status = false;
@@ -11,5 +11,6 @@
 
     // find the peaks in the smoothed image
-    psArray *peaks = pmPeaksInImage (significance, threshold);
+    // NOTE : significance->variance actually carries the detection S/N image
+    psArray *peaks = pmPeaksInImage (significance->variance, threshold);
     if (peaks == NULL) {
 	// we only get a NULL peaks array due to a programming or config error. 
@@ -34,12 +35,13 @@
     for (int i = 0; i < peaks->n; i++) {
         pmPeak *peak = peaks->data[i];
-        peak->SN = sqrt(peak->value);
-        peak->flux = readout->image->data.F32[peak->y-row0][peak->x-col0];
-	// if (peak->flux / peak->value > 5.0/12.0) {
-	//     psWarning ("odd peak levels (1)");
-	// }
-	// if (peak->value / peak->flux > 5*12.0) {
-	//     psWarning ("odd peak levels (2)");
-	// }
+        peak->rawFlux = readout->image->data.F32[peak->y-row0][peak->x-col0];
+	peak->rawFluxStdev = sqrt(readout->variance->data.F32[peak->y-row0][peak->x-col0]);
+        peak->smoothFlux = significance->image->data.F32[peak->y-row0][peak->x-col0];
+	peak->smoothFluxStdev = peak->smoothFlux / sqrt(significance->variance->data.F32[peak->y-row0][peak->x-col0]);
+	// NOTE smoothFluxStdev is actually (sqrt(variance) / covar_factor)
+
+	// do we need this or not?
+        // peak->SN = sqrt(peak->detValue);
+
 	if (readout->variance && isfinite (peak->dx)) {
 	    peak->dx *= sqrt(readout->variance->data.F32[peak->y-row0][peak->x-col0]);
@@ -51,5 +53,5 @@
 
     // limit the total number of returned peaks as specified
-    psArraySort (peaks, pmPeakSortBySN);
+    psArraySort (peaks, pmPeaksSortByRawFluxDescend);
     if (nMax && (peaks->n > nMax)) {
 	psArray *tmpPeaks = psArrayAllocEmpty (nMax);
