Index: /trunk/psModules/src/camera/pmFPAMaskWeight.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 7714)
+++ /trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 7715)
@@ -90,8 +90,9 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmReadoutSetMask(pmReadout *readout // Readout for which to set mask
+bool pmReadoutSetMask(pmReadout *readout// Readout for which to set mask
                      )
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
+    PS_ASSERT_IMAGE_NON_NULL(readout->image, false);
 
     pmCell *cell = readout->parent;     // The parent cell
@@ -111,41 +112,11 @@
     psTrace(__func__, 5, "Saturation: %f, bad: %f\n", saturation, bad);
 
-    // Create the mask image if required
-    if (!readout->mask) {
-        psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
-        if (!mdok || psRegionIsNaN(*trimsec)) {
-            psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set mask.\n");
-            return false;
-        }
-
-        pmHDU *hdu = pmHDUFromCell(cell);   // The HDU containing the cell's pixels
-        PS_ASSERT_PTR_NON_NULL(hdu, false);
-        if (!hdu->images && !pmHDUGenerateForCell(cell)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell.\n");
-            return false;
-        }
-
-        createParentMasks(hdu);
-
-        // Need to identify which readout we're working with....
-        long index = identifyReadout(hdu, readout); // Index of the readout
-        if (index == -1) {
-            psError(PS_ERR_UNKNOWN, true, "Unable to identify readout image in HDU.\n");
-            return false;
-        }
-
-        psImage *mask = psImageSubset(hdu->masks->data[index], *trimsec); // The mask pixels
-        if (!mask) {
-            psString trimsecString = psRegionToString(*trimsec);
-            psError(PS_ERR_UNKNOWN, false, "Unable to set mask from HDU with trimsec: %s.\n", trimsecString);
-            psFree(trimsecString);
-            return NULL;
-        }
-        psImageInit(mask, 0);
-        readout->mask = mask;
-    }
 
     // Set up the mask
     psImage *image = readout->image;    // The image pixels
+    if (!readout->mask) {
+        // Generate a (throwaway) mask image, if required
+        readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
+    }
     psImage *mask = readout->mask;      // The mask pixels
     for (long i = 0; i < image->numRows; i++) {
@@ -163,4 +134,50 @@
 }
 
+bool pmReadoutGenerateMask(pmReadout *readout // Readout for which to generate mask
+                          )
+{
+    PS_ASSERT_PTR_NON_NULL(readout, false);
+
+    pmCell *cell = readout->parent;     // The parent cell
+    bool mdok = true;                   // Status of MD lookup
+
+    // Create the mask image if required
+    if (!readout->mask) {
+        psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section
+        if (!mdok || psRegionIsNaN(*trimsec)) {
+            psError(PS_ERR_IO, true, "CELL.TRIMSEC is not set --- unable to set mask.\n");
+            return false;
+        }
+
+        pmHDU *hdu = pmHDUFromCell(cell);   // The HDU containing the cell's pixels
+        PS_ASSERT_PTR_NON_NULL(hdu, false);
+        if (!hdu->images && !pmHDUGenerateForCell(cell)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell.\n");
+            return false;
+        }
+
+        createParentMasks(hdu);
+
+        // Need to identify which readout we're working with....
+        long index = identifyReadout(hdu, readout); // Index of the readout
+        if (index == -1) {
+            psError(PS_ERR_UNKNOWN, true, "Unable to identify readout image in HDU.\n");
+            return false;
+        }
+
+        psImage *mask = psImageSubset(hdu->masks->data[index], *trimsec); // The mask pixels
+        if (!mask) {
+            psString trimsecString = psRegionToString(*trimsec);
+            psError(PS_ERR_UNKNOWN, false, "Unable to set mask from HDU with trimsec: %s.\n", trimsecString);
+            psFree(trimsecString);
+            return false;
+        }
+        psImageInit(mask, 0);
+        readout->mask = mask;
+    }
+
+    return pmReadoutSetMask(readout);
+}
+
 bool pmReadoutSetWeight(pmReadout *readout // Readout for which to set weight
                        )
@@ -182,4 +199,21 @@
         return false;
     }
+
+    // Set weight image to the variance in ADU = f/g + rn^2
+    psImage *image = readout->image;    // The image pixels
+    readout->weight = (psImage*)psBinaryOp(readout->weight, image, "/", psScalarAlloc(gain, PS_TYPE_F32));
+    readout->weight = (psImage*)psBinaryOp(readout->weight, readout->weight, "+",
+                                           psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
+
+    return true;
+}
+
+bool pmReadoutGenerateWeight(pmReadout *readout // Readout for which to generate weight
+                            )
+{
+    PS_ASSERT_PTR_NON_NULL(readout, false);
+
+    pmCell *cell = readout->parent;     // The parent cell
+    bool mdok = true;                   // Status of MD lookup
 
     // Create the weight image if required
@@ -213,5 +247,5 @@
                     trimsecString);
             psFree(trimsecString);
