Index: trunk/psModules/src/camera/pmFPAMaskWeight.c
===================================================================
--- trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 24483)
+++ trunk/psModules/src/camera/pmFPAMaskWeight.c	(revision 24767)
@@ -109,14 +109,24 @@
     float saturation = psMetadataLookupF32(&mdok, cell->concepts, "CELL.SATURATION"); // Saturation level
     if (!mdok || isnan(saturation)) {
-        psError(PS_ERR_IO, true, "CELL.SATURATION is not set --- unable to set mask.\n");
-        return false;
+        // psError(PS_ERR_IO, true, "CELL.SATURATION is not set --- unable to set mask.\n");
+        // return false;
+	psWarning("CELL.SATURATION is not set --- completely masking cell.\n");
+	saturation = NAN;
     }
     float bad = psMetadataLookupF32(&mdok, cell->concepts, "CELL.BAD"); // Bad level
     if (!mdok || isnan(bad)) {
-        psError(PS_ERR_IO, true, "CELL.BAD is not set --- unable to set mask.\n");
-        return false;
+        // psError(PS_ERR_IO, true, "CELL.BAD is not set --- unable to set mask.\n");
+        // return false;
+	psWarning("CELL.BAD is not set --- completely masking cell.\n");
+	bad = NAN;
     }
     psTrace("psModules.camera", 5, "Saturation: %f, bad: %f\n", saturation, bad);
 
+    // if CELL.GAIN or CELL.READNOISE are not set, then the variance will be set to NAN; 
+    // in this case, we have to set the mask as well
+    float gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); // Cell gain
+    if (!mdok) { gain = NAN; }
+    float readnoise = psMetadataLookupF32(&mdok, cell->concepts, "CELL.READNOISE"); // Cell read noise
+    if (!mdok) { readnoise = NAN; }
 
     // Set up the mask
@@ -127,4 +137,11 @@
     }
     psImage *mask = readout->mask;      // The mask pixels
+
+    // completely mask if SATURATION or BAD are invalid
+    if (isnan(saturation) || isnan(bad) || isnan(gain) || isnan(readnoise)) {
+	psImageInit(mask, badMask);
+	return true;
+    }
+
     psImageInit(mask, 0);
 
@@ -210,15 +227,31 @@
     float gain = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN"); // Cell gain
     if (!mdok || isnan(gain)) {
-        psError(PS_ERR_IO, true, "CELL.GAIN is not set --- unable to set variance.\n");
-        return false;
+        // psError(PS_ERR_IO, true, "CELL.GAIN is not set --- unable to set variance.\n");
+        // return false;
+        psWarning("CELL.GAIN is not set --- setting variance to NAN\n");
+	gain = NAN;
     }
     float readnoise = psMetadataLookupF32(&mdok, cell->concepts, "CELL.READNOISE"); // Cell read noise
     if (!mdok || isnan(readnoise)) {
-        psError(PS_ERR_IO, true, "CELL.READNOISE is not set --- unable to set variance.\n");
-        return false;
-    }
-    if (psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) {
+        // psError(PS_ERR_IO, true, "CELL.READNOISE is not set --- unable to set variance.\n");
+        // return false;
+        psWarning("CELL.READNOISE is not set --- setting variance to NAN\n");
+	readnoise = NAN;
+    }
+    // if we have a non-NAN readnoise, then we need to ensure it has been updated (not necessary if NAN)
+    if (!isnan(gain) && psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) {
         psError(PS_ERR_IO, true, "CELL.READNOISE has not yet been updated for the gain");
         return false;
+    }
+
+    // for invalid input data, set the readout variance to NAN
+    if (isnan(gain) || isnan(readnoise)) {
+        if (!readout->variance) {
+	    // generate the image if needed
+            readout->variance = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_F32);
+        }
+	// XXX need to set the mask, if defined
+        psImageInit(readout->variance, NAN);
+	return true;
     }
 
