Index: /trunk/ppMerge/src/ppMergeArguments.c
===================================================================
--- /trunk/ppMerge/src/ppMergeArguments.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeArguments.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-01 21:43:05 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -25,6 +25,6 @@
             "\tIMAGE(STR):     Image filename\n"
             "\tMASK(STR):      Mask filename\n"
-            "\tWEIGHT(STR)     Weight map filename\n"
-            "where MASK and WEIGHT are optional.",
+            "\tVARIANCE(STR)   Variance map filename\n"
+            "where MASK and VARIANCE are optional.",
             program);
     fprintf(stderr, "\n");
@@ -155,5 +155,5 @@
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-frachigh", 0, "Fraction of low pixels to discard", NAN);
     psMetadataAddS32(arguments, PS_LIST_TAIL, "-nkeep",    0, "Minimum number of pixels in stack to keep", 0);
-    psMetadataAddBool(arguments, PS_LIST_TAIL, "-weights", 0, "Use image weights in combination?", false);
+    psMetadataAddBool(arguments, PS_LIST_TAIL, "-variances", 0, "Use image variances in combination?", false);
 
     // XXX EAM : not clear this should be allowed on the command line.
@@ -300,5 +300,5 @@
     VALUE_ARG_RECIPE_FLOAT("-frachigh", "FRACHIGH", F32);
     VALUE_ARG_RECIPE_INT("-nkeep",      "NKEEP",    S32, 0);
-    VALUE_ARG_RECIPE_BOOL("-weights",   "WEIGHTS");
+    VALUE_ARG_RECIPE_BOOL("-variances", "VARIANCES");
 
     // XXX we do not supply this on the command line
Index: /trunk/ppMerge/src/ppMergeCamera.c
===================================================================
--- /trunk/ppMerge/src/ppMergeCamera.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeCamera.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-01 21:43:05 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -96,5 +96,5 @@
 {
     bool haveMasks = false;             // Do we have masks?
-    bool haveWeights = false;           // Do we have weight maps?
+    bool haveVariances = false;           // Do we have variance maps?
 
     ppMergeType type = psMetadataLookupS32(NULL, config->arguments, "TYPE"); ///< Type of frame
@@ -121,6 +121,6 @@
 
         bool mdok;
-        psString mask = psMetadataLookupStr(&mdok, input, "MASK"); ///< Name of mask
-        psString weight = psMetadataLookupStr(&mdok, input, "WEIGHT"); ///< Name of weight map
+        psString mask = psMetadataLookupStr(&mdok, input, "MASK"); // Name of mask
+        psString variance = psMetadataLookupStr(&mdok, input, "VARIANCE"); // Name of variance map
 
         // Add the image file
@@ -164,25 +164,26 @@
         }
 
-        // Optionally add the weight file
-        if (weight && strlen(weight) > 0) {
-            haveWeights = true;
-            psArray *weightFiles = psArrayAlloc(1); ///< Array of filenames for this FPA
-            weightFiles->data[0] = psMemIncrRefCounter(weight);
-            psMetadataAddArray(config->arguments, PS_LIST_TAIL, "WEIGHT.FILENAMES", PS_META_REPLACE,
-                               "Filenames of weight files", weightFiles);
-            psFree(weightFiles);
+        // Optionally add the variance file
+        if (variance && strlen(variance) > 0) {
+            haveVariances = true;
+            psArray *varianceFiles = psArrayAlloc(1); // Array of filenames for this FPA
+            varianceFiles->data[0] = psMemIncrRefCounter(variance);
+            psMetadataAddArray(config->arguments, PS_LIST_TAIL, "VARIANCE.FILENAMES", PS_META_REPLACE,
+                               "Filenames of variance files", varianceFiles);
+            psFree(varianceFiles);
 
             bool status;
-            pmFPAfile *weightFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPMERGE.INPUT.WEIGHT",
-                                                          "WEIGHT.FILENAMES");
+            pmFPAfile *varianceFile = pmFPAfileBindFromArgs(&status, imageFile, config,
+                                                            "PPMERGE.INPUT.VARIANCE", "VARIANCE.FILENAMES");
             if (!status) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to define file from weight %d (%s)", numFiles, weight);
-                return false;
-            }
-            if (weightFile->type != PM_FPA_FILE_WEIGHT) {
-                psError(PS_ERR_IO, true, "PPMERGE.INPUT.WEIGHT is not of type WEIGHT");
-                return false;
-            }
-            haveWeights = true;
+                psError(PS_ERR_UNKNOWN, false, "Unable to define file from variance %d (%s)",
+                        numFiles, variance);
+                return false;
+            }
+            if (varianceFile->type != PM_FPA_FILE_VARIANCE) {
+                psError(PS_ERR_IO, true, "PPMERGE.INPUT.VARIANCE is not of type VARIANCE");
+                return false;
+            }
+            haveVariances = true;
         }
 
@@ -194,6 +195,6 @@
         psMetadataRemoveKey(config->arguments, "MASK.FILENAMES");
     }
-    if (psMetadataLookup(config->arguments, "WEIGHT.FILENAMES")) {
-        psMetadataRemoveKey(config->arguments, "WEIGHT.FILENAMES");
+    if (psMetadataLookup(config->arguments, "VARIANCE.FILENAMES")) {
+        psMetadataRemoveKey(config->arguments, "VARIANCE.FILENAMES");
     }
     if (psMetadataLookup(config->arguments, "PSF.FILENAMES")) {
@@ -203,6 +204,6 @@
     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INPUTS.NUM", 0, "Number of input files", numFiles);
     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "INPUTS.MASKS", 0, "Got input masks?", haveMasks);
-    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "INPUTS.WEIGHTS", 0,
-                      "Got input weights?", haveWeights);
+    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "INPUTS.VARIANCES", 0,
+                      "Got input variances?", haveVariances);
 
 
Index: /trunk/ppMerge/src/ppMergeFiles.c
===================================================================
--- /trunk/ppMerge/src/ppMergeFiles.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeFiles.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-01 21:43:05 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -13,9 +13,9 @@
 #include "ppMerge.h"
 
