Index: trunk/ppSub/src/ppSubSetMasks.c
===================================================================
--- trunk/ppSub/src/ppSubSetMasks.c	(revision 21360)
+++ trunk/ppSub/src/ppSubSetMasks.c	(revision 21524)
@@ -6,22 +6,26 @@
  *
  *  @author IfA
- *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-06 01:37:17 $
+ *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-18 00:31:20 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <pslib.h>
+#include <psmodules.h>
+#include <psphot.h>
+
 #include "ppSub.h"
 
-/** this function generates (if needed) and sets or updates the masks for both the input and
- * reference images.  this function also has the code for interpolation over bad pixels, but it
- * is currently if-def-ed out
- */
+bool ppSubSetMasks(pmConfig *config, const pmFPAview *view)
+{
+    psAssert(config, "Require configuration");
+    psAssert(view, "Require view");
 
-bool ppSubSetMasks (pmConfig *config, const pmFPAview *view) {
-
-    psImageMaskType maskValue;
-    psImageMaskType markValue;
-    bool mdok = false;
-
+    psImageMaskType maskValue, markValue; // Mask values
     if (!pmConfigMaskSetBits(&maskValue, &markValue, config)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to determine mask value.");
@@ -29,16 +33,16 @@
     }
 
-    // set the mask bits needed by psphot (in psphot recipe) 
+    // Set the mask bits needed by psphot (in psphot recipe)
     psphotSetMaskRecipe (config, maskValue, markValue);
 
     // Look up recipe values
-    psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
+    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     psAssert(recipe, "We checked this earlier, so it should be here.");
 
     psImageMaskType satValue = pmConfigMaskGet("SAT", config);
-    psAssert (satValue, "SAT must be non-zero");
+    psAssert(satValue, "SAT must be non-zero");
 
     psImageMaskType badValue = pmConfigMaskGet("BAD", config);
-    psAssert (badValue, "BAD must be non-zero");
+    psAssert(badValue, "BAD must be non-zero");
 
     // input images
@@ -49,8 +53,5 @@
     psImage *reference = refRO->image;  // Reference image
     PS_ASSERT_IMAGES_SIZE_EQUAL(input, reference, false);
-
-    // XXX use psImageCopy below to avoid caring about image dimensions
-    int numCols = input->numCols;
-    int numRows = input->numRows;
+    int numCols = input->numCols, numRows = input->numRows; // Size of image
 
     // Generate masks if they don't exist
@@ -78,15 +79,12 @@
     }
     if (!pmReadoutMaskNonfinite(refRO, satValue)) {
-	psError(PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in reference.");
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in reference.");
+        return false;
     }
 
-#if (0)
-    // Look up recipe values
-    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
-    psAssert(recipe, "We checked this earlier, so it should be here.");
 
+#if 0
+    // Interpolation over bad pixels: this takes a while!
     bool mdok = false;
-
     psString interpModeStr = psMetadataLookupStr(&mdok, recipe, "INTERPOLATION"); // Interpolation mode
     psImageInterpolateMode interpMode = psImageInterpolateModeFromString(interpModeStr); // Interp
@@ -102,10 +100,10 @@
     // Interpolate over bad pixels, so the bad pixels don't explode
     if (!pmReadoutInterpolateBadPixels(inRO, maskVal, interpMode, poorFrac, maskPoor, maskBad)) {
-	psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for input image.");
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for input image.");
+        return false;
     }
     if (!pmReadoutInterpolateBadPixels(refRO, maskVal, interpMode, poorFrac, maskPoor, maskBad)) {
-	psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for reference image.");
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "Unable to interpolate bad pixels for reference image.");
+        return false;
     }
     maskVal |= maskBad;
