Index: /branches/pap_mops/ippScripts/scripts/publish_file.pl
===================================================================
--- /branches/pap_mops/ippScripts/scripts/publish_file.pl	(revision 24506)
+++ /branches/pap_mops/ippScripts/scripts/publish_file.pl	(revision 24507)
@@ -107,4 +107,7 @@
         next if defined $comp->{quality} and $comp->{quality} > 0;
 
+        (carp "Bad zpt_obs or exp_time for component" and next) if not defined $comp->{zpt_obs} or not defined $comp->{exp_time};
+        my $zp = $comp->{zpt_obs} + 2.5 * log($comp->{exp_time}) / log(10);
+
         if ($stage eq 'diff') {
             my $skycell_id = $comp->{skycell_id};
@@ -112,10 +115,10 @@
             $files{"$skycell_id.neg"} = $ipprc->filename( "PPSUB.INVERSE.SOURCES", $path_base ) if
                 defined $comp->{bothways} and $comp->{bothways};
-            $zp{"$skycell_id.pos"} = $comp->{zpt_obs};
-            $zp{"$skycell_id.neg"} = $comp->{zpt_obs};
+            $zp{"$skycell_id.pos"} = $zp;
+            $zp{"$skycell_id.neg"} = $zp if defined $comp->{bothways} and $comp->{bothways};
         } elsif ($stage eq 'camera') {
             my $cam_id = $comp->{cam_id};
             $files{$cam_id} = $ipprc->filename( "PSASTRO.OUTPUT", $path_base );
-            $zp{$cam_id} = $comp->{zpt_obs};
+            $zp{$cam_id} = $zp;
         }
     }
Index: /branches/pap_mops/ippTools/share/camtool_find_processedexp.sql
===================================================================
--- /branches/pap_mops/ippTools/share/camtool_find_processedexp.sql	(revision 24506)
+++ /branches/pap_mops/ippTools/share/camtool_find_processedexp.sql	(revision 24507)
@@ -5,4 +5,5 @@
     rawExp.exp_tag,
     rawExp.exp_name,
+    rawExp.exp_time,
     rawExp.camera,
     rawExp.telescope,
Index: /branches/pap_mops/ippTools/share/difftool_skyfile.sql
===================================================================
--- /branches/pap_mops/ippTools/share/difftool_skyfile.sql	(revision 24506)
+++ /branches/pap_mops/ippTools/share/difftool_skyfile.sql	(revision 24507)
@@ -10,4 +10,5 @@
     camProcessedExp.zpt_lq,
     camProcessedExp.zpt_uq,
+    rawExp.exp_time,
     rawExp.camera,
     warp1,
@@ -19,5 +20,8 @@
 JOIN diffInputSkyfile USING(diff_id, skycell_id)
 JOIN warpRun
-    ON warpRun.warp_id = diffInputSkyfile.warp1 -- NOTE: joining input only!
+-- NOTE: joining input only!
+-- This is so that we can get the correct zero point
+-- XXX This needs to be more clever to handle diffs between stacks
+    ON warpRun.warp_id = diffInputSkyfile.warp1
 JOIN fakeRun USING(fake_id)
 JOIN camRun USING(cam_id)
