Index: /trunk/ppImage/src/Makefile.am
===================================================================
--- /trunk/ppImage/src/Makefile.am	(revision 38232)
+++ /trunk/ppImage/src/Makefile.am	(revision 38233)
@@ -50,4 +50,5 @@
 	ppImageMemory.c \
         ppImageAddNoise.c \
+        ppImageSquashNANs.c \
         ppImageRandomGaussian.c \
 	ppImageAuxiliaryMask.c \
Index: /trunk/ppImage/src/ppImage.h
===================================================================
--- /trunk/ppImage/src/ppImage.h	(revision 38232)
+++ /trunk/ppImage/src/ppImage.h	(revision 38233)
@@ -52,4 +52,5 @@
     bool checkCTE;                      // measure pixel-based variance
     bool checkNoise;                    // measure cell-level variance
+    bool squashNANs;                    // measure cell-level variance
     bool applyParity;                   // Apply Cell parities
     bool doMaskStats;                   // Calculate mask statistics
@@ -59,7 +60,7 @@
     bool addNoise;                      // Add noise to degrade MD image to 3pi
 
-  bool hasVideo;                      // Determine if this OTA has a video cell
-  bool useVideoDark;                  // Should we use a video dark if we can?
-  bool useVideoMask;                  // Should we use a video mask if we can?
+    bool hasVideo;                      // Determine if this OTA has a video cell
+    bool useVideoDark;                  // Should we use a video dark if we can?
+    bool useVideoMask;                  // Should we use a video mask if we can?
   
     // output files requested
@@ -117,5 +118,5 @@
     psStatsOptions patternCellMean;        // Statistic for mean
 
-  int patternContinuityEdgeWidth;        // Size of box to use for edge matching.
+    int patternContinuityEdgeWidth;        // Size of box to use for edge matching.
   
     int remnanceSize;                   // Size for remnance detection
@@ -124,10 +125,10 @@
     char *normClass;                    // class to use for per-class normalization
 
-  psU16 maskstat_static;
-  psU16 maskstat_dynamic;
-  psU16 maskstat_magic;
-  psU16 maskstat_advisory;
-
-  psString auxVideoMask;                // auxillary video mask file
+    psU16 maskstat_static;
+    psU16 maskstat_dynamic;
+    psU16 maskstat_magic;
+    psU16 maskstat_advisory;
+
+    psString auxVideoMask;                // auxillary video mask file
   
 } ppImageOptions;
@@ -183,4 +184,6 @@
 bool ppImageCheckNoise(pmConfig *config, ppImageOptions *options, pmFPAview *view);
 
+bool ppImageSquashNANs(pmConfig *config, ppImageOptions *options, pmFPAview *view);
+
 bool ppImageBurntoolMask(pmConfig *config, ppImageOptions *options, pmFPAview *view, pmReadout *readout);
 bool ppImageBurntoolMaskFromTable(pmConfig *config, ppImageOptions *options, pmFPAview *view, pmReadout *readout);
Index: /trunk/ppImage/src/ppImageLoop.c
===================================================================
--- /trunk/ppImage/src/ppImageLoop.c	(revision 38232)
+++ /trunk/ppImage/src/ppImageLoop.c	(revision 38233)
@@ -133,4 +133,9 @@
 		if (!ppImageAddNoise(config, options, view, input->fpa)){
                     ESCAPE("Unable to degrade MD image to 3pi");
+		}
+
+
+		if (!ppImageSquashNANs(config, options, view)) {
+                    ESCAPE("Unable to squash NAN pixels");
 		}
 
Index: /trunk/ppImage/src/ppImageOptions.c
===================================================================
--- /trunk/ppImage/src/ppImageOptions.c	(revision 38232)
+++ /trunk/ppImage/src/ppImageOptions.c	(revision 38233)
@@ -46,4 +46,5 @@
     options->checkCTE        = false;   // Measure pixel-based variance
     options->checkNoise      = false;   // Measure cell-level variances.
+    options->squashNANs      = false;   // Measure cell-level variances.
     options->applyParity     = false;   // Apply Cell parities
     options->doMaskStats     = false;   // Calculate mask fractions
@@ -340,4 +341,5 @@
     options->checkCTE       = psMetadataLookupBool(NULL, recipe, "CHECK.CTE");
     options->checkNoise     = psMetadataLookupBool(NULL, recipe, "CHECK.NOISE");
+    options->squashNANs     = psMetadataLookupBool(NULL, recipe, "SQUASH.NANS");
 
     /* doMaskBuild : there are some cases where we require a mask, so we force doMaskBuild to be set even if the user specified 'FALSE'
Index: /trunk/ppImage/src/ppImageSquashNANs.c
===================================================================
--- /trunk/ppImage/src/ppImageSquashNANs.c	(revision 38233)
+++ /trunk/ppImage/src/ppImageSquashNANs.c	(revision 38233)
@@ -0,0 +1,32 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ppImage.h"
+
+bool ppImageSquashNANs(pmConfig *config, ppImageOptions *options, pmFPAview *view)
+{
+    // this step is completely optional.
+    if (!options->squashNANs) {
+	return true;
+    }
+    
+    psTimerStart("squash.NANs");
+
+    // find the currently selected readout
+    pmReadout *readout = pmFPAfileThisReadout(config->files, view, "PPIMAGE.INPUT");
+
+    psImage *image = readout->image;    // Readout's image
+    int numCols = image->numCols, numRows = image->numRows; // Size of image
+
+    for (int y = 0; y < numRows; y++) {
+	for (int x = 0; x < numCols; x++) {
+	    if (!isfinite(image->data.F32[y][x])) {
+		image->data.F32[y][x] = -500.0;
+	    }
+	}
+    }
+    psLogMsg ("ppImage", 5, "squash NANs: %f sec\n", psTimerMark ("squash.NANs"));
+
+    return true;
+}
