Index: trunk/ppStack/src/ppStackSources.c
===================================================================
--- trunk/ppStack/src/ppStackSources.c	(revision 21259)
+++ trunk/ppStack/src/ppStackSources.c	(revision 21260)
@@ -146,4 +146,28 @@
 #endif
 
+    // Save best matches SOMEWHERE for future photometry
+    // XXX this is a really poor output location; clean up the pmFPAfiles used in ppStack
+    pmCell *sourcesCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT");
+    psArray *sourcesBest = psArrayAllocEmpty (100);
+
+    // XXX something of a hack: require at 2 detections or 1/2 of the max possible
+    int minMatches = PS_MAX (2, 0.5*num);
+    for (int i = 0; i < matches->n; i++) {
+	pmSourceMatch *match = matches->data[i]; // Match of interest
+	if (match->num < minMatches) continue;
+
+	// We need to grab a single instance of this source: just take the first available
+	int nImage = match->image->data.S32[0];
+	int nIndex = match->index->data.S32[0];
+	psArray *sources = sourceLists->data[nImage];
+	pmSource *source = sources->data[nIndex];
+	
+	// stick this sample source on sourcesBest
+	psArrayAdd (sourcesBest, 100, source);
+    }
+    psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest);
+    psLogMsg("ppStack", PS_LOG_INFO, "Selected %ld sources for photometry analysis\n", sourcesBest->n);
+    psFree (sourcesBest);
+
     psFree(matches);
     if (!trans) {
