Index: /trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- /trunk/ippToPsps/jython/stackbatch.py	(revision 38825)
+++ /trunk/ippToPsps/jython/stackbatch.py	(revision 38826)
@@ -238,4 +238,12 @@
         photoCalID = str(self.scratchDb.getPhotoCalID(stackID))
 
+        # Convert detectionThreshold to appropriate magnitudes
+        detectionThreshold = self.getKeyFloat(header, "%.8f", 'DETEFF.MAGREF')
+        expTime = self.getKeyFloat(header, "%.8f", 'EXPTIME')
+        zp      = self.getKeyFloat(header, "%.8f", 'FPA.ZP')
+        # CZW check?
+        detectionThreshold = detectionThreshold + zp - 2.5 * math.log10(expTime)
+        
+        
         # mysql is sensitive to values which are ambiugously float.  eg
         # a warning is raised if we try to insert '25.' into a float field.
@@ -258,5 +266,5 @@
         sqlLine.group("photoCalID",    photoCalID) 
         sqlLine.group("analysisVer",   str(self.analysisVer))
-        sqlLine.group("completMag",       self.getKeyFloat(header, "%.8f", 'FLIMIT'))
+        sqlLine.group("detectionThreshold",       detectionThreshold)
         sqlLine.group("expTime",       self.getKeyFloat(header, "%.5f", 'EXPTIME'))  
         sqlLine.group("psfModelID",    psfmodelID)           
