Index: trunk/psphot/src/psphotOutput.c
===================================================================
--- trunk/psphot/src/psphotOutput.c	(revision 6862)
+++ trunk/psphot/src/psphotOutput.c	(revision 7328)
@@ -20,4 +20,32 @@
 
     pmMomentsWriteText (sources, output);
+    return true;
+}
+
+bool psphotDumpSource (pmSource *source, char *name) {
+
+    FILE *f = fopen (name, "w");
+    if (f == NULL) psAbort ("psphot", "can't open file");
+
+    for (int i = 0; i < source->pixels->numRows; i++) {
+        for (int j = 0; j < source->pixels->numCols; j++) {
+            // skip masked points
+            if (source->mask->data.U8[i][j]) {
+                continue;
+            }
+            // skip zero-weight points
+            if (source->weight->data.F32[i][j] == 0) {
+                continue;
+            }
+
+	    fprintf (f, "%d %d %f %f %d\n", 
+		     (j + source->pixels->col0),
+		     (i + source->pixels->row0),
+		     source->pixels->data.F32[i][j],
+		     1.0 / source->weight->data.F32[i][j],
+		     source->mask->data.U8[i][j]);
+        }
+    }
+    fclose (f);
     return true;
 }
