Index: trunk/psModules/src/imcombine/pmSubtractionEquation.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtractionEquation.c	(revision 20561)
+++ trunk/psModules/src/imcombine/pmSubtractionEquation.c	(revision 21363)
@@ -24,5 +24,5 @@
 static inline double calculateSumProduct(const psKernel *image1, // First image in multiplication
                                          const psKernel *image2, // Second image in multiplication
-                                         const psKernel *weight, // Weight image
+                                         const psKernel *variance, // Variance image
                                          int footprint // (Half-)Size of stamp
     )
@@ -31,5 +31,5 @@
     for (int y = - footprint; y <= footprint; y++) {
         for (int x = - footprint; x <= footprint; x++) {
-            sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // weight->kernel[y][x];
+            sum += image1->kernel[y][x] * image2->kernel[y][x] / 1.0; // variance->kernel[y][x];
         }
     }
@@ -42,5 +42,5 @@
                                            const psKernel *image1, // First image in multiplication
                                            const psKernel *image2, // Second image in multiplication
-                                           const psKernel *weight, // Weight image
+                                           const psKernel *variance, // Variance image
                                            const psImage *polyValues, // Spatial polynomial values
                                            int numKernels, // Number of kernel basis functions
@@ -50,5 +50,5 @@
     )
 {
-    double sum = calculateSumProduct(image1, image2, weight, footprint); // Sum of the image products
+    double sum = calculateSumProduct(image1, image2, variance, footprint); // Sum of the image products
     if (!isfinite(sum)) {
         return false;
@@ -79,5 +79,5 @@
                                            const psKernel *image1, // First image in multiplication
                                            const psKernel *image2, // Second image in multiplication
-                                           const psKernel *weight, // Weight image
+                                           const psKernel *variance, // Variance image
                                            const psImage *polyValues, // Spatial polynomial values
                                            int numKernels, // Number of kernel basis functions
@@ -87,5 +87,5 @@
     )
 {
-    double sum = calculateSumProduct(image1, image2, weight, footprint); // Sum of the image products
+    double sum = calculateSumProduct(image1, image2, variance, footprint); // Sum of the image products
     if (!isfinite(sum)) {
         return false;
@@ -120,5 +120,5 @@
                                   const psArray *convolutions1, // Convolutions for element 1
                                   const psArray *convolutions2, // Convolutions for element 2
-                                  const psKernel *weight, // Weight image
+                                  const psKernel *variance, // Variance image
                                   const psImage *polyValues, // Polynomial values
                                   int numKernels, // Number of kernel basis functions
@@ -135,5 +135,5 @@
             psKernel *jConv = convolutions2->data[j]; // Convolution for j-th element
 
-            if (!calculateMatrixElement2(matrix, i, j, iConv, jConv, weight, polyValues, numKernels,
+            if (!calculateMatrixElement2(matrix, i, j, iConv, jConv, variance, polyValues, numKernels,
                                          footprint, spatialOrder, symmetric)) {
                 psTrace("psModules.imcombine", 2, "Bad sumCC at %d, %d", i, j);
@@ -151,5 +151,5 @@
                             const psArray *convolutions, // Convolutions of source with kernels
                             const psKernel *input, // Input stamp, or NULL
-                            const psKernel *weight, // Weight stamp
+                            const psKernel *variance, // Variance stamp
                             const psImage *polyValues, // Spatial polynomial values
                             int footprint, // (Half-)Size of stamp
@@ -171,5 +171,5 @@
 
     // Square part of the matrix (convolution-convolution products)
-    if (!calculateMatrixSquare(matrix, convolutions, convolutions, weight, polyValues, numKernels,
+    if (!calculateMatrixSquare(matrix, convolutions, convolutions, variance, polyValues, numKernels,
                                spatialOrder, footprint)) {
         return false;
@@ -185,5 +185,5 @@
 
             // Normalisation-convolution terms
-            if (!calculateMatrixElement1(matrix, i, normIndex, conv, input, weight, polyValues, numKernels,
+            if (!calculateMatrixElement1(matrix, i, normIndex, conv, input, variance, polyValues, numKernels,
                                          footprint, spatialOrder, true)) {
                 psTrace("psModules.imcombine", 2, "Bad sumIC at %d", i);
@@ -195,5 +195,5 @@
             for (int y = - footprint; y <= footprint; y++) {
                 for (int x = - footprint; x <= footprint; x++) {
-                    sumC += conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
+                    sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
                 }
             }
@@ -218,5 +218,5 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                double invNoise2 = 1.0 / 1.0; // weight->kernel[y][x];
+                double invNoise2 = 1.0 / 1.0; // variance->kernel[y][x];
                 double value = input->kernel[y][x] * invNoise2;
                 sumI += value;
@@ -253,5 +253,5 @@
                             const psKernel *input, // Input stamp, or NULL if !normAndBG
                             const psKernel *target, // Target stamp
-                            const psKernel *weight, // Weight stamp
+                            const psKernel *variance, // Variance stamp
                             const psImage *polyValues, // Spatial polynomial values
                             int footprint, // (Half-)Size of stamp
@@ -277,5 +277,5 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
+                sumTC += target->kernel[y][x] * conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
             }
         }
@@ -297,5 +297,5 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                float value = target->kernel[y][x] / 1.0; // weight->kernel[y][x];
+                float value = target->kernel[y][x] / 1.0; // variance->kernel[y][x];
                 sumIT += value * input->kernel[y][x];
                 sumT += value;
@@ -329,5 +329,5 @@
                                  const psArray *convolutions2, // Convolutions of image 2
                                  const psKernel *image1, // Image 1 stamp
-                                 const psKernel *weight, // Weight stamp
+                                 const psKernel *variance, // Variance stamp
                                  const psImage *polyValues, // Spatial polynomial values
                                  int footprint // (Half-)Size of stamp
@@ -348,5 +348,5 @@
     PM_SUBTRACTION_INDICES(normIndex, bgIndex, kernels);
 
-    if (!calculateMatrixSquare(matrix, convolutions1, convolutions2, weight, polyValues, numKernels,
+    if (!calculateMatrixSquare(matrix, convolutions1, convolutions2, variance, polyValues, numKernels,
                                spatialOrder, footprint)) {
         return false;
@@ -356,5 +356,5 @@
         // Normalisation
         psKernel *conv = convolutions2->data[i]; // Convolution
-        if (!calculateMatrixElement1(matrix, i, normIndex, conv, image1, weight, polyValues, numKernels,
+        if (!calculateMatrixElement1(matrix, i, normIndex, conv, image1, variance, polyValues, numKernels,
                                      footprint, spatialOrder, false)) {
             psTrace("psModules.imcombine", 2, "Bad sumIC at %d", i);
@@ -366,5 +366,5 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                sumC += conv->kernel[y][x] / 1.0; // weight->kernel[y][x];
+                sumC += conv->kernel[y][x] / 1.0; // variance->kernel[y][x];
             }
         }
@@ -559,13 +559,13 @@
       case PM_SUBTRACTION_MODE_1:
         status = calculateMatrix(stamp->matrix1, kernels, stamp->convolutions1, stamp->image1,
-                                 stamp->weight, polyValues, footprint, true);
+                                 stamp->variance, polyValues, footprint, true);
         status &= calculateVector(stamp->vector1, kernels, stamp->convolutions1, stamp->image1,
-                                  stamp->image2, stamp->weight, polyValues, footprint, true);
+                                  stamp->image2, stamp->variance, polyValues, footprint, true);
         break;
       case PM_SUBTRACTION_MODE_2:
         status = calculateMatrix(stamp->matrix1, kernels, stamp->convolutions2, stamp->image2,
-                                 stamp->weight, polyValues, footprint, true);
+                                 stamp->variance, polyValues, footprint, true);
         status &= calculateVector(stamp->vector1, kernels, stamp->convolutions2, stamp->image2,
-                                  stamp->image1, stamp->weight, polyValues, footprint, true);
+                                  stamp->image1, stamp->variance, polyValues, footprint, true);
         break;
       case PM_SUBTRACTION_MODE_DUAL:
@@ -581,14 +581,14 @@
 #endif
         status  = calculateMatrix(stamp->matrix1, kernels, stamp->convolutions1, stamp->image1,
-                                  stamp->weight, polyValues, footprint, true);
+                                  stamp->variance, polyValues, footprint, true);
         status &= calculateMatrix(stamp->matrix2, kernels, stamp->convolutions2, NULL,
-                                  stamp->weight, polyValues, footprint, false);
+                                  stamp->variance, polyValues, footprint, false);
         status &= calculateMatrixCross(stamp->matrixX, kernels, stamp->convolutions1,
-                                       stamp->convolutions2, stamp->image1, stamp->weight, polyValues,
+                                       stamp->convolutions2, stamp->image1, stamp->variance, polyValues,
                                        footprint);
         status &= calculateVector(stamp->vector1, kernels, stamp->convolutions1, stamp->image1,
-                                  stamp->image2, stamp->weight, polyValues, footprint, true);
+                                  stamp->image2, stamp->variance, polyValues, footprint, true);
         status &= calculateVector(stamp->vector2, kernels, stamp->convolutions2, NULL,
-                                  stamp->image2, stamp->weight, polyValues, footprint, false);
+                                  stamp->image2, stamp->variance, polyValues, footprint, false);
         break;
       default:
@@ -1033,5 +1033,5 @@
 
         // Calculate residuals
-        psKernel *weight = stamp->weight; // Weight postage stamp
+        psKernel *variance = stamp->variance; // Variance postage stamp
         psImageInit(residual->image, 0.0);
         if (kernels->mode != PM_SUBTRACTION_MODE_DUAL) {
@@ -1098,5 +1098,5 @@
         for (int y = - footprint; y <= footprint; y++) {
             for (int x = - footprint; x <= footprint; x++) {
-                double dev = PS_SQR(residual->kernel[y][x]) / weight->kernel[y][x];
+                double dev = PS_SQR(residual->kernel[y][x]) / variance->kernel[y][x];
                 deviation += dev;
 #ifdef TESTING
@@ -1141,10 +1141,10 @@
             psFitsClose(fits);
         }
-        if (stamp->weight) {
+        if (stamp->variance) {
             psString filename = NULL;
-            psStringAppend(&filename, "stamp_weight_%03d.fits", i);
+            psStringAppend(&filename, "stamp_variance_%03d.fits", i);
             psFits *fits = psFitsOpen(filename, "w");
             psFree(filename);
-            psFitsWriteImage(fits, NULL, stamp->weight->image, 0, NULL);
+            psFitsWriteImage(fits, NULL, stamp->variance->image, 0, NULL);
             psFitsClose(fits);
         }
