Index: /branches/pap_branch_080908/psModules/src/imcombine/pmStack.c
===================================================================
--- /branches/pap_branch_080908/psModules/src/imcombine/pmStack.c	(revision 19477)
+++ /branches/pap_branch_080908/psModules/src/imcombine/pmStack.c	(revision 19478)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.38.2.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-09-10 18:17:54 $
+ *  @version $Revision: 1.38.2.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-09-11 03:35:30 $
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
  *
@@ -265,5 +265,5 @@
         pixelData->data.F32[num] = image->data.F32[yIn][xIn];
         if (variance) {
-            pixelVariances->data.F32[num] = variance->data.F32[yIn][xIn] * varFactors->data.F32[i];
+            pixelVariances->data.F32[num] = variance->data.F32[yIn][xIn];
         }
         pixelWeights->data.F32[num] = data->weight;
@@ -312,5 +312,6 @@
               // Use variance to check that the two are consistent
               float diff = pixelData->data.F32[0] - pixelData->data.F32[1];
-              float sigma2 = pixelVariances->data.F32[0] + pixelVariances->data.F32[1];
+              float sigma2 = pixelVariances->data.F32[0] * varFactors->data.F32[pixelSources->data.U16[0]] +
+                  pixelVariances->data.F32[1] * varFactors->data.F32[pixelSources->data.U16[1]];
               if (PS_SQR(diff) > PS_SQR(rej) * sigma2) {
                   // Not consistent: mark both for inspection
@@ -341,5 +342,5 @@
                   float rej2 = PS_SQR(rej); // Rejection level squared
                   for (int i = 0; i < num; i++) {
-                      pixelVariances->data.F32[i] *= rej2;
+                      pixelVariances->data.F32[i] *= rej2 * varFactors->data.F32[pixelSources->data.U16[i]];;
                   }
               }
@@ -377,5 +378,6 @@
                   if (useVariance) {
                       // Comparing squares --- cheaper than lots of sqrts
-                      if (PS_SQR(diff) > rej2 * pixelVariances->data.F32[j]) {
+                      // pixelVariances includes the variance factor and the rejection limit, from above
+                      if (PS_SQR(diff) > pixelVariances->data.F32[j]) {
                           MASK_PIXEL_FOR_INSPECTION();
                       }