-            return NULL;
+            return false;
         }
         psImageInit(weight, 0);
@@ -219,15 +253,9 @@
     }
 
-    // Set weight image to the variance in ADU = f/g + rn^2
-    psImage *image = readout->image;    // The image pixels
-    psBinaryOp(readout->weight, image, "/", psScalarAlloc(gain, PS_TYPE_F32));
-    psBinaryOp(readout->weight, readout->weight, "+",
-               psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32));
-
-    return true;
-}
-
-bool pmCellSetMaskWeight(pmCell *cell // Cell for which to set weights
-                        )
+    return pmReadoutSetWeight(readout);
+}
+
+bool pmCellGenerateMaskWeight(pmCell *cell // Cell for which to set weights
+                             )
 {
     PS_ASSERT_PTR_NON_NULL(cell, false);
@@ -237,6 +265,6 @@
     for (int i = 0; i < readouts->n; i++) {
         pmReadout *readout = readouts->data[i]; // The readout
-        success |= pmReadoutSetMask(readout);
-        success |= pmReadoutSetWeight(readout);
+        success |= pmReadoutGenerateMask(readout);
+        success |= pmReadoutGenerateWeight(readout);
     }
 
@@ -244,6 +272,6 @@
 }
 
-bool pmReadoutSetMaskWeight(pmReadout *readout // Readout for which to set mask and weights
-                           )
+bool pmReadoutGenerateMaskWeight(pmReadout *readout // Readout for which to set mask and weights
+                                )
 {
     PS_ASSERT_PTR_NON_NULL(readout, false);
@@ -251,6 +279,6 @@
     bool success;
 
-    success |= pmReadoutSetMask(readout);
-    success |= pmReadoutSetWeight(readout);
+    success |= pmReadoutGenerateMask(readout);
+    success |= pmReadoutGenerateWeight(readout);
 
     return success;
Index: /trunk/psModules/src/camera/pmFPAMaskWeight.h
===================================================================
--- /trunk/psModules/src/camera/pmFPAMaskWeight.h	(revision 7714)
+++ /trunk/psModules/src/camera/pmFPAMaskWeight.h	(revision 7715)
@@ -21,12 +21,23 @@
 } pmMaskValue;
 
+// These functions set an extant mask/weight (or create a throwaway one).
+// The throwaway case is intended for when the user is iterating using pmReadoutReadNext, in which case
+// the HDU can't be generated
 bool pmReadoutSetMask(pmReadout *readout // Readout for which to set mask
                      );
 bool pmReadoutSetWeight(pmReadout *readout // Readout for which to set weight
                        );
-bool pmCellSetMaskWeight(pmCell *cell // Cell for which to set weights
-                        );
-bool pmReadoutSetMaskWeight(pmReadout *readout // Readout for which to set weights
-                           );
+
+// These functions generate a mask/weight suitable for output (complete with HDU entry) and then set them.
+bool pmReadoutGenerateMask(pmReadout *readout // Readout for which to generate mask
+                          );
+bool pmReadoutGenerateWeight(pmReadout *readout // Readout for which to generate weight
+                            );
+
+// These functions are conveniences for pmReadoutGenerateMask and pmReadoutGenerateWeight.
+bool pmCellGenerateMaskWeight(pmCell *cell // Cell for which to generate mask and weights
+                             );
+bool pmReadoutGenerateMaskWeight(pmReadout *readout // Readout for which to generate mask and weights
+                                );
 
 
Index: /trunk/psModules/src/camera/pmFPARead.c
===================================================================
--- /trunk/psModules/src/camera/pmFPARead.c	(revision 7714)
+++ /trunk/psModules/src/camera/pmFPARead.c	(revision 7715)
@@ -159,5 +159,6 @@
 //
 // Note that this doesn't put pixels in the HDU.  It is therefore NOT COMPATIBLE with pmCellWrite,
-// pmChipWrite, and pmFPAWrite.  Use pmReadoutWriteNext to write the data that's read by this function.
+// pmChipWrite, and pmFPAWrite (or any function that uses or creates an HDU for that matter).
+// Use pmReadoutWriteNext to write the data that's read by this function.
 bool pmReadoutReadNext(pmReadout *readout, // Readout into which to read
                        psFits *fits,    // FITS file from which to read
