Index: /branches/eam_branch_20090208/psphot/src/psphotMergeSources.c
===================================================================
--- /branches/eam_branch_20090208/psphot/src/psphotMergeSources.c	(revision 21453)
+++ /branches/eam_branch_20090208/psphot/src/psphotMergeSources.c	(revision 21454)
@@ -122,2 +122,42 @@
     return detections;
 }
+
+// generate the detection structure for the supplied array of sources
+bool psphotSetSourceParams (pmConfig *config, psArray *sources, pmPSF *psf) {
+
+    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
+    if (!recipe) {
+        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
+        return false;
+    }
+
+    for (int i = 0; i < sources->n; i++) {
+        pmSource *source = sources->data[i];
+        pmModel *model = source->modelPSF;
+
+        if (source->mode & PSF_SOURCE_MASK || !isfinite(source->psfMag)) {
+            continue;
+        }
+
+        float flux = powf(10.0, -0.4 * source->psfMag);
+        float xpos = model->params->data.F32[PM_PAR_XPOS];
+        float ypos = model->params->data.F32[PM_PAR_YPOS];
+
+        pmPeak *peak = pmPeakAlloc(xpos, ypos, 1.0, PM_PEAK_LONE);
+        peak->xf = xpos;
+        peak->yf = ypos;
+        peak->flux = flux; // this are being set wrong, but does it matter?
+
+	if (isfinite (source->errMag) && (source->errMag > 0.0)) {
+	  peak->SN = 1.0 / source->errMag; 
+	} else {
+	  peak->SN = 0.0;
+	}
+
+        source->peak = peak;
+    }
+
+    psLogMsg ("psphot", 3, "%ld PSF sources loaded", sources->n);
+
+    return true;
+}
