Index: trunk/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendReadout.c	(revision 24079)
+++ trunk/ppImage/src/ppImageDetrendReadout.c	(revision 24485)
@@ -64,5 +64,27 @@
     if (options->doVarianceBuild) {
         // create the target mask and variance images
-        pmReadoutGenerateVariance(input, true);
+	psImage *noiseImage = NULL;
+	if (options->doNoiseMap) {
+	    // XXX convert the noiseMap image to a binned image
+	    pmReadout *noiseMap = NULL;
+	    noiseMap = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.NOISEMAP");
+	    noiseImage = psImageCopy (NULL, input->image, PS_TYPE_F32);
+	    psImageInit (noiseImage, 0.0);
+
+	    // XXX this works, but is not really quite right: the model shoud include the
+	    // offset information, we are not really getting exactly the right mapping from the
+	    // original file.
+	    psImageBinning *binning = psImageBinningAlloc();
+	    binning->nXruff = noiseMap->image->numCols;
+	    binning->nYruff = noiseMap->image->numRows;
+	    binning->nXfine = input->image->numCols;
+	    binning->nYfine = input->image->numRows;
+	    psImageBinningSetScale(binning, PS_IMAGE_BINNING_LEFT);
+
+	    psImageUnbin (noiseImage, noiseMap->image, binning);
+	    psFree (binning);
+	}
+        pmReadoutGenerateVariance(input, noiseImage, true);
+	psFree (noiseImage);
     }
 
