Index: trunk/psModules/src/camera/pmFPAMaskWeight.c
===================================================================
--- trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 24480)
+++ trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 24483)
@@ -199,7 +199,8 @@
 }
 
-bool pmReadoutSetVariance(pmReadout *readout, bool poisson)
+bool pmReadoutSetVariance(pmReadout *readout, const psImage *noiseMap, bool poisson)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
+    // check that the noiseMap (if it exists) matches the readout variance size)
 
     pmCell *cell = readout->parent;     // The parent cell
@@ -240,7 +241,12 @@
     }
 
-    // XXX if readnoise is based on an image map, we need to apply it here
-    readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+",
-                                           psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
+    // apply a supplied readnoise map (NOTE: in DN, not electrons):
+    if (noiseMap) {
+	psImage *rdVar = (psImage*)psBinaryOp(NULL, (const psPtr) noiseMap, "*", (const psPtr) noiseMap);
+	readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", rdVar);
+	psFree (rdVar);
+    } else {
+	readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
+    }
 
     return true;
@@ -249,5 +255,5 @@
 // this function creates the variance pixels, or uses the existing variance pixels.  it will set
 // the noise pixel values only if the variance image is not supplied
-bool pmReadoutGenerateVariance(pmReadout *readout, bool poisson)
+bool pmReadoutGenerateVariance(pmReadout *readout, const psImage *noiseMap, bool poisson)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -293,8 +299,8 @@
     readout->variance = variance;
 
-    return pmReadoutSetVariance(readout, poisson);
-}
-
-bool pmReadoutGenerateMaskVariance(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
+    return pmReadoutSetVariance(readout, noiseMap, poisson);
+}
+
+bool pmReadoutGenerateMaskVariance(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, const psImage *noiseMap, bool poisson)
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -303,10 +309,10 @@
 
     success &= pmReadoutGenerateMask(readout, satMask, badMask);
-    success &= pmReadoutGenerateVariance(readout, poisson);
+    success &= pmReadoutGenerateVariance(readout, noiseMap, poisson);
 
     return success;
 }
 
-bool pmCellGenerateMaskVariance(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
+bool pmCellGenerateMaskVariance(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, const psImage *noiseMap, bool poisson)
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -316,5 +322,5 @@
     for (int i = 0; i < readouts->n; i++) {
         pmReadout *readout = readouts->data[i]; // The readout
-        success &= pmReadoutGenerateMaskVariance(readout, poisson, satMask, badMask);
+        success &= pmReadoutGenerateMaskVariance(readout, satMask, badMask, noiseMap, poisson);
     }
 
Index: trunk/psModules/src/camera/pmFPAMaskWeight.h
===================================================================
--- trunk/psModules/src/camera/pmFPAMaskWeight.h	(revision 24480)
+++ trunk/psModules/src/camera/pmFPAMaskWeight.h	(revision 24483)
@@ -54,4 +54,5 @@
 /// can't be generated.
 bool pmReadoutSetVariance(pmReadout *readout, ///< Readout for which to set variance
+			  const psImage *noiseMap, ///< 2D image of the read noise in DN
                           bool poisson    ///< Include poisson variance (in addition to read noise)?
     );
@@ -72,4 +73,5 @@
 /// with HDU entry).  This is intended for most operations.
 bool pmReadoutGenerateVariance(pmReadout *readout, ///< Readout for which to generate variance
+			  const psImage *noiseMap, ///< 2D image of the read noise in DN
                                bool poisson    ///< Include poisson variance (in addition to read noise)?
     );
@@ -81,4 +83,5 @@
                                    psImageMaskType sat, ///< Mask value to give saturated pixels
                                    psImageMaskType bad, ///< Mask value to give bad (low) pixels
+				   const psImage *noiseMap, ///< 2D image of the read noise in DN
                                    bool poisson ///< Include poisson variance (in addition to read noise)?
     );
@@ -90,4 +93,5 @@
                                 psImageMaskType sat, ///< Mask value to give saturated pixels
                                 psImageMaskType bad, ///< Mask value to give bad (low) pixels
+				const psImage *noiseMap, ///< 2D image of the read noise in DN
                                 bool poisson ///< Include poisson variance (in addition to read noise)?
     );
