Index: /trunk/psModules/src/camera/pmHDUGenerate.c
===================================================================
--- /trunk/psModules/src/camera/pmHDUGenerate.c	(revision 7253)
+++ /trunk/psModules/src/camera/pmHDUGenerate.c	(revision 7254)
@@ -26,5 +26,7 @@
     for (int i = 0; i < cells->n; i++) {
         pmCell *cell = cells->data[i];  // A cell
-        result |= psListAdd(list, PS_LIST_TAIL, cell);
+        if (!cell->hdu) {               // Don't add cells that have their own HDU
+            result |= psListAdd(list, PS_LIST_TAIL, cell);
+        }
     }
 
@@ -44,5 +46,7 @@
     for (int i = 0; i < chips->n; i++) {
         pmChip *chip = chips->data[i];  // A chip
-        result |= addCellsFromChip(list, chip);
+        if (! chip->hdu) {              // Don't add chips that have their own HDU
+            result |= addCellsFromChip(list, chip);
+        }
     }
 
@@ -263,5 +267,5 @@
     }
     if (numReadouts == 0 || type == 0) {
-        psError(PS_ERR_IO, true, "Unable to find images within HDU.\n");
+        // Nothing from which to create an HDU
         psFree(cells);
         return false;
Index: /trunk/psModules/src/imcombine/pmReadoutCombine.c
===================================================================
--- /trunk/psModules/src/imcombine/pmReadoutCombine.c	(revision 7253)
+++ /trunk/psModules/src/imcombine/pmReadoutCombine.c	(revision 7254)
@@ -5,6 +5,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-05-25 04:06:28 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-05-31 22:51:15 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,4 +25,5 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+#if 1
 // Return the statistic of interest
 static double getStat(const psStats *stats, // Statistics structure
@@ -58,4 +59,5 @@
     return NAN;
 }
+#endif
 
 // Mask for combination --- used only locally
@@ -140,12 +142,4 @@
     long minInputCols = LONG_MAX;       // The smallest input column value
     long minInputRows = LONG_MAX;       // The smallest input row value
-    psVector *rowLower = psVectorAlloc(inputs->n, PS_TYPE_U32); // The lower y bound for each image
-    psVector *rowUpper = psVectorAlloc(inputs->n, PS_TYPE_U32); // The upper y bound for each image
-    psVector *colLower = psVectorAlloc(inputs->n, PS_TYPE_U32); // The lower x bound for each image
-    psVector *colUpper = psVectorAlloc(inputs->n, PS_TYPE_U32); // The upper x bound for each image
-    rowLower->n = inputs->n;
-    rowUpper->n = inputs->n;
-    colLower->n = inputs->n;
-    colUpper->n = inputs->n;
     psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack
     mask->n = inputs->n;
@@ -181,9 +175,4 @@
         psTrace(__func__, 7, "Readout %d: offset %d,%d; size %dx%d\n", i,
                 readout->col0, readout->row0, readout->image->numCols, readout->image->numRows);
-        // Bounds of input image
-        rowLower->data.U32[i] = readout->row0;
-        colLower->data.U32[i] = readout->col0;
-        rowUpper->data.U32[i] = readout->row0 + readout->image->numRows;
-        colUpper->data.U32[i] = readout->col0 + readout->image->numCols;
     }
     if (!valid) {
@@ -270,25 +259,37 @@
     psMaskType maskVal = params->maskVal; // The mask value
 
-    psTrace(__func__, 3, "Iterating %d --> %d, %d --> %d\n",
+    psTrace(__func__, 3, "Iterating output: %d --> %d, %d --> %d\n",
             minInputCols - output->col0, maxInputCols - output->col0,
             minInputRows - output->row0, maxInputRows - output->row0);
+    if (psTraceGetLevel(__func__) >= 3) {
+        for (int r = 0; r < inputs->n; r++) {
+            pmReadout *readout = inputs->data[r]; // Input readout
+            psTrace(__func__, 3, "Iterating input %d: %d --> %d, %d --> %d\n", r,
+                    minInputCols - readout->col0, maxInputCols - readout->col0,
+                    minInputRows - readout->row0, maxInputRows - readout->row0);
+        }
+    }
 
     for (int i = minInputRows; i < maxInputRows; i++) {
+        if (psTraceGetLevel(__func__) > 9) {
+            printf("Processing row %d\r", i);
+            fflush(stdout);
+        }
         for (int j = minInputCols; j < maxInputCols; j++) {
 
             int numValid = 0;           // Number of valid pixels in the stack
             for (int r = 0; r < inputs->n; r++) {
-                // Check existence and bounds
-                if (mask->data.U8[r] & PM_READOUT_COMBINE_NO_IMAGE ||
-                        i <  colLower->data.U32[r] ||
-                        i >= colUpper->data.U32[r] ||
-                        j <  rowLower->data.U32[r] ||
-                        j >= rowUpper->data.U32[r]) {
-                    continue;
-                }
-
                 pmReadout *readout = inputs->data[r]; // Input readout
                 int yIn = i - readout->row0; // y position on input readout
                 int xIn = j - readout->col0; // x position on input readout
+
+                // Check existence and bounds
+                if (mask->data.U8[r] & PM_READOUT_COMBINE_NO_IMAGE ||
+                        xIn < 0 || xIn >= readout->image->numCols ||
+                        yIn < 0 || yIn >= readout->image->numRows) {
+                    continue;
+                }
+
+                // Check mask
                 if (readout->mask && readout->mask->data.U8[yIn][xIn] & maskVal) {
                     mask->data.U8[r] &= PM_READOUT_COMBINE_MASKED;
@@ -317,13 +318,13 @@
             int yOut = i - output->row0; // y position on output readout
             int xOut = j - output->col0; // x position on output readout
-            psTrace(__func__, 10, "Output pixel: %d %d\n", xOut, yOut);
 
             if (numValid == 0) {
                 output->mask->data.U8[yOut][xOut] = PM_MASK_FLAT;
+                output->image->data.F32[yOut][xOut] = NAN;
                 continue;
             }
 
             // Apply fracLow,fracHigh if there are enough pixels
-            if (numValid * keepFrac >= params->nKeep) {
+            if (numValid * keepFrac >= params->nKeep && keepFrac != 1.0) {
                 index = psVectorSortIndex(index, pixels);
                 int numLow = numValid * params->fracLow; // Number of low pixels to clip
@@ -359,10 +360,9 @@
         }
     }
+    if (psTraceGetLevel(__func__) > 9) {
+        printf("\n");
+    }
 
     psFree(index);
-    psFree(rowLower);
-    psFree(rowUpper);
-    psFree(colLower);
-    psFree(colUpper);
     psFree(pixels);
     psFree(mask);
