Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 11160)
+++ trunk/psModules/src/objects/pmSource.c	(revision 11261)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA: significant modifications.
  *
- *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-19 04:38:26 $
+ *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-24 21:32:19 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -214,9 +214,10 @@
 
     psArray *peaks  = NULL;
-    pmPSFClump emptyClump = {0.0, 0.0, 0.0, 0.0};
-    pmPSFClump psfClump = emptyClump;
-
-    PS_ASSERT_PTR_NON_NULL(sources, emptyClump);
-    PS_ASSERT_PTR_NON_NULL(recipe, emptyClump);
+    pmPSFClump errorClump = {-1.0, -1.0, 0.0, 0.0};
+    pmPSFClump emptyClump = {+0.0, +0.0, 0.0, 0.0};
+    pmPSFClump psfClump;
+
+    PS_ASSERT_PTR_NON_NULL(sources, errorClump);
+    PS_ASSERT_PTR_NON_NULL(recipe, errorClump);
 
     bool status = true;
@@ -249,34 +250,26 @@
 
         // place the sources in the sigma-plane image (ignore 0,0 values?)
+        int nValid = 0;
         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 == NULL)
+                continue;
+            if (tmpSrc->moments == NULL)
+                continue;
+            if (tmpSrc->moments->SN < PSF_CLUMP_SN_LIM)
+                continue;
 
             // Sx,Sy are limited at 0.  a peak at 0,0 is artificial
-            if (fabs(tmpSrc->moments->Sx) < 0.05) {
-                continue;
-            }
-            if (fabs(tmpSrc->moments->Sy) < 0.05) {
-                continue;
-            }
-            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) > AR_MAX) {
-                continue;
-            }
-            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) < AR_MIN) {
-                continue;
-            }
-            if (tmpSrc->mode & PM_SOURCE_MODE_BLEND) {
-                continue;
-            }
+            if (fabs(tmpSrc->moments->Sx) < 0.05)
+                continue;
+            if (fabs(tmpSrc->moments->Sy) < 0.05)
+                continue;
+            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) > AR_MAX)
+                continue;
+            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) < AR_MIN)
+                continue;
+            if (tmpSrc->mode & PM_SOURCE_MODE_BLEND)
+                continue;
 
             // for the moment, force splane dimensions to be 10x10 image pix
@@ -294,4 +287,5 @@
 
             splane->data.F32[binY][binX] += 1.0;
+            nValid ++;
         }
 
@@ -311,12 +305,16 @@
         psFree (stats);
 
+        // if we failed to find a valid peak, return the empty clump (failure signal)
         if (peaks == NULL)
         {
-            return (psfClump);
-        }
-    }
-    // XXX EAM : possible errors:
-    //           1) no peak in splane
-    //           2) no significant peak in splane
+            psLogMsg ("psphot", 3, "failed to find a peak in the PSF clump image\n");
+            if (nValid == 0) {
+                psLogMsg ("psphot", 3, "no valid sources kept for PSF search\n");
+            } else {
+                psLogMsg ("psphot", 3, "no significant peak\n");
+            }
+            return (emptyClump);
+        }
+    }
 
     // measure statistics on Sx, Sy if Sx, Sy within range of clump
@@ -408,5 +406,6 @@
     psTrace("psModules.objects", 5, "---- begin ----");
 
-    psBool rc = true;
+    PS_ASSERT_PTR_NON_NULL(sources, false);
+    PS_ASSERT_PTR_NON_NULL(recipe, false);
 
     int Nsat     = 0;
@@ -538,5 +537,5 @@
 
     psTrace("psModules.objects", 5, "---- end ----\n");
-    return(rc);
+    return true;
 }
 
