Index: trunk/ppSub/src/ppSubReadout.c
===================================================================
--- trunk/ppSub/src/ppSubReadout.c	(revision 20055)
+++ trunk/ppSub/src/ppSubReadout.c	(revision 20116)
@@ -547,4 +547,50 @@
                              psTimerClear("PPSUB_PHOT"));
         }
+
+#ifdef TESTING
+        // Record data about sources: not everything gets into the output CMF files
+        {
+            pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); // Readout with the sources
+            psArray *sources = psMetadataLookupPtr(NULL, photRO->analysis, "PSPHOT.SOURCES"); // Sources
+            FILE *sourceFile = fopen("sources.dat", "w"); // File for sources
+            fprintf(sourceFile, "# x y mag mag_err psf_chisq cr_nsigma ext_nsigma psf_qf flags m_x m_y m_xx m_xy m_yy\n");
+            for (int i = 0; i < sources->n; i++) {
+                pmSource *source = sources->data[i];
+                if (!source) {
+                    continue;
+                }
+
+                float x, y;             // Position of source
+                float chi2;             // chi^2 for source
+                if (source->modelPSF) {
+                    x = source->modelPSF->params->data.F32[PM_PAR_XPOS];
+                    y = source->modelPSF->params->data.F32[PM_PAR_YPOS];
+                    chi2 = source->modelPSF->chisq;
+                } else if (source->peak) {
+                    x = source->peak->xf;
+                    y = source->peak->yf;
+                    chi2 = NAN;
+                } else {
+                    psWarning("No position available for source.");
+                    continue;
+                }
+
+                float xMoment = NAN, yMoment = NAN, xxMoment = NAN, xyMoment = NAN, yyMoment = NAN;
+                if (source->moments) {
+                    xMoment = source->moments->Mx;
+                    yMoment = source->moments->My;
+                    xxMoment = source->moments->Mxx;
+                    xyMoment = source->moments->Mxy;
+                    yyMoment = source->moments->Myy;
+                }
+
+                fprintf(sourceFile, "%f %f %f %f %f %f %f %f %d %f %f %f %f %f",
+                        x, y, source->psfMag, source->errMag, chi2, source->crNsigma, source->extNsigma,
+                        source->pixWeight, source->mode, xMoment, yMoment, xxMoment, xyMoment, yyMoment);
+            }
+            fclose(sourceFile);
+        }
+#endif
+
     }
 
@@ -594,4 +640,5 @@
     }
 
+#ifdef TESTING
     // Significance image
     {
@@ -603,4 +650,5 @@
         psFree(sig);
     }
+#endif
 
     psFree(outRO);
