Index: trunk/ppSim/src/ppSimInsertStars.c
===================================================================
--- trunk/ppSim/src/ppSimInsertStars.c	(revision 27657)
+++ trunk/ppSim/src/ppSimInsertStars.c	(revision 28125)
@@ -23,4 +23,6 @@
     // XXX this is missing the gain.
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe
+
+    bool psfConvolve = psMetadataLookupBool(NULL, recipe, "PSF.CONVOLVE"); // smooth the image with the PSF?
 
     float expTime   = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time
@@ -103,43 +105,50 @@
         float flux = star->flux * expCorr->data.F32[(int)yCell][(int)xCell];
 
-        // instantiate a model for the PSF at this location, set desired flux
-        pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0);
-        pmModelSetFlux (model, flux);
+	// if psfConvolve is TRUE, we will (elsewhere) convolve the image we a PSF
+	// in this case, simply place delta functions in the image
+	if (psfConvolve) {
+	    readout->image->data.F32[(int)(yCell)][(int)(xCell)] = flux;
+	    continue;
+	}
 
-        float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
-        radius = PS_MAX (radius, 1.0);
+	// instantiate a model for the PSF at this location, set desired flux
+	pmModel *model = pmModelFromPSFforXY (psf, xChip, yChip, 1.0);
+	pmModelSetFlux (model, flux);
 
-        // construct a source, with model flux pixels set, based on the model
-        pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
+	float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
+	radius = PS_MAX (radius, 1.0);
 
-        // XXX set the mag & err values (should this be done in pmSourceFromModel?)
-        // XXX i should be applying the gain and the correct effective area
-        psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0);
-        psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
+	// construct a source, with model flux pixels set, based on the model
+	pmSource *source = pmSourceFromModel (model, readout, radius, PM_SOURCE_TYPE_STAR);
 
-        // this value is the pure (input) flux, and is saved in the output source cmf files
-        source->psfMag = -2.5*log10(star->flux);
-        source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux;
+	// XXX set the mag & err values (should this be done in pmSourceFromModel?)
+	// XXX i should be applying the gain and the correct effective area
+	psEllipseAxes axes = pmPSF_ModelToAxes (model->params->data.F32, 20.0);
+	psF64 Area = 2.0 * M_PI * axes.major * axes.minor;
 
-        fprintf (outfile, "%8.3f %8.3f  %10.2f  %7.3f %5.3f\n", star->x, star->y, star->flux, source->psfMag, source->errMag);
+	// this value is the pure (input) flux, and is saved in the output source cmf files
+	source->psfMag = -2.5*log10(star->flux);
+	source->errMag = sqrt(Area*PS_SQR(roughNoise) + flux) / flux;
 
-        // insert the source flux in the image
-        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
+	fprintf (outfile, "%8.3f %8.3f  %10.2f  %7.3f %5.3f\n", star->x, star->y, star->flux, source->psfMag, source->errMag);
 
-        // insert the source flux in the noise image
-        pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY);
+	// insert the source flux in the image
+	pmSourceAddWithOffset (source, PM_MODEL_OP_FULL, 0xff, dX, dY);
 
-        // Blow away the image parts of the source, which makes the memory explode
-        RESET(source->pixels);
-        RESET(source->variance);
-        RESET(source->maskObj);
-        RESET(source->maskView);
-        RESET(source->modelFlux);
-        RESET(source->psfImage);
-        RESET(source->blends);
+	// insert the source flux in the noise image
+	pmSourceAddWithOffset (source, PM_MODEL_OP_FULL | PM_MODEL_OP_NOISE, 0xff, dX, dY);
 
-        // add the sources to the source array
-        psArrayAdd (sources, 100,source);
-        psFree(source);                 // Drop reference
+	// Blow away the image parts of the source, which makes the memory explode
+	RESET(source->pixels);
+	RESET(source->variance);
+	RESET(source->maskObj);
+	RESET(source->maskView);
+	RESET(source->modelFlux);
+	RESET(source->psfImage);
+	RESET(source->blends);
+
+	// add the sources to the source array
+	psArrayAdd (sources, 100,source);
+	psFree(source);                 // Drop reference
     }
     fclose (outfile);
