Index: trunk/ppTranslate/src/ppMopsWrite.c
===================================================================
--- trunk/ppTranslate/src/ppMopsWrite.c	(revision 34284)
+++ trunk/ppTranslate/src/ppMopsWrite.c	(revision 34438)
@@ -38,9 +38,30 @@
 
   // Get these header words from the first input non null input
+  // but for SEEING which is the median of the (non-NULL) detections
+  // seeings
   ppMopsDetections *det = NULL;
-  for (int d = 0; d < detections->n && det == NULL; d++) {
-    det = detections->data[d];
+  int validSeeingCount = 0;
+  for (int d = 0; d < detections->n; d++) {
+    if (detections->data[d] != NULL) {
+      if (det == NULL) {
+	det = detections->data[d];
+      }
+      if (isfinite(detections->data[d]->seeing)) {
+	validSeeingCount += 1;
+      }
+    }
   }
   if (det != NULL) {
+    //Get the SEEING median
+    seeingValues = psVectorAlloc(validSeeingCount, PS_TYPE_F32);
+    psVectorInit(validSeeingCount, NAN);
+    validSeeingCount = 0;
+    for (int d = 0; d < detections->n; d++) {
+      if ( (detections->data[d] != NULL) && (isfinite(detections->data[d]->seeing)) ){
+	seeingValues->data.F32[validSeeingCount++] = detections->data[d]->seeing;
+      }
+    }
+    psStats *seeingStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
+    psVectorStats(seeingStats, seeingValues, NULL, NULL, 0);
     psMetadataAddF64(header, PS_LIST_TAIL, "MJD-OBS", 0, "MJD of exposure midpoint", det->mjd);
     psMetadataAddStr(header, PS_LIST_TAIL, "RA", 0, "Right Ascension of boresight", det->raBoresight);
@@ -52,5 +73,5 @@
     psMetadataAddStr(header, PS_LIST_TAIL, "FILTER", 0, "Filter name", det->filter);
     psMetadataAddF32(header, PS_LIST_TAIL, "AIRMASS", 0, "Airmass of exposure", det->airmass);
-    psMetadataAddF32(header, PS_LIST_TAIL, "SEEING", 0, "Mean seeing", det->seeing);
+    psMetadataAddF32(header, PS_LIST_TAIL, "SEEING", 0, "Mean seeing", seeingStats->sampleMedian);
   } else {
     psWarning("no inputs with surviving detections. output header will be incomplete");
