Index: /trunk/ppSim/src/Makefile.am
===================================================================
--- /trunk/ppSim/src/Makefile.am	(revision 23464)
+++ /trunk/ppSim/src/Makefile.am	(revision 23465)
@@ -45,4 +45,5 @@
 	ppSimRandomGaussian.c	  \
 	ppSimBadPixels.c          \
+	ppSimBadCTE.c             \
 	ppSimVersion.c
 
Index: /trunk/ppSim/src/ppSim.h
===================================================================
--- /trunk/ppSim/src/ppSim.h	(revision 23464)
+++ /trunk/ppSim/src/ppSim.h	(revision 23465)
@@ -135,4 +135,9 @@
 
 
+// add a bad CTE region
+bool ppSimBadCTE(psImage *image,	// Signal image, modified and returned
+		 const pmConfig *config // configuration
+  );
+
 /// Add bad pixels to an image
 bool ppSimBadPixels(pmReadout *readout, ///< Readout for which to generate bad pixels
Index: /trunk/ppSim/src/ppSimBadCTE.c
===================================================================
--- /trunk/ppSim/src/ppSimBadCTE.c	(revision 23465)
+++ /trunk/ppSim/src/ppSimBadCTE.c	(revision 23465)
@@ -0,0 +1,34 @@
+# include "ppSim.h"
+
+// Add a "bad CTE" region to the image : it is not really modeled as bad CTE, rather it is
+// simply smoothed by a Gaussian kernel.  This has the same effect on the image variance as bad
+// CTE, but not (quite) the same effect on stellar photometry
+
+bool ppSimBadCTE(psImage *image,	// Signal image, modified and returned
+		 const pmConfig *config // configuration
+  )
+{
+    assert(image->type.type == PS_TYPE_F32);
+
+    bool status;
+
+    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
+    if (!psMetadataLookupBool (&status, recipe, "BADCTE")) {
+	return true;
+    }
+    
+    char *region = psMetadataLookupStr (&status, recipe, "BADCTE.REGION");
+    psRegion badCTE = psRegionForImage (image, psRegionFromString (region));
+    if (psRegionIsNaN (badCTE)) psAbort("analysis region mis-defined");
+
+    float sigma = psMetadataLookupF32 (&status, recipe, "BADCTE.SIGMA");
+    int Nsigma = psMetadataLookupS32 (&status, recipe, "BADCTE.NSIGMA");
+
+    psImage *subset = psImageSubset (image, badCTE);
+    if (!subset) psAbort ("error in badCTE region?");
+
+    psImageSmooth (subset, sigma, Nsigma);
+
+    return true;
+}
+
Index: /trunk/ppSim/src/ppSimLoop.c
===================================================================
--- /trunk/ppSim/src/ppSimLoop.c	(revision 23464)
+++ /trunk/ppSim/src/ppSimLoop.c	(revision 23465)
@@ -154,4 +154,7 @@
             done:
                 if (!ppSimAddNoise(readout->image, readout->variance, cell, config, rng)) ESCAPE (PS_ERR_UNKNOWN, "problem adding noise");
+
+                if (!ppSimBadCTE(readout->image, config)) ESCAPE (PS_ERR_UNKNOWN, "problem inducing bad cte");
+
                 if (!ppSimSaturate(readout, config)) ESCAPE (PS_ERR_UNKNOWN, "problem setting saturation levels");
 
