Index: branches/pap/ppStack/src/ppStackSources.c
===================================================================
--- branches/pap/ppStack/src/ppStackSources.c	(revision 26313)
+++ branches/pap/ppStack/src/ppStackSources.c	(revision 26325)
@@ -163,5 +163,5 @@
         }
 
-        zp->data.F32[i] = airmassTerm * airmass - 2.5 * log10(exptime);
+        zp->data.F32[i] = 2.5 * log10(exptime) - airmassTerm * airmass;
         sumExpTime += exptime;
     }
@@ -243,8 +243,9 @@
     psFree(matches);
 
-    // M = m + c0 + c1 * airmass - 2.5log(t) + transparency
+    // M = m + c0 - c1 * airmass + 2.5log(t) - transparency
     // Want sources to have m corresponding to airmass = 1 and t = sumExpTime and transparency = 0
-    // m_0 + c1 * airmass_0 + 2.5log(t_0) - trans_0 = m_1 + c1 * airmass_1 + 2.5log(t_1) - trans_1
-    // m_0 = m_1 + zp_1 + trans_1 - c1 * airmass_0 - 2.5log(t_0)
+    // m_0 - c1 * airmass_0 + 2.5log(t_0) - trans_0 = m_1 - c1 * airmass_1 + 2.5log(t_1) - trans_1
+    // m_0 = m_1 + zp_1 - trans_1 + c1 * airmass_0 - 2.5log(t_0)
+    // where zp_1 = 2.5log(t_1) - c1 * airmass_1
     // We don't need to know the magnitude zero point for the filter, since it cancels out
     psLogMsg("ppStack", PS_LOG_INFO, "Scaling output to exp = %f sec, with airmass addition = %f mag\n",
@@ -256,5 +257,5 @@
         }
         psArray *sources = sourceLists->data[i]; // Sources of interest
-        float magCorr = airmassTerm - 2.5*log10(sumExpTime) - zp->data.F32[i] - trans->data.F32[i];
+        float magCorr = airmassTerm - 2.5*log10(sumExpTime) + zp->data.F32[i] - trans->data.F32[i];
         options->norm->data.F32[i] = magCorr;
         psLogMsg("ppStack", PS_LOG_INFO, "Applying magnitude correction to image %d: %f (%f,%f)\n",
