Index: /branches/eam_branch_20070921/psphot/src/psphotSourcePlots.c
===================================================================
--- /branches/eam_branch_20070921/psphot/src/psphotSourcePlots.c	(revision 14992)
+++ /branches/eam_branch_20070921/psphot/src/psphotSourcePlots.c	(revision 14993)
@@ -20,8 +20,9 @@
     int dY = 0;                         // height of row so far
     int NX = 20*DX;                     // full width of output image
-    int NY = 0;                         // total height of output image
+    int NY = DY;                        // total height of output image so far
 
-    // first, examine the PSF and SAT stars:
-    // - determine bounding boxes for summary image
+    // first, examine the PSF and SAT stars to set output image size:
+    // - add stamp widths until we exceed output image width,
+    // - then start a new row offset by max height
     for (int i = 0; i < sources->n; i++) {
 
@@ -31,5 +32,8 @@
         keep |= (source->mode & PM_SOURCE_MODE_PSFSTAR);
         keep |= (source->mode & PM_SOURCE_MODE_SATSTAR);
-        if (!keep) continue;
+        if (!keep) {
+	    psTrace ("psphot", 4, "not plotting star %d: %x", i, source->mode);
+	    continue;
+	}
 
         // how does this subimage get placed into the output image?
@@ -57,7 +61,15 @@
     }
 
+    if (NY == 0) {
+	psWarning ("no PSF or SAT stars to plot? skipping.\n");
+	return false;
+    }
+
     // allocate output image
     psImage *outpos = psImageAlloc (NX, NY, PS_TYPE_F32);
     psImage *outsub = psImageAlloc (NX, NY, PS_TYPE_F32);
+
+    psImageInit (outpos, 0.0);
+    psImageInit (outsub, 0.0);
 
     int Xo = 0;                         // starting corner of next box
@@ -142,5 +154,5 @@
     psFree (outpos);
     psFree (outsub);
-    return (sources);
+    return true;
 }
 
