Index: trunk/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtraction.c	(revision 13378)
+++ trunk/psModules/src/imcombine/pmSubtraction.c	(revision 13379)
@@ -4,6 +4,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-05-12 02:00:39 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-15 01:23:19 $
  *
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
@@ -79,5 +79,5 @@
           for (int v = -size; v <= size; v++) {
               for (int u = -size; u <= size; u++) {
-                  sum += weightFunc(kernel->kernel[v][u]) * image->data.F64[y + v][x + u];
+                  sum += weightFunc(kernel->kernel[v][u]) * image->data.F32[y + v][x + u];
               }
           }
@@ -163,8 +163,5 @@
     for (int i = 0; i < stamps->n; i++) {
         pmSubtractionStamp *stamp = stamps->data[i]; // Stamp of interest
-        psTrace("psModules.imcombine", 6, "Inspecting stamp %d\n", i);
-
         if (stamp->status == PM_SUBTRACTION_STAMP_CALCULATE) {
-            psTrace("psModules.imcombine", 6, "Calculating for stamp %d\n", i);
             psImage *stampMatrix = stamp->matrix; // Least-squares matrix for this stamp
             psVector *stampVector = stamp->vector; // Least-squares vector for this stamp
@@ -240,4 +237,14 @@
 
             stamp->status = PM_SUBTRACTION_STAMP_USED;
+
+            if (psTraceGetLevel("psModules.imcombine.equation") >= 10) {
+                psString matrixName = NULL;
+                psStringAppend(&matrixName, "matrix%d.fits", i);
+                psFits *matrixFile = psFitsOpen(matrixName, "w");
+                psFree(matrixName);
+                psFitsWriteImage(matrixFile, NULL, stampMatrix, 0, NULL);
+                psFitsClose(matrixFile);
+            }
+
         }
     }
@@ -311,4 +318,10 @@
         psError(PS_ERR_UNKNOWN, true, "Failed to solve the least-squares system.\n");
         return NULL;
+    }
+
+    if (psTraceGetLevel("psModules.imcombine") >= 7) {
+        for (int i = 0; i < solution->n; i++) {
+            printf("       Solution %d: %f\n", i, solution->data.F64[i]);
+        }
     }
 
@@ -413,4 +426,5 @@
         if (stamp->status == PM_SUBTRACTION_STAMP_USED && deviations->data.F32[i] > limit) {
             // Mask out the stamp in the image so you it's not found again
+            psTrace("psModules.imcombine", 3, "Rejecting stamp %d\n", i);
             numRejected++;
             for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) {
Index: trunk/psModules/src/imcombine/pmSubtractionKernels.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtractionKernels.c	(revision 13378)
+++ trunk/psModules/src/imcombine/pmSubtractionKernels.c	(revision 13379)
@@ -29,5 +29,5 @@
     }
     float result = value;               // Result to return
-    for (int i = 2; i < exp; i++) {
+    for (int i = 2; i <= exp; i++) {
         result *= value;
     }
@@ -144,6 +144,20 @@
                         kernels->yOrder->data.S32[index] = yOrder;
                         kernels->preCalc->data[index] = psMemIncrRefCounter(preCalc);
+
+                        psTrace("psModules.imcombine", 7, "Kernel %d: %f %d %d %d %d\n", index,
+                                sigmas->data.F32[i], uOrder, vOrder, xOrder, yOrder);
                     }
                 }
+
+
+                if (psTraceGetLevel("psModules.imcombine.kernel") >= 10) {
+                    psString kernelName = NULL;
+                    psStringAppend(&kernelName, "kernel%d.fits", index);
+                    psFits *kernelFile = psFitsOpen(kernelName, "w");
+                    psFree(kernelName);
+                    psFitsWriteImage(kernelFile, NULL, preCalc->image, 0, NULL);
+                    psFitsClose(kernelFile);
+                }
+
                 psFree(preCalc);        // Drop reference
             }
@@ -156,4 +170,5 @@
            kernels->xOrder->data.S32[kernels->subIndex] == 0 &&
            kernels->yOrder->data.S32[kernels->subIndex] == 0);
+
 
     return kernels;
