Index: trunk/psModules/src/imcombine/pmSubtractionParams.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtractionParams.c	(revision 21363)
+++ trunk/psModules/src/imcombine/pmSubtractionParams.c	(revision 26035)
@@ -71,5 +71,5 @@
                             double *sumII, // Sum of I(x)^2/sigma(x)^2
                             double *sumIC, // Sum of I(x)conv(x)/sigma(x)^2
-                            const pmSubtractionStamp *stamp, // Stamp with variance
+                            const pmSubtractionStamp *stamp, // Stamp
                             const psKernel *target, // Target stamp
                             int kernelIndex, // Index for kernel component
@@ -78,13 +78,13 @@
     )
 {
-    psKernel *variance = stamp->variance;   // Variance, sigma(x)^2
+    psKernel *weight = stamp->weight;   // Weight image
     psKernel *convolution = selectConvolution(stamp, kernelIndex, mode); // Convolution of interest
 
     for (int y = -footprint; y <= footprint; y++) {
         psF32 *in = &target->kernel[y][-footprint]; // Dereference input
-        psF32 *wt = &variance->kernel[y][-footprint]; // Dereference variance
+        psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight
         psF32 *conv = &convolution->kernel[y][-footprint]; // Dereference convolution
         for (int x = -footprint; x <= footprint; x++, in++, wt++, conv++) {
-            double temp = *in / *wt; // Temporary product
+            double temp = *in * *wt; // Temporary product
             *sumI += temp;
             *sumII += *in * temp;
@@ -98,5 +98,5 @@
 static void accumulateConvolutions(double *sumC, // Sum of conv(x)/sigma(x)^2
                                    double *sumCC, // Sum of conv(x)^2/sigma(x)^2
-                                   const pmSubtractionStamp *stamp, // Stamp with input and variance
+                                   const pmSubtractionStamp *stamp, // Stamp with input and weight
                                    int kernelIndex, // Index for kernel component
                                    int footprint, // Size of region of interest
@@ -104,12 +104,12 @@
     )
 {
-    psKernel *variance = stamp->variance;   // Variance, sigma(x)^2
+    psKernel *weight = stamp->weight;   // Weight image
     psKernel *convolution = selectConvolution(stamp, kernelIndex, mode); // Convolution of interest
 
     for (int y = -footprint; y <= footprint; y++) {
-        psF32 *wt = &variance->kernel[y][-footprint]; // Dereference variance
+        psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight
         psF32 *conv = &convolution->kernel[y][-footprint]; // Dereference convolution
         for (int x = -footprint; x <= footprint; x++, wt++, conv++) {
-            double convNoise = *conv / *wt; // Temporary product
+            double convNoise = *conv * *wt; // Temporary product
             *sumC += convNoise;
             *sumCC += *conv * convNoise;
@@ -120,5 +120,5 @@
 
 static double accumulateChi2(const psKernel *target, // Target stamp
-                             pmSubtractionStamp *stamp, // Stamp with variance
+                             pmSubtractionStamp *stamp, // Stamp with weight
                              int kernelIndex, // Index for kernel component
                              double coeff, // Coefficient of convolution
@@ -129,13 +129,13 @@
 {
     double chi2 = 0.0;
-    psKernel *variance = stamp->variance;   // Variance, sigma(x)^2
+    psKernel *weight = stamp->weight;   // Weight image
     psKernel *convolution = selectConvolution(stamp, kernelIndex, mode); // Convolution of interest
 
     for (int y = -footprint; y <= footprint; y++) {
         psF32 *in = &target->kernel[y][-footprint]; // Dereference input
-        psF32 *wt = &variance->kernel[y][-footprint]; // Dereference variance
+        psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight
         psF32 *conv = &convolution->kernel[y][-footprint]; // Dereference convolution
         for (int x = -footprint; x <= footprint; x++, in++, wt++, conv++) {
-            chi2 += PS_SQR(*in - bg - coeff * *conv) / *wt;
+            chi2 += PS_SQR(*in - bg - coeff * *conv) * *wt;
         }
     }
@@ -146,10 +146,10 @@
 // Return the initial value of chi^2
 static double initialChi2(const psKernel *target, // Target stamp
-                          const pmSubtractionStamp *stamp, // Stamp with variance
+                          const pmSubtractionStamp *stamp, // Stamp
                           int footprint, // Size of convolution
                           pmSubtractionMode mode // Mode of subtraction
     )
 {
-    psKernel *variance = stamp->variance;   // Variance map
+    psKernel *weight = stamp->weight;   // Weight image
     psKernel *source;                   // Source stamp
     switch (mode) {
@@ -167,9 +167,9 @@
     for (int y = -footprint; y <= footprint; y++) {
         psF32 *in = &target->kernel[y][-footprint]; // Dereference input
-        psF32 *wt = &variance->kernel[y][-footprint]; // Dereference variance
+        psF32 *wt = &weight->kernel[y][-footprint]; // Dereference weight
         psF32 *ref = &source->kernel[y][-footprint]; // Derference reference
         for (int x = -footprint; x <= footprint; x++, in++, wt++, ref++) {
             float diff = *in - *ref;    // Temporary value
-            chi2 += PS_SQR(diff) / *wt;
+            chi2 += PS_SQR(diff) * *wt;
         }
     }
@@ -180,5 +180,5 @@
 // Subtract a convolution from the input
 static void subtractConvolution(psKernel *target, // Target stamp
-                                const pmSubtractionStamp *stamp, // Stamp with variance
+                                const pmSubtractionStamp *stamp, // Stamp
                                 int kernelIndex, // Index for kernel component
                                 float coeff, // Coefficient of subtraction
@@ -288,9 +288,9 @@
 
         // This sum is invariant to the kernel
-        psKernel *variance = stamp->variance; // Variance map for stamp
+        psKernel *weight = stamp->weight; // Weight image
         for (int v = -footprint; v <= footprint; v++) {
-            psF32 *wt = &variance->kernel[v][-footprint]; // Dereference variance map
+            psF32 *wt = &weight->kernel[v][-footprint]; // Dereference weight
             for (int u = -footprint; u <= footprint; u++, wt++) {
-                sum1 += 1.0 / *wt;
+                sum1 += 1.0 * *wt;
             }
         }