-const char *allFiles[] = { "PPMERGE.INPUT", "PPMERGE.INPUT.MASK", "PPMERGE.INPUT.WEIGHT",
+const char *allFiles[] = { "PPMERGE.INPUT", "PPMERGE.INPUT.MASK", "PPMERGE.INPUT.VARIANCE",
                            "PPMERGE.OUTPUT", "PPMERGE.OUTPUT.COUNT", "PPMERGE.OUTPUT.SIGMA",
-                           NULL };      ///< All files
-const char *inputFiles[] = { "PPMERGE.INPUT", "PPMERGE.INPUT.MASK", "PPMERGE.INPUT.WEIGHT",
-                             NULL };    ///< Input files
+                           NULL };      // All files
+const char *inputFiles[] = { "PPMERGE.INPUT", "PPMERGE.INPUT.MASK", "PPMERGE.INPUT.VARIANCE",
+                             NULL };    // Input files
 const char *outputFiles[] = { "PPMERGE.OUTPUT", "PPMERGE.OUTPUT.COUNT", "PPMERGE.OUTPUT.SIGMA",
                               NULL };   ///< Output files
@@ -51,8 +51,8 @@
         }
     }
-    if (psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS")) {
-        pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.WEIGHT", num);
-        if (!pmReadoutReadChunkWeight(readout, file->fits, 0, rows, 0, config)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to read readout weight.");
+    if (psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES")) {
+        pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.VARIANCE", num);
+        if (!pmReadoutReadChunkVariance(readout, file->fits, 0, rows, 0, config)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to read readout variance.");
             return false;
         }
@@ -91,9 +91,10 @@
         psFree(fileView);
     }
-    if (psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS")) {
-        pmFPAfile *weight = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.WEIGHT", num); // Weight file
-        pmFPAview *fileView = pmFPAviewForLevel(weight->fileLevel, view);
-        if (!pmFPAfileOpen(weight, fileView, config)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to open weight file %d", num);
+    if (psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES")) {
+        pmFPAfile *variance = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.VARIANCE",
+                                                    num); // Variance file
+        pmFPAview *fileView = pmFPAviewForLevel(variance->fileLevel, view);
+        if (!pmFPAfileOpen(variance, fileView, config)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to open variance file %d", num);
             psFree(fileView);
             return false;
@@ -127,5 +128,5 @@
     bool mdok;                          // Status of MD lookup
     bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
-    bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); // Got weights?
+    bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances?
 
     const char **fileList = selectFiles(files); // Files to activate
@@ -134,5 +135,5 @@
             continue;
         }
-        if (!haveWeights && strcmp(fileList[i], "PPMERGE.INPUT.WEIGHT") == 0) {
+        if (!haveVariances && strcmp(fileList[i], "PPMERGE.INPUT.VARIANCE") == 0) {
             continue;
         }
@@ -163,5 +164,5 @@
     bool mdok;                          // Status of MD lookup
     bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
-    bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); // Got weights?
+    bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances?
 
     psList *list = psListAlloc(NULL);   // List of files
@@ -171,5 +172,5 @@
             continue;
         }
-        if (!haveWeights && strcmp(fileList[i], "PPMERGE.INPUT.WEIGHT") == 0) {
+        if (!haveVariances && strcmp(fileList[i], "PPMERGE.INPUT.VARIANCE") == 0) {
             continue;
         }
Index: /trunk/ppMerge/src/ppMergeLoop_Threaded.c
===================================================================
--- /trunk/ppMerge/src/ppMergeLoop_Threaded.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeLoop_Threaded.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-01 21:43:05 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -36,13 +36,13 @@
     bool mdok;                          ///< Status of MD lookup
     bool haveMasks = psMetadataLookupBool(&mdok, arguments, "INPUTS.MASKS"); // Do we have masks?
-    bool haveWeights = psMetadataLookupBool(&mdok, arguments, "INPUTS.WEIGHTS"); ///< Do we have weights?
-
-    psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); ///< Input images
-    psArray *masks = NULL, *weights = NULL; ///< Input masks and weights
+    bool haveVariances = psMetadataLookupBool(&mdok, arguments, "INPUTS.VARIANCES"); // Do we have variances?
+
+    psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); // Input images
+    psArray *masks = NULL, *variances = NULL; // Input masks and variances
     if (haveMasks) {
         masks = ppMergeFileDataLevel(config, "PPMERGE.INPUT.MASK", PM_FPA_LEVEL_READOUT);
     }
-    if (haveWeights) {
-        weights = ppMergeFileDataLevel(config, "PPMERGE.INPUT.WEIGHT", PM_FPA_LEVEL_READOUT);
+    if (haveVariances) {
+        variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
     }
 
@@ -50,23 +50,22 @@
     if (!mdok) nThreads = 0;
 
-    /** General combination parameters */
-    int iter = psMetadataLookupS32(NULL, arguments, "ITER"); ///< Number of rejection iterations
-    float rej = psMetadataLookupF32(NULL, arguments, "REJ"); ///< Rejection level
-    float fraclow = psMetadataLookupF32(NULL, arguments, "FRACLOW"); ///< Reject fraction of low pixels
-    float frachigh = psMetadataLookupF32(NULL, arguments, "FRACHIGH"); ///< Reject fraction of hi pixels
-    int nKeep = psMetadataLookupS32(NULL, arguments, "NKEEP"); ///< Minimum number of values to keep
-    psStatsOptions combineStat = psMetadataLookupS32(NULL, arguments, "COMBINE"); ///< Combination statistic
-    bool useWeights = psMetadataLookupBool(NULL, arguments, "WEIGHTS"); ///< Use weights?
-
-    /** Fringe parameters */
-    int fringeNum = psMetadataLookupS32(NULL, arguments, "FRINGE.NUM"); ///< Number of fringe points
-    int fringeSize = psMetadataLookupS32(NULL, arguments, "FRINGE.SIZE"); ///< Size of fringe regions
-    int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); ///< Smoothing regions in x
-    int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); ///< Smoothing regions in y
+    // General combination parameters
+    int iter = psMetadataLookupS32(NULL, arguments, "ITER"); // Number of rejection iterations
+    float rej = psMetadataLookupF32(NULL, arguments, "REJ"); // Rejection level
+    float fraclow = psMetadataLookupF32(NULL, arguments, "FRACLOW"); // Reject fraction of low pixels
+    float frachigh = psMetadataLookupF32(NULL, arguments, "FRACHIGH"); // Reject fraction of hi pixels
+    int nKeep = psMetadataLookupS32(NULL, arguments, "NKEEP"); // Minimum number of values to keep
+    psStatsOptions combineStat = psMetadataLookupS32(NULL, arguments, "COMBINE"); // Combination statistic
+    bool useVariances = psMetadataLookupBool(NULL, arguments, "VARIANCES"); // Use variances?
+
+    // Fringe parameters
+    int fringeNum = psMetadataLookupS32(NULL, arguments, "FRINGE.NUM"); // Number of fringe points
+    int fringeSize = psMetadataLookupS32(NULL, arguments, "FRINGE.SIZE"); // Size of fringe regions
+    int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); // Smoothing regions in x
+    int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y
 
     // set the mask and mark bit values based on the named masks
