Index: trunk/psphot/src/psphotMergeSources.c
===================================================================
--- trunk/psphot/src/psphotMergeSources.c	(revision 13411)
+++ trunk/psphot/src/psphotMergeSources.c	(revision 20070)
@@ -51,2 +51,42 @@
     return true;
 }
+
+pmDetections *detections = psphotLoadPSFSources (pmConfig *config, const pmFPAview *view) {
+
+    // find the currently selected readout
+    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CMF");
+    if (!readout) {
+        psLogMsg ("psphot", 3, "readout not found");
+        return NULL;
+    }
+
+    pmDetections *detections = pmDetectionsAlloc();
+  
+    psArray *sources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
+    if (!sources) {
+        psLogMsg ("psphot", 3, "no psf sources for this readout");
+        return detections;
+    }
+
+    detections->peaks = psArrayAllocEmpty(100);
+
+    for (int i = 0; i < sources->n; i++) {
+        pmSource *source = sources->data[i];
+        pmModel *model = source->modelPSF;
+
+        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 = 1.0;
+
+	psArrayAdd (detections->peaks, 100, peak);
+	psFree (peak);
+    }
+
+    psLogMsg ("psphot", 3, "%ld PSF sources loaded", detections->peaks->nn);
+
+    return detections;
+}
