Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 10611)
+++ trunk/psModules/src/objects/pmSource.c	(revision 11160)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-12-10 18:29:31 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-19 04:38:26 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -329,8 +329,8 @@
         psStats *stats  = NULL;
 
-        // XXX EAM : this lets us takes the single highest peak
+        // select the single highest peak
         psArraySort (peaks, pmPeaksCompareDescend);
         clump = peaks->data[0];
-        psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->counts);
+        psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->value);
 
         // define section window for clump
@@ -343,9 +343,16 @@
         tmpSy = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
 
-        // XXX clip sources based on flux?
         // create vectors with Sx, Sy values in window
+        // clip sources based on S/N
         for (psS32 i = 0 ; i < sources->n ; i++)
         {
             pmSource *tmpSrc = (pmSource *) sources->data[i];
+
+            if (tmpSrc == NULL)
+                continue;
+            if (tmpSrc->moments == NULL)
+                continue;
+            if (tmpSrc->moments->SN < PSF_CLUMP_SN_LIM)
+                continue;
 
             if (tmpSrc->moments->Sx < minSx)
@@ -380,5 +387,4 @@
         psTrace ("psModules.objects", 2, "clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
         psTrace ("psModules.objects", 2, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
-        // these values should be pushed on the recipe somewhere
 
         psFree (stats);
@@ -413,5 +419,6 @@
 
     // report stats on S/N values for star-like objects
-    psVector *starsn = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
+    psVector *starsn_peaks = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
+    psVector *starsn_moments = psVectorAllocEmpty (sources->n, PS_TYPE_F32);
 
     // get basic parameters, or set defaults
@@ -432,4 +439,12 @@
 
         source->peak->type = 0;
+
+        // we are basically classifying by moments; use the default if not found
+        if (!source->moments) {
+            source->type = PM_SOURCE_TYPE_STAR;
+            source->mode |= PM_SOURCE_MODE_DEFAULT;
+            Nstar++;
+            continue;
+        }
 
         psF32 sigX = source->moments->Sx;
@@ -482,6 +497,8 @@
 
         // the rest are probable stellar objects
-        starsn->data.F32[starsn->n] = source->moments->SN;
-        starsn->n ++;
+        starsn_moments->data.F32[starsn_moments->n] = source->moments->SN;
+        starsn_moments->n ++;
+        starsn_peaks->data.F32[starsn_peaks->n] = source->peak->SN;
+        starsn_peaks->n ++;
         Nstar ++;
 
@@ -500,11 +517,16 @@
     }
 
-    psStats *stats  = NULL;
+    psStats *stats = NULL;
     stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX);
-    psVectorStats (stats, starsn, NULL, NULL, 0);
-
-    psLogMsg ("pmObjects", 3, "SN range: %f - %f\n", stats[0].min, stats[0].max);
+    psVectorStats (stats, starsn_moments, NULL, NULL, 0);
+    psLogMsg ("pmObjects", 3, "SN range (moments): %f - %f\n", stats[0].min, stats[0].max);
+    psFree (starsn_moments);
     psFree (stats);
-    psFree (starsn);
+
+    stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX);
+    psVectorStats (stats, starsn_peaks, NULL, NULL, 0);
+    psLogMsg ("pmObjects", 3, "SN range (peaks)  : %f - %f\n", stats[0].min, stats[0].max);
+    psFree (starsn_peaks);
+    psFree (stats);
 
     psTrace ("psModules.objects", 2, "Nstar:    %3d\n", Nstar);
