Index: /trunk/ppMops/src/ppMops.c
===================================================================
--- /trunk/ppMops/src/ppMops.c	(revision 24244)
+++ /trunk/ppMops/src/ppMops.c	(revision 24245)
@@ -46,8 +46,9 @@
 
     // Translate the columns
-    int numRows = detections->n;        // Number of rows
-    psArray *output = psArrayAlloc(numRows); // Output table
+    int numIn = detections->n;        // Number of rows in input
+    int numOut = 0;                   // Number of rows in output
+    psArray *output = psArrayAllocEmpty(numIn); // Output table
     double plateScale = 0.0;                 // Average plate scale
-    for (int i = 0; i < numRows; i++) {
+    for (int i = 0; i < numIn; i++) {
         psMetadata *inRow = detections->data[i]; // Input row
         psMetadata *outRow = output->data[i] = psMetadataAlloc(); // Output row
@@ -64,4 +65,9 @@
         psU32 flags = psMetadataLookupU32(NULL, inRow, "FLAGS");
 
+        if (flags & SOURCE_MASK) {
+            continue;
+        }
+
+        numOut++;
         plateScale += scale;
 
@@ -86,5 +92,6 @@
         psMetadataAddF64(outRow, PS_LIST_TAIL, "LEN_SIG", 0, "Length error (arcsec)", 0.0);
     }
-    plateScale /= numRows;
+    output->n = numOut;
+    plateScale /= numOut;
     psFree(detections);
 
@@ -101,4 +108,5 @@
         double az = psMetadataLookupF64(NULL, header, "FPA.AZ");
         int imageid = psMetadataLookupS32(NULL, header, "IMAGEID");
+        double mjd = psMetadataLookupF64(NULL, header, "MJD-OBS") + exptime / 2.0 / 3600 / 24;
 
         float psf = plateScale * 0.5 * (psMetadataLookupF32(NULL, header, "FWHM_MAJ") +
@@ -111,4 +119,5 @@
         psMetadataAddF64(outHeader, PS_LIST_TAIL, "RA", 0, "Right ascension of boresight", ra);
         psMetadataAddF64(outHeader, PS_LIST_TAIL, "DEC", 0, "Declination of boresight", dec);
+        psMetadataAddF64(outHeader, PS_LIST_TAIL, "MJD-OBS", 0, "MJD of exposure midpoint", mjd);
         psMetadataAddStr(outHeader, PS_LIST_TAIL, "FILTER", 0, "Filter name", filter);
         psMetadataAddF64(outHeader, PS_LIST_TAIL, "EXPTIME", 0, "Exposure time (sec)", exptime);
Index: /trunk/ppMops/src/ppMops.h
===================================================================
--- /trunk/ppMops/src/ppMops.h	(revision 24244)
+++ /trunk/ppMops/src/ppMops.h	(revision 24245)
@@ -7,4 +7,11 @@
 #define OBSERVATORY_CODE 566                    // IAU Observatory Code
 #define OUT_EXTNAME "MOPS_TRANSIENT_DETECTIONS" // Extension name for data in output
+#define SOURCE_MASK (8 | /* FAIL */ \
+                     1024 |  /* BADPSF */ \
+                     2048 | /* DEFECT */ \
+                     4096 | /* SATURATED */ \
+                     8192 | /* CR_LIMIT */ \
+                     65536 /* SKY_FAILURE */ \
+                     )
 
 // Configuration data
