Index: branches/tap_branches/ppSim/src/ppSimInsertStars.c
===================================================================
--- branches/tap_branches/ppSim/src/ppSimInsertStars.c	(revision 25900)
+++ branches/tap_branches/ppSim/src/ppSimInsertStars.c	(revision 27838)
@@ -26,4 +26,5 @@
     float expTime   = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time
     float darkRate  = psMetadataLookupF32(NULL, recipe, "DARK.RATE"); // Dark rate
+    float nSigmaLim = psMetadataLookupF32(NULL, recipe, "STARS.SIGMA.LIM"); // significance of faintest stars
 
     float readnoise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE");// CCD read noise, e
@@ -106,6 +107,5 @@
         pmModelSetFlux (model, flux);
 
-        // XXX let the flux limit be a user-defined number of sky sigmas (not just 1.0)
-        float radius = model->modelRadius (model->params, roughNoise);
+        float radius = model->modelRadius (model->params, nSigmaLim * roughNoise);
         radius = PS_MAX (radius, 1.0);
 
@@ -136,5 +136,5 @@
         RESET(source->maskView);
         RESET(source->modelFlux);
-        RESET(source->psfFlux);
+        RESET(source->psfImage);
         RESET(source->blends);
 
@@ -145,7 +145,13 @@
     fclose (outfile);
 
-    // NOTE: the pmFPAfile "PPSIM.OUTPUT" points at these sources
-    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "fake sources", sources);
-    psFree(sources);
+    pmDetections *detections = pmDetectionsAlloc();
+    detections->allSources = sources;
+
+    // save detections on the readout->analysis
+    if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_META_REPLACE | PS_DATA_UNKNOWN, "fake sources", detections)) {
+	psError (PSPHOT_ERR_CONFIG, false, "problem saving detections on readout");
+	return false;
+    }
+    psFree(detections);
 
     // XXX many leaks in here, i think