-    psImageMaskType maskVal;
-    psImageMaskType markVal;
-    if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) {
+    psImageMaskType maskVal, markVal;
+    if (!pmConfigMaskSetBits(&maskVal, &markVal, config)) {
         psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
         return false;
@@ -81,5 +80,5 @@
     combination->iter = iter;
     combination->rej = rej;
-    combination->weights = useWeights;
+    combination->variances = useVariances;
 
     psMetadata *stats = NULL;           ///< Statistics for output
@@ -344,11 +343,11 @@
                 psFree(countsRO);
 
-		// XXX EAM 2009.01.18 : sigmaCell and countsCell need to have their concepts copied from outCell.
-		// This was causing segfaults for VYSOS5; Why did this ever work for SIMTEST?
-		if (!pmConceptsCopyCell(countsCell, outCell)) {
-		    psError(PS_ERR_UNKNOWN, false, "Unable to copy cell concepts.");
-		    psFree(outRO);
-		    goto ERROR;
-		}
+                // XXX EAM 2009.01.18 : sigmaCell and countsCell need to have their concepts copied from outCell.
+                // This was causing segfaults for VYSOS5; Why did this ever work for SIMTEST?
+                if (!pmConceptsCopyCell(countsCell, outCell)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to copy cell concepts.");
+                    psFree(outRO);
+                    goto ERROR;
+                }
 
                 pmCell *sigmaCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.SIGMA");
@@ -360,9 +359,9 @@
                 psFree(sigmaRO);
 
-		if (!pmConceptsCopyCell(sigmaCell, outCell)) {
-		    psError(PS_ERR_UNKNOWN, false, "Unable to copy cell concepts.");
-		    psFree(outRO);
-		    goto ERROR;
-		}
+                if (!pmConceptsCopyCell(sigmaCell, outCell)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to copy cell concepts.");
+                    psFree(outRO);
+                    goto ERROR;
+                }
             }
 
@@ -447,5 +446,5 @@
     psFree(inputs);
     psFree(masks);
-    psFree(weights);
+    psFree(variances);
     psFree(stats);
     return true;
@@ -456,5 +455,5 @@
     psFree(inputs);
     psFree(masks);
-    psFree(weights);
+    psFree(variances);
     psFree(stats);
     return false;
Index: /trunk/ppMerge/src/ppMergeMask.c
===================================================================
--- /trunk/ppMerge/src/ppMergeMask.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeMask.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-01 21:43:05 $
+ *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -38,9 +38,8 @@
     float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); ///< Radius to grow mask
 
-    psImageMaskType markVal;
-    psImageMaskType maskValRaw;
-    if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) {
-	psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
-	return false;
+    psImageMaskType markVal, maskValRaw;
+    if (!pmConfigMaskSetBits(&maskValRaw, &markVal, config)) {
+        psError(PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
+        return false;
     }
 
@@ -48,23 +47,23 @@
     psImageMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
     if (!maskValOut) {
-	psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
-	return false;
-    }
-    
-    psStats *statistics = psStatsAlloc(meanStat | stdevStat); ///< Statistics for background
+        psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
+        return false;
+    }
+
+    psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background
 
     psString outName = ppMergeOutputFile(config); ///< Name of output file
     pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); ///< Output chip
     psFree(outName);
-    
+
     int numCells = 1;
     if (chipStats) {
-	// count the number of active cells for this chip:
-	numCells = 0;
-	for (int i = 0; i < outChip->cells->n; i++) {
-	    pmCell *cell = outChip->cells->data[i];
-	    if (!cell->process) continue;
-	    numCells ++;
-	}
+        // count the number of active cells for this chip:
+        numCells = 0;
+        for (int i = 0; i < outChip->cells->n; i++) {
+            pmCell *cell = outChip->cells->data[i];
+            if (!cell->process) continue;
+            numCells ++;
+        }
     }
 
@@ -85,7 +84,7 @@
         while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
 
-	    // the output FPA structure carries the information about which cells to process
-            pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell
-	    if (!outCell->process) continue;
+            // the output FPA structure carries the information about which cells to process
+            pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
+            if (!outCell->process) continue;
 
             pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell
@@ -150,6 +149,6 @@
                 int y = pixel / numCols;
                 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue;
-		if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
-		if (!isfinite(image->data.F32[y][x])) continue;
+                if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
+                if (!isfinite(image->data.F32[y][x])) continue;
 
                 values->data.F32[valueIndex++] = image->data.F32[y][x];
@@ -165,9 +164,9 @@
                 }
 
-		float mean = psStatsGetValue(statistics, meanStat);
-		float stdev = psStatsGetValue(statistics, stdevStat);
-
-		// this function increments the count for each suspect pixel in each input plane
-		// maskValRaw is used to test for valid input pixels
+                float mean = psStatsGetValue(statistics, meanStat);
+                float stdev = psStatsGetValue(statistics, stdevStat);
+
+                // this function increments the count for each suspect pixel in each input plane
+                // maskValRaw is used to test for valid input pixels
                 if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
                     psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
@@ -197,8 +196,7 @@
             inView->cell = -1;
             while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
-
-		// the output FPA structure carries the information about which cells to process
-		pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell
-		if (!outCell->process) continue;
+                // the output FPA structure carries the information about which cells to process
+                pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
+                if (!outCell->process) continue;
 
                 pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell
@@ -210,8 +208,8 @@
                 pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK");
 
