Index: /trunk/ippScripts/scripts/ipp_serial_mops.pl
===================================================================
--- /trunk/ippScripts/scripts/ipp_serial_mops.pl	(revision 24338)
+++ /trunk/ippScripts/scripts/ipp_serial_mops.pl	(revision 24339)
@@ -80,5 +80,6 @@
     MAX(diffWarps.diff_id) AS diff_id,
     -- The following trick pulls out the appropriate values for the maximum diff_id
-    SUBSTRING_INDEX(GROUP_CONCAT(camTemplate.zpt_obs ORDER BY diffWarps.diff_id), ',', 1) AS zpt_obs,
+    SUBSTRING_INDEX(GROUP_CONCAT(camProcessedTemplate.zpt_obs ORDER BY diffWarps.diff_id), ',', 1) AS zpt_obs,
+    SUBSTRING_INDEX(GROUP_CONCAT(rawTemplate.exp_time ORDER BY diffWarps.diff_id), ',', 1) AS exp_time,
     CONVERT(SUBSTRING_INDEX(GROUP_CONCAT(diffWarps.inverse ORDER BY diffWarps.diff_id), ',', 1), UNSIGNED) AS inverse
 FROM (
@@ -117,5 +118,8 @@
 JOIN warpRun AS warpTemplate ON warpTemplate.warp_id = diffWarps.template_warp
 JOIN fakeRun AS fakeTemplate ON fakeTemplate.fake_id = warpTemplate.fake_id
-JOIN camProcessedExp AS camTemplate ON camTemplate.cam_id = fakeTemplate.cam_id
+JOIN camRun AS camTemplate ON camTemplate.cam_id = fakeTemplate.cam_id
+JOIN camProcessedExp AS camProcessedTemplate ON camProcessedTemplate.cam_id = camTemplate.cam_id
+JOIN chipRun AS chipTemplate ON chipTemplate.chip_id = camTemplate.chip_id
+JOIN rawExp AS rawTemplate ON rawTemplate.exp_id = chipTemplate.exp_id
 WHERE rawExp.camera = '$camera'
 GROUP BY exp_id;";
@@ -132,6 +136,10 @@
     my $exp_id = $diff->{exp_id};
     my $zp = $diff->{zpt_obs};
+    my $exp_time = $diff->{exp_time};
     my $diff_id = $diff->{diff_id};
     my $inverse = $diff->{inverse};
+
+    (carp "Bad ZP or EXPTIME for $exp_id" and next) if not defined $zp or not defined $exp_time;
+    $zp += 2.5 * log($exp_time) / log(10);
 
     my $sql = "SELECT * FROM diffSkyfile WHERE diff_id = $diff_id AND fault = 0 AND quality = 0;";
Index: /trunk/ppMops/src/ppMops.c
===================================================================
--- /trunk/ppMops/src/ppMops.c	(revision 24338)
+++ /trunk/ppMops/src/ppMops.c	(revision 24339)
@@ -16,4 +16,9 @@
     data->zp = atof(argv[2]);
     data->output = psStringCopy(argv[3]);
+
+    if (!isfinite(data->zp)) {
+        psErrorStackPrint(stderr, "Zero point is unknown\n");
+        exit(PS_EXIT_CONFIG_ERROR);
+    }
 
     psArray *detections = NULL;         // Detections
@@ -43,11 +48,4 @@
             exit(PS_EXIT_DATA_ERROR);
         }
-    }
-
-    // Correct ZP for exposure time
-    data->zp += 2.5 * log10(psMetadataLookupF32(NULL, header, "EXPTIME"));
-    if (!isfinite(data->zp)) {
-        psErrorStackPrint(stderr, "Zero point is unknown\n");
-        exit(PS_EXIT_CONFIG_ERROR);
     }
 
