Index: /branches/pap_branch_20090128/psModules/src/imcombine/pmStack.c
===================================================================
--- /branches/pap_branch_20090128/psModules/src/imcombine/pmStack.c	(revision 21331)
+++ /branches/pap_branch_20090128/psModules/src/imcombine/pmStack.c	(revision 21332)
@@ -8,6 +8,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.46.2.1 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-01-29 00:33:51 $
+ *  @version $Revision: 1.46.2.2 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-05 21:31:31 $
  *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
  *
@@ -30,5 +30,6 @@
 #define PIXEL_LIST_BUFFER 100           // Number of entries to add to pixel list at a time
 #define PIXEL_MAP_BUFFER 2              // Number of entries to add to pixel map at a time
-//#define VARIANCE_FACTORS                // Use variance factors when calculating the variances?
+#define VARIANCE_FACTORS                // Use variance factors when calculating the variances?
+//#define ADD_VARIANCE                  // Allow additional variance (besides variance factor)?
 #define NUM_DIRECT_STDEV 5              // For less than this number of values, measure stdev directly
 
@@ -606,14 +607,11 @@
         weights->data.F32[i] = data->weight;
         stack->data[i] = psMemIncrRefCounter(data->readout);
-        // Variance factor
-        float vf = psMetadataLookupF32(NULL, data->readout->parent->concepts, "CELL.VARFACTOR"); // Var factor
-        if (!isfinite(vf)) {
-            psWarning("Non-finite CELL.VARFACTOR for image %d --- setting to unity.", i);
-            vf = 1.0;
-        }
-        varFactors->data.F32[i] = vf;
+        varFactors->data.F32[i] = data->readout->covariance ?
+            psImageCovarianceFactor(data->readout->covariance) : 1.0;
+#if 0
         if (isfinite(data->addVariance)) {
             varFactors->data.F32[i] *= data->addVariance;
         }
+#endif
         if (!haveRejects && !data->inspect) {
             data->inspect = psPixelsAllocEmpty(PIXEL_LIST_BUFFER);