-		float mean = psStatsGetValue(statistics, meanStat);
-		float stdev = psStatsGetValue(statistics, stdevStat);
-
-		if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
+                float mean = psStatsGetValue(statistics, meanStat);
+                float stdev = psStatsGetValue(statistics, stdevStat);
+
+                if (!pmMaskFlagSuspectPixels(outRO, readout, mean, stdev, maskSuspect, maskValRaw)) {
                     psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
                     goto MERGE_MASK_ERROR;
@@ -243,6 +241,6 @@
     while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) {
 
-	// skip inactive cells
-	if (!outCell->process) continue;
+        // skip inactive cells
+        if (!outCell->process) continue;
 
         pmHDU *hdu = pmHDUFromCell(outCell); ///< HDU for cell
@@ -254,12 +252,12 @@
         pmReadout *outRO = outCell->readouts->data[0]; ///< Output readout
 
-	if (smoothSuspect) {
-	    // XXX test output of suspect pixel image
-	    psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); ///< Suspect img
-	    assert (suspects);
-	    psImageSmooth (suspects, smoothScale, 3); ///< extend smoothing region to 3-sigma
-	}
-
-	// set the bad pixels to the value 'maskVal'
+        if (smoothSuspect) {
+            // XXX test output of suspect pixel image
+            psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img
+            assert (suspects);
+            psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma
+        }
+
+        // set the bad pixels to the value 'maskVal'
         if (!pmMaskIdentifyBadPixels(outRO, maskValOut, maskBad, maskMode)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels");
@@ -352,9 +350,9 @@
     assert(config);
 
-    bool mdok;                          ///< Status of MD lookup
-    int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); ///< Number of inputs
-    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); ///< Do we have masks?
-    bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); ///< Do we have weights?
-    int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); ///< Number of rejection iterations
+    bool mdok;                          // Status of MD lookup
+    int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
+    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
+    bool haveVariances = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.VARIANCES"); // Got variances?
+    int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // Number of rejection iterations
 
     PS_ASSERT_INT_POSITIVE(iter, false);
@@ -375,7 +373,7 @@
         psFree(masks);
     }
-    if (haveWeights) {
-        psArray *weights = ppMergeFileDataLevel(config, "PPMERGE.INPUT.WEIGHT", PM_FPA_LEVEL_READOUT);
-        psFree(weights);
+    if (haveVariances) {
+        psArray *variances = ppMergeFileDataLevel(config, "PPMERGE.INPUT.VARIANCE", PM_FPA_LEVEL_READOUT);
+        psFree(variances);
     }
 
@@ -417,21 +415,21 @@
         }
 
-	if (outChip->data_exists) {
-	    psList *inChips = psListAlloc(NULL);
-	    for (int i=0; i < numFiles; i++) {
-		pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); ///< Input file
-		pmChip *chip = pmFPAviewThisChip(view, file->fpa);
-		psListAdd(inChips, PS_LIST_TAIL, chip);
-	    }
-
-	    // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!
-
-	    if (!pmConceptsAverageChips(outChip, inChips, true)) {
-		psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
-		psFree(inChips);
-		goto PPMERGE_MASK_ERROR;
-	    }
-	    psFree(inChips);
-	}
+        if (outChip->data_exists) {
+            psList *inChips = psListAlloc(NULL);
+            for (int i=0; i < numFiles; i++) {
+                pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
+                pmChip *chip = pmFPAviewThisChip(view, file->fpa);
+                psListAdd(inChips, PS_LIST_TAIL, chip);
+            }
+
+            // XXX I need to call pmConfigMaskWriteHeader for the PHU somewhere, after it is created!
+
+            if (!pmConceptsAverageChips(outChip, inChips, true)) {
+                psError(PS_ERR_UNKNOWN, false, "Unable to average Chip concepts.");
+                psFree(inChips);
+                goto PPMERGE_MASK_ERROR;
+            }
+            psFree(inChips);
+        }
         if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
             goto PPMERGE_MASK_ERROR;
Index: /trunk/ppMerge/src/ppMergeReadChunk.c
===================================================================
--- /trunk/ppMerge/src/ppMergeReadChunk.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeReadChunk.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-01 21:43:05 $
+ *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -20,7 +20,8 @@
 
     bool mdok;
-    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); ///< Do we have masks?
-    bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS");///< Do we have weights?
-    int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); ///< Number of rows to read per chunk
+    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
+    bool haveVariances = psMetadataLookupBool(&mdok, config->arguments,
+                                              "INPUTS.VARIANCES");// Do we have variances?
+    int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk
 
     // select an available fileGroup
@@ -52,5 +53,5 @@
                 // override the recorded last scan
                 inRO->thisImageScan  = fileGroup->firstScan;
-                inRO->thisWeightScan = fileGroup->firstScan;
+                inRO->thisVarianceScan = fileGroup->firstScan;
                 inRO->thisMaskScan   = fileGroup->firstScan;
                 inRO->forceScan      = true;
@@ -81,9 +82,10 @@
                 }
 
