Index: /trunk/psModules/src/detrend/pmShutterCorrection.c
===================================================================
--- /trunk/psModules/src/detrend/pmShutterCorrection.c	(revision 9383)
+++ /trunk/psModules/src/detrend/pmShutterCorrection.c	(revision 9384)
@@ -481,4 +481,11 @@
         pmShutterCorrection *guess = pmShutterCorrectionGuess(exptimes, counts); // Guess at correction
         pmShutterCorrection *corr = pmShutterCorrectionFullFit(exptimes, counts, errors, guess); // Correct'n
+        if (!corr) {
+            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to measure shutter reference correction.\n");
+            psFree(guess);
+            psFree(counts);
+            psFree(errors);
+            goto MEASURE_ERROR;
+        }
         psTrace("psModules.detrend", 5, "Sample reference value: %f\n", corr->offref);
         if (isfinite(corr->offref)) {
@@ -508,5 +515,5 @@
                 // We don't have weights, so no realistic errors: turn off iteration
                 if (nIter > 0) {
-                    psWarning("Not all images have weights --- turning weighting off.\n");
+                    psWarning("Not all images have weights --- turning iteration off.\n");
                 }
                 nIter = 1;
@@ -516,5 +523,5 @@
 
     psImage *shutter = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Shutter correction image
-    //psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
+    psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
     psVector *mask = psVectorAlloc(num, PS_TYPE_U8); // Mask for each image
     mask->n = num;
@@ -541,11 +548,17 @@
                                         nIter, rej, maskVal);
             shutter->data.F32[y][x] = corr->offset;
-            //pattern->data.F32[y][x] = corr->scale;
+            pattern->data.F32[y][x] = corr->scale;
             psFree(corr);
         }
     }
+    psFree(mask);
     psFree(counts);
     psFree(errors);
     psFree(refs);
+
+    psFits *fits = psFitsOpen("pattern.fits", "w");
+    psFitsWriteImage(fits, NULL, pattern, 0, NULL);
+    psFitsClose(fits);
+    psFree(pattern);
 
     return shutter;