-                if (haveWeights && pmReadoutMoreWeight(inRO, file->fits, 0, rows, config)) {
+                if (haveVariances && pmReadoutMoreVariance(inRO, file->fits, 0, rows, config)) {
                     keepReading = true;
-                    pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.WEIGHT", i);
-                    if (!pmReadoutReadChunkWeight(inRO, file->fits, 0, rows, 0, config)) {
-                        psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPMERGE.INPUT.WEIGHT %d",
+                    pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT.VARIANCE", i);
+                    if (!pmReadoutReadChunkVariance(inRO, file->fits, 0, rows, 0, config)) {
+                        psError(PS_ERR_IO, false,
+                                "Unable to read chunk %d for file PPMERGE.INPUT.VARIANCE %d",
                                 numChunk, i);
                         *status = false;
Index: /trunk/ppMerge/src/ppMergeScaleZero.c
===================================================================
--- /trunk/ppMerge/src/ppMergeScaleZero.c	(revision 21364)
+++ /trunk/ppMerge/src/ppMergeScaleZero.c	(revision 21365)
@@ -6,6 +6,6 @@
  *
  *  @author IfA
- *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-02 20:26:26 $
+ *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-06 02:44:31 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -56,9 +56,9 @@
     for (int i = 0; i < numInputs; i++) {
         pmFPAfileActivate(config->files, false, NULL);
-        psArray *files = ppMergeFileActivateSingle(config, PPMERGE_FILES_INPUT, true, i); ///< Activated files
-        pmFPAfile *input = files->data[0]; ///< Representative file; should be the image (not mask or weight)
-        pmFPA *fpa = input->fpa;        ///< FPA of interest
-        view = pmFPAviewAlloc(0);       ///< View to component of interest
-        int cellNum = 0;                ///< Index for cell
+        psArray *files = ppMergeFileActivateSingle(config, PPMERGE_FILES_INPUT, true, i); // Activated files
+        pmFPAfile *input = files->data[0]; // Representative file; should be the image (not mask or variance)
+        pmFPA *fpa = input->fpa;        // FPA of interest
+        view = pmFPAviewAlloc(0);       // View to component of interest
+        int cellNum = 0;                // Index for cell
         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
             goto ERROR;
Index: /trunk/ppSim/src/ppSimInsertStars.c
===================================================================
--- /trunk/ppSim/src/ppSimInsertStars.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimInsertStars.c	(revision 21365)
@@ -39,7 +39,7 @@
     float skyRate = psMetadataLookupF32(NULL, recipe, "SKY.RATE"); // Sky rate
     if (isnan(skyRate)) {
-	float zp      = psMetadataLookupF32(&mdok, recipe, "ZEROPOINT"); assert (mdok);
-	float scale   = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE");     assert (mdok);
-	float skyMags = psMetadataLookupF32(&mdok, recipe, "SKY.MAGS");  assert (mdok);
+        float zp      = psMetadataLookupF32(&mdok, recipe, "ZEROPOINT"); assert (mdok);
+        float scale   = psMetadataLookupF32(&mdok, recipe, "PIXEL.SCALE");     assert (mdok);
+        float skyMags = psMetadataLookupF32(&mdok, recipe, "SKY.MAGS");  assert (mdok);
         skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
     }
@@ -75,5 +75,5 @@
     FILE *outfile = fopen (outname, "w");
 
-    // add sources to the readout image & weight
+    // add sources to the readout image & variance
     psTrace("ppSim", 1, "Inserting %ld stars...\n", stars->n);
     for (long i = 0; i < stars->n; i++) {
@@ -118,5 +118,5 @@
         psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
 
-	// this value is the pure (input) flux, and is saved in the output source cmf files
+        // this value is the pure (input) flux, and is saved in the output source cmf files
         source->psfMag = -2.5*log10(star->flux);
         source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux;
@@ -132,5 +132,5 @@
         // Blow away the image parts of the source, which makes the memory explode
         RESET(source->pixels);
-        RESET(source->weight);
+        RESET(source->variance);
         RESET(source->maskObj);
         RESET(source->maskView);
Index: /trunk/ppSim/src/ppSimLoadForceSources.c
===================================================================
--- /trunk/ppSim/src/ppSimLoadForceSources.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimLoadForceSources.c	(revision 21365)
@@ -56,17 +56,17 @@
     // Select the spots within range of this readout.  Project the spots to this chip
     for (int i = 0; i < spots->n; i++) {
-	pmAstromObj *obj = spots->data[i];
+        pmAstromObj *obj = spots->data[i];
 
-	psProject (obj->TP, obj->sky, fpa->toSky);
-	psPlaneTransformApply (obj->FP, fpa->fromTPA, obj->TP);
-	psPlaneTransformApply (obj->chip, chip->fromFPA, obj->FP);
+        psProject (obj->TP, obj->sky, fpa->toSky);
+        psPlaneTransformApply (obj->FP, fpa->fromTPA, obj->TP);
+        psPlaneTransformApply (obj->chip, chip->fromFPA, obj->FP);
 
-	// limit the X,Y range of the objs to the selected chip
-	if (obj->chip->x < minX) continue;
-	if (obj->chip->x > maxX) continue;
-	if (obj->chip->y < minY) continue;
-	if (obj->chip->y > maxY) continue;
+        // limit the X,Y range of the objs to the selected chip
+        if (obj->chip->x < minX) continue;
+        if (obj->chip->x > maxX) continue;
+        if (obj->chip->y < minY) continue;
+        if (obj->chip->y > maxY) continue;
 
-	// convert the pmAstromObj to pmSource
+        // convert the pmAstromObj to pmSource
 
         // instantiate a model for the PSF at this location, Io = 1.0
@@ -74,8 +74,8 @@
 
         // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0)
-	// XXX use a fixed radius??
+        // XXX use a fixed radius??
         // float radius = model->modelRadius (model->params, roughNoise);
         // radius = PS_MAX (radius, 1.0);
-	float radius = 5.0;
+        float radius = 5.0;
 
         // construct a source, with model flux pixels set, based on the model
@@ -87,10 +87,10 @@
         // psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
 
-	// these are not really needed since we will be fitting for them
+        // these are not really needed since we will be fitting for them
         source->psfMag = NAN;
         source->errMag = NAN;
 
         // insert the source flux in the image
-	// XXX not sure the offset is really 0,0
+        // XXX not sure the offset is really 0,0
         pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, 0.0, 0.0);
         pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, 0.0, 0.0);
@@ -98,5 +98,5 @@
         // Blow away the image parts of the source, which makes the memory explode
         RESET(source->pixels);
-        RESET(source->weight);
+        RESET(source->variance);
         RESET(source->maskObj);
         RESET(source->maskView);
@@ -105,5 +105,5 @@
         RESET(source->blends);
 
-	psArrayAdd (sources, 100, source);
+        psArrayAdd (sources, 100, source);
         psFree(source);                 // Drop local reference
     }
Index: /trunk/ppSim/src/ppSimLoop.c
===================================================================
--- /trunk/ppSim/src/ppSimLoop.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimLoop.c	(revision 21365)
@@ -34,14 +34,14 @@
     psArray *galaxies = psArrayAllocEmpty (1);
     if (type == PPSIM_TYPE_OBJECT) {
-	// Load forced-photometry positions (these are placed on fpa->analysis for use in ppSimPhotomReadout)
-	if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");
-
-	// Load catalogue stars
+        // Load forced-photometry positions (these are placed on fpa->analysis for use in ppSimPhotomReadout)
+        if (!ppSimLoadSpots (fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load forced-photometry spots");
+
+        // Load catalogue stars
         if (!ppSimLoadStars (stars, fpa, config)) ESCAPE (PS_ERR_UNKNOWN, "failed to load catalog stars");
 
-	// Add random stars
+        // Add random stars
         if (!ppSimMakeStars (stars, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random stars");
 
-	// Add random galaxies
+        // Add random galaxies
         if (!ppSimMakeGalaxies (galaxies, fpa, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "failed to make random galaxies");
     }
@@ -105,8 +105,8 @@
                 // TO DO: Decide if cell is to be windowed, reduce numCols, numRows appropriately
                 readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Signal in pixels
-                readout->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels
+                readout->variance = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Noise in pixels
 
                 psImageInit (readout->image, 0.0);
-                psImageInit (readout->weight, 0.0);
+                psImageInit (readout->variance, 0.0);
 
                 psFree(readout);        // Drop reference
@@ -115,12 +115,12 @@
             psVector *biasCols = ppSimMakeBiassec (cell, config);
 
-	    pmReadout *readout;
-	    while ((readout = pmFPAviewNextReadout (view, fpa, 1))) {
-
-                // if we have not read in a weight or generated a fake image above, we need to
+            pmReadout *readout;
+            while ((readout = pmFPAviewNextReadout (view, fpa, 1))) {
+
+                // if we have not read in a variance or generated a fake image above, we need to
                 // build one here
-                if (!readout->weight) {
-                    if (!pmReadoutGenerateWeight(readout, true)) {
-                        psError (PS_ERR_UNKNOWN, false, "trouble creating weight");
+                if (!readout->variance) {
+                    if (!pmReadoutGenerateVariance(readout, true)) {
+                        psError (PS_ERR_UNKNOWN, false, "trouble creating variance");
                         return false;
                     }
@@ -133,8 +133,8 @@
 
                 psVector *biasRows = ppSimMakeBias (&status, readout, config, rng);
-		if (!status) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure");
+                if (!status) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure");
                 if (type == PPSIM_TYPE_BIAS) goto done;
 
-		if (!ppSimMakeDark (readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure");
+                if (!ppSimMakeDark (readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem generating dark structure");
                 if (type == PPSIM_TYPE_DARK) goto done;
 
@@ -153,5 +153,5 @@
 
             done:
-                if (!ppSimAddNoise(readout->image, readout->weight, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise");
+                if (!ppSimAddNoise(readout->image, readout->variance, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise");
                 if (!ppSimSaturate(readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem setting saturation levels");
 
@@ -165,6 +165,6 @@
                 readout->parent->parent->data_exists = true;
 
-		// if there is an input image, merge it with the simulated image
-		if (!ppSimMergeReadouts (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem merging input image with simulated image");
+                // if there is an input image, merge it with the simulated image
+                if (!ppSimMergeReadouts (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem merging input image with simulated image");
             }
             psFree(biasCols);
@@ -173,5 +173,5 @@
 
             if (cell->hdu) {
-		// XXX only do this if there is no INPUT image?
+                // XXX only do this if there is no INPUT image?
                 if (!ppSimInitHeader(config, NULL, NULL, cell)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
             }
@@ -186,13 +186,13 @@
         }
 
-	// XXX why no UpdateConceptsChip??
+        // XXX why no UpdateConceptsChip??
 
         if (chip->hdu) {
-	    // XXX only do this if there is no INPUT image
+            // XXX only do this if there is no INPUT image
             if (!ppSimInitHeader(config, NULL, chip, NULL)) ESCAPE (PS_ERR_UNKNOWN, "problem setting output header");
         }
 
         // we perform photometry on the readouts of this chip in the output
-	if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
+        if (!ppSimPhotom (config, view)) ESCAPE (PS_ERR_UNKNOWN, "problem performing photometry");
 
         if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
Index: /trunk/ppSim/src/ppSimMakeBias.c
===================================================================
--- /trunk/ppSim/src/ppSimMakeBias.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimMakeBias.c	(revision 21365)
@@ -20,15 +20,15 @@
     float readnoise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE");// CCD read noise, e
     if (isnan(readnoise)) {
-	psWarning("CELL.READNOISE is not set; reverting to recipe value READNOISE.");
-	readnoise = psMetadataLookupF32(&mdok, recipe, "READNOISE");
-	if (!mdok) {
-	    psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find READNOISE in recipe.");
-	    *status = false;
-	    return NULL;
-	}
+        psWarning("CELL.READNOISE is not set; reverting to recipe value READNOISE.");
+        readnoise = psMetadataLookupF32(&mdok, recipe, "READNOISE");
+        if (!mdok) {
+            psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find READNOISE in recipe.");
+            *status = false;
+            return NULL;
+        }
     }
 
     psImage *signal = readout->image;
-    psImage *variance = readout->weight;
+    psImage *variance = readout->variance;
 
     int numRows = signal->numRows;
@@ -38,5 +38,5 @@
     psPolynomial1D *biasPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_CHEB, biasOrder);
     for (int j = 0; j < biasOrder + 1; j++) {
-	biasPoly->coeff[j] = biasRange * psRandomGaussian(rng);
+        biasPoly->coeff[j] = biasRange * psRandomGaussian(rng);
     }
 
@@ -45,15 +45,15 @@
 
     for (int y = 0; y < numRows; y++) {
-	// Adjust bias level for this row
-	biasRows->data.F32[y] = psPolynomial1DEval(biasPoly, (float)(y + biasOffset) /
-						  (float)numRows - 0.5) + biasLevel;
+        // Adjust bias level for this row
+        biasRows->data.F32[y] = psPolynomial1DEval(biasPoly, (float)(y + biasOffset) /
+                                                  (float)numRows - 0.5) + biasLevel;
 
-	for (int x = 0; x < numCols; x++) {
+        for (int x = 0; x < numCols; x++) {
 
-	    // Bias level
-	    signal->data.F32[y][x] += biasRows->data.F32[y];
-	    variance->data.F32[y][x] += PS_SQR(readnoise);
+            // Bias level
+            signal->data.F32[y][x] += biasRows->data.F32[y];
+            variance->data.F32[y][x] += PS_SQR(readnoise);
 
-	}
+        }
     }
     psFree(biasPoly);
Index: /trunk/ppSim/src/ppSimMakeDark.c
===================================================================
--- /trunk/ppSim/src/ppSimMakeDark.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimMakeDark.c	(revision 21365)
@@ -7,5 +7,5 @@
 
     psImage *signal = readout->image;
-    psImage *variance = readout->weight;
+    psImage *variance = readout->variance;
 
     psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe
@@ -29,11 +29,11 @@
 
     for (int y = 0; y < signal->numRows; y++) {
-	for (int x = 0; x < signal->numCols; x++) {
-			
-	    // Dark current
-	    float darkCurrent = darkRate * expTime; // Dark current accumulated
-	    signal->data.F32[y][x] += darkCurrent;
-	    variance->data.F32[y][x] += darkCurrent;
-	}
+        for (int x = 0; x < signal->numCols; x++) {
+
+            // Dark current
+            float darkCurrent = darkRate * expTime; // Dark current accumulated
+            signal->data.F32[y][x] += darkCurrent;
+            variance->data.F32[y][x] += darkCurrent;
+        }
     }
     return true;
Index: /trunk/ppSim/src/ppSimMakeSky.c
===================================================================
--- /trunk/ppSim/src/ppSimMakeSky.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimMakeSky.c	(revision 21365)
@@ -9,5 +9,5 @@
 
     psImage *signal = readout->image;
-    psImage *variance = readout->weight;
+    psImage *variance = readout->variance;
 
     pmCell *cell = readout->parent;
@@ -19,5 +19,5 @@
     bool sky  = psMetadataLookupBool(&status, recipe, "SKY"); // Generate a SKY flux?
     bool flat = psMetadataLookupBool(&status, recipe, "FLAT"); // Apply flat-field term?
- 
+
     float expTime      = psMetadataLookupF32(&status, recipe, "EXPTIME"); // Exposure time
 
@@ -29,7 +29,7 @@
     float skyMags      = psMetadataLookupF32(&status, recipe, "SKY.MAGS");  assert (status);
     if (!isnan(skyMags)) {
-	float zp       = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status);
-	float scale    = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status);
-	skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
+        float zp       = psMetadataLookupF32(&status, recipe, "ZEROPOINT"); assert (status);
+        float scale    = psMetadataLookupF32(&status, recipe, "PIXEL.SCALE"); assert (status);
+        skyRate = scale * scale * ppSimMagToFlux (skyMags, zp);
     }
     if (type == PPSIM_TYPE_FLAT) {
@@ -37,11 +37,11 @@
     }
 
-    int x0Chip 	      = psMetadataLookupS32(&status, chip->concepts, "CHIP.X0");
-    int y0Chip 	      = psMetadataLookupS32(&status, chip->concepts, "CHIP.Y0");
+    int x0Chip        = psMetadataLookupS32(&status, chip->concepts, "CHIP.X0");
+    int y0Chip        = psMetadataLookupS32(&status, chip->concepts, "CHIP.Y0");
     int xParityChip   = psMetadataLookupS32(&status, chip->concepts, "CHIP.XPARITY");
     int yParityChip   = psMetadataLookupS32(&status, chip->concepts, "CHIP.YPARITY");
 
-    int x0Cell 	      = psMetadataLookupS32(&status, cell->concepts, "CELL.X0");
-    int y0Cell 	      = psMetadataLookupS32(&status, cell->concepts, "CELL.Y0");
+    int x0Cell        = psMetadataLookupS32(&status, cell->concepts, "CELL.X0");
+    int y0Cell        = psMetadataLookupS32(&status, cell->concepts, "CELL.Y0");
     int xParityCell   = psMetadataLookupS32(&status, cell->concepts, "CELL.XPARITY");
     int yParityCell   = psMetadataLookupS32(&status, cell->concepts, "CELL.YPARITY");
@@ -72,28 +72,28 @@
             // Gaussian flat-field over the FPA with flatValue = 1.0 at the field center
             float flatValue = 1.0;
-	    if (flat) {
-		// we make the flat-field have a response of 1.0 at the field center (like a vignetting)
-		flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA)));
-	    }
+            if (flat) {
+                // we make the flat-field have a response of 1.0 at the field center (like a vignetting)
+                flatValue = expf(-0.5 / PS_SQR(flatSigma) * (PS_SQR(yFPA) + PS_SQR(xFPA)));
+            }
 
-	    float scatterRate = 0.0;
+            float scatterRate = 0.0;
 
-	    if (sky) {
-	      // add a scattered light term to the flat-field images
-	      if (type == PPSIM_TYPE_FLAT) {
-		  scatterRate = scatterFrac * PS_SQR(xFPA);
-	      }
+            if (sky) {
+              // add a scattered light term to the flat-field images
+              if (type == PPSIM_TYPE_FLAT) {
+                  scatterRate = scatterFrac * PS_SQR(xFPA);
+              }
 
-	      // Sky background
-	      float skyFlux = (skyRate * (flatValue + scatterRate)) * realExpTime; // Flux from sky
-	      signal->data.F32[y][x] += skyFlux;
-	      variance->data.F32[y][x] += skyFlux;
-	    }
+              // Sky background
+              float skyFlux = (skyRate * (flatValue + scatterRate)) * realExpTime; // Flux from sky
+              signal->data.F32[y][x] += skyFlux;
+              variance->data.F32[y][x] += skyFlux;
+            }
 
-	    // used later to modify the star and galaxy photometry 
-	    if (expCorr) {
-		// exposure correction is (effective exposure time) * (flatValue)
-	      expCorr->data.F32[y][x] = flatValue * realExpTime / expTime;
-	    }
+            // used later to modify the star and galaxy photometry
+            if (expCorr) {
+                // exposure correction is (effective exposure time) * (flatValue)
+              expCorr->data.F32[y][x] = flatValue * realExpTime / expTime;
+            }
 
             // TO DO: Add fringes
Index: /trunk/ppSim/src/ppSimMergeReadouts.c
===================================================================
--- /trunk/ppSim/src/ppSimMergeReadouts.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimMergeReadouts.c	(revision 21365)
@@ -14,8 +14,8 @@
     if (!inReadout) return true;
 
-    if (!inReadout->weight) {
-      if (!pmReadoutGenerateWeight(inReadout, true)) {
-	psError (PS_ERR_UNKNOWN, false, "trouble creating weight");
-	return false;
+    if (!inReadout->variance) {
+      if (!pmReadoutGenerateVariance(inReadout, true)) {
+        psError (PS_ERR_UNKNOWN, false, "trouble creating variance");
+        return false;
       }
     }
@@ -30,8 +30,8 @@
 
     psImage *inSignal = inReadout->image;
-    psImage *inVariance = inReadout->weight;
+    psImage *inVariance = inReadout->variance;
 
     psImage *outSignal = outReadout->image;
-    psImage *outVariance = outReadout->weight;
+    psImage *outVariance = outReadout->variance;
 
     assert (inSignal->numRows == outSignal->numRows);
@@ -39,8 +39,8 @@
 
     for (int y = 0; y < inSignal->numRows; y++) {
-	for (int x = 0; x < inSignal->numCols; x++) {
-	    outSignal->data.F32[y][x] += inSignal->data.F32[y][x];
-	    outVariance->data.F32[y][x] += inVariance->data.F32[y][x];
-	}
+        for (int x = 0; x < inSignal->numCols; x++) {
+            outSignal->data.F32[y][x] += inSignal->data.F32[y][x];
+            outVariance->data.F32[y][x] += inVariance->data.F32[y][x];
+        }
     }
     return true;
Index: /trunk/ppSim/src/ppSimPhotomReadoutFake.c
===================================================================
--- /trunk/ppSim/src/ppSimPhotomReadoutFake.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimPhotomReadoutFake.c	(revision 21365)
@@ -12,5 +12,5 @@
     }
 
-# if 0    
+# if 0
     // set the photcode for this image
     if (!psphotAddPhotcode (recipe, config, view, "PPSIM.FAKE.CHIP")) {
@@ -22,5 +22,5 @@
     // *** in this section, perform the photometry for real + fake sources on PPSIM.FAKE.CHIP ***
 
-    // find the currently selected readout. 
+    // find the currently selected readout.
     // we always perform photometry on the mosaiced chip
     pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.CHIP");
@@ -35,6 +35,6 @@
     PS_ASSERT_PTR_NON_NULL (injectedSources, false);
 
-    // Generate the mask and weight images, including the user-defined analysis region of interest
-    psphotSetMaskAndWeight (config, readout, recipe);
+    // Generate the mask and variance images, including the user-defined analysis region of interest
+    psphotSetMaskAndVariance (config, readout, recipe);
 
     // XXX need to define the source pixels
@@ -53,13 +53,13 @@
     psArray *realSources = psArrayAlloc (realMeasuredSources->n);
     for (int i = 0; i < realMeasuredSources->n; i++) {
-	realSources->data[i] = pmSourceCopy (realMeasuredSources->data[i]);
+        realSources->data[i] = pmSourceCopy (realMeasuredSources->data[i]);
     }
 
     // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
-    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile 
+    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile
     pmPSF *psf = psphotLoadPSF (config, view, recipe);
     assert (psf);
 
-    // remove all sources 
+    // remove all sources
     psphotRemoveAllSources (realSources, recipe);
 
@@ -76,5 +76,5 @@
 
     // XXX fake sources should measure peak->x,y, force sources should not
-    psImageMaskType maskVal = 0xff; 
+    psImageMaskType maskVal = 0xff;
     psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
     ppSimDetections (significance, recipe, fakeSources);
@@ -90,5 +90,5 @@
     psphotGuessModels (config, readout, realSources, psf);
     psphotGuessModels (config, readout, fakeSources, psf);
-    
+
     // linear fit to real + fake sources
     psArray *sources = ppSimMergeSources (realSources, fakeSources);
@@ -113,6 +113,6 @@
     pmReadout *fakeReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FAKE.SOURCES");
     if (!fakeReadout) {
-	fakeReadout = pmReadoutAlloc (fakeCell);
-	psFree (fakeReadout); // there is a copy on 'cell' as well
+        fakeReadout = pmReadoutAlloc (fakeCell);
+        psFree (fakeReadout); // there is a copy on 'cell' as well
     }
     psAssert (fakeReadout, "no fakeReadout?");
Index: /trunk/ppSim/src/ppSimPhotomReadoutForce.c
===================================================================
--- /trunk/ppSim/src/ppSimPhotomReadoutForce.c	(revision 21364)
+++ /trunk/ppSim/src/ppSimPhotomReadoutForce.c	(revision 21365)
@@ -12,5 +12,5 @@
     }
 
-# if 0    
+# if 0
     // set the photcode for this image
     if (!psphotAddPhotcode (recipe, config, view, "PPSIM.FAKE.CHIP")) {
@@ -22,5 +22,5 @@
     // *** in this section, perform the photometry for real + force sources on PPSIM.FORCE.CHIP ***
 
-    // find the currently selected readout. 
+    // find the currently selected readout.
     // we always perform photometry on the mosaiced chip
     pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PPSIM.FORCE.CHIP");
@@ -35,6 +35,6 @@
     psAssert (forceSources, "failed to load force photometry sources");
 
-    // Generate the mask and weight images, including the user-defined analysis region of interest
-    psphotSetMaskAndWeight (config, readout, recipe);
+    // Generate the mask and variance images, including the user-defined analysis region of interest
+    psphotSetMaskAndVariance (config, readout, recipe);
 
     // XXX need to define the source pixels
@@ -46,13 +46,13 @@
     psArray *realSources = psArrayAlloc (realMeasuredSources->n);
     for (int i = 0; i < realMeasuredSources->n; i++) {
-	realSources->data[i] = pmSourceCopy (realMeasuredSources->data[i]);
+        realSources->data[i] = pmSourceCopy (realMeasuredSources->data[i]);
     }
 
     // load the psf model, if suppled.  FWHM_X,FWHM_Y,etc are saved in the recipe
-    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile 
+    // this function uses PSPHOT.PSF.LOAD as the pmFPAfile
     pmPSF *psf = psphotLoadPSF (config, view, recipe);
     assert (psf);
 
-    // remove all sources 
+    // remove all sources
     psphotRemoveAllSources (realSources, recipe);
 
@@ -69,5 +69,5 @@
 
     // XXX fake sources should measure peak->x,y, force sources should not
-    psImageMaskType maskVal = 0xff; 
+    psImageMaskType maskVal = 0xff;
     psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
     ppSimDetections (significance, recipe, forceSources);
@@ -83,5 +83,5 @@
     psphotGuessModels (config, readout, realSources, psf);
     psphotGuessModels (config, readout, forceSources, psf);
-    
+
     // linear fit to real + force sources
     psArray *sources = ppSimMergeSources (realSources, forceSources);
@@ -106,6 +106,6 @@
     pmReadout *forceReadout = pmFPAfileThisReadout (config->files, view, "PPSIM.FORCE.SOURCES");
     if (!forceReadout) {
-	forceReadout = pmReadoutAlloc (forceCell);
-	psFree (forceReadout); // there is a copy on 'cell' as well
+        forceReadout = pmReadoutAlloc (forceCell);
+        psFree (forceReadout); // there is a copy on 'cell' as well
     }
     psAssert (forceReadout, "no forceReadout?");
