Index: /trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- /trunk/ippToPsps/jython/detectionbatch.py	(revision 38953)
+++ /trunk/ippToPsps/jython/detectionbatch.py	(revision 38954)
@@ -504,5 +504,5 @@
             sqlLine.group("apFlux",       "AP_FLUX / " + expTimeString)
             sqlLine.group("apFluxErr",    "AP_FLUX_SIG / " + expTimeString)
-            sqlLine.group("apFillF",      "AP_NPIX / (3.14159265359 * POW(AP_MAG_RADIUS - 0.5, 2))")
+            sqlLine.group("apFillF",      "AP_NPIX / (3.14159265359 * AP_MAG_RADIUS * AP_MAG_RADIUS)")
         sqlLine.group("apRadius",         "AP_MAG_RADIUS * abs(PLTSCALE)")
         sqlLine.group("kronFlux",         "KRON_FLUX / " + expTimeString)
Index: /trunk/ippToPsps/jython/diffbatch.py
===================================================================
--- /trunk/ippToPsps/jython/diffbatch.py	(revision 38953)
+++ /trunk/ippToPsps/jython/diffbatch.py	(revision 38954)
@@ -321,5 +321,5 @@
             sqlLine.group("DapFlux",          "AP_FLUX / " + expTimeString)
             sqlLine.group("DapFluxErr",       "AP_FLUX_SIG / " + expTimeString)
-#           sqlLine.group("DapFillF",         "AP_NPIX / (3.14159265359 * POW(AP_MAG_RADIUS - 0.5, 2))")
+#           sqlLine.group("DapFillF",         "AP_NPIX / (3.14159265359 * AP_MAG_RADIUS * AP_MAG_RADIUS)")
 #       sqlLine.group("DapRadius",        "AP_MAG_RADIUS")
         sqlLine.group("DkronFlux",        "KRON_FLUX / " + expTimeString)
Index: /trunk/ippToPsps/jython/forcedwarpbatch.py
===================================================================
--- /trunk/ippToPsps/jython/forcedwarpbatch.py	(revision 38953)
+++ /trunk/ippToPsps/jython/forcedwarpbatch.py	(revision 38954)
@@ -400,5 +400,5 @@
         sqlLine.group("FapFlux",           "AP_FLUX / " + expTimeString)
         sqlLine.group("FapFluxErr",        "AP_FLUX_SIG / " + expTimeString)
-        sqlLine.group("FapFillF",          "AP_NPIX / (3.14159265359 * POW(AP_MAG_RADIUS - 0.5, 2))")
+        sqlLine.group("FapFillF",          "AP_NPIX / (3.14159265359 * AP_MAG_RADIUS * AP_MAG_RADIUS)")
         sqlLine.group("FapRadius",         "AP_MAG_RADIUS")
         sqlLine.group("FkronFlux",         "KRON_FLUX / " + expTimeString)
Index: /trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- /trunk/ippToPsps/jython/stackbatch.py	(revision 38953)
+++ /trunk/ippToPsps/jython/stackbatch.py	(revision 38954)
@@ -261,7 +261,9 @@
         zpErr   = self.getKeyFloat(header, "%.8f", 'ZPT_ERR')
 
+        # zp correction should comes from DVO (unless image is not in DVO)
         zpImage = self.scratchDb.getImageZeroPoint(stackID)
-
-        # XXX zp correction should come from DVO
+        if zpImage < 0.0:
+            zpImage = zp
+
         detectionThreshold = detectionThreshold + zpImage - 2.5 * math.log10(expTime)
         
@@ -476,5 +478,5 @@
             sqlLine.group("a."+filter+"momentYY",      "b.MOMENTS_YY * PLTSCALE * PLTSCALE")
             sqlLine.group("a."+filter+"momentR1",      "b.MOMENTS_R1 * b.PLTSCALE")
-            sqlLine.group("a."+filter+"momentRH",      "b.MOMENTS_RH * b.PLTSCALE")
+            sqlLine.group("a."+filter+"momentRH",      "b.MOMENTS_RH * sqrt(b.PLTSCALE)")
             sqlLine.group("a."+filter+"PSFFlux",       "b.PSF_INST_FLUX / " + expTimeString)
             sqlLine.group("a."+filter+"PSFFluxErr",    "b.PSF_INST_FLUX_SIG / " + expTimeString)
@@ -483,5 +485,5 @@
             sqlLine.group("a."+filter+"KronFlux",      "b.KRON_FLUX / " + expTimeString)
             sqlLine.group("a."+filter+"KronFluxErr",   "b.KRON_FLUX_ERR / " + expTimeString)
-            sqlLine.group("a."+filter+"ApFillFac",     "b.AP_NPIX / (3.14159265359 * POW(b.AP_MAG_RADIUS - 0.5, 2))")
+            sqlLine.group("a."+filter+"ApFillFac",     "b.AP_NPIX / (3.14159265359 * b.AP_MAG_RADIUS * b.AP_MAG_RADIUS)")
             sqlLine.group("a."+filter+"ApRadius",      "b.AP_MAG_RADIUS")
             sqlLine.group("a."+filter+"KronRad",       "b.MOMENTS_R1 * 2.5 * b.PLTSCALE")
@@ -662,7 +664,7 @@
         sqlLine.group("a." + filter + model + "Phi",       "DEGREES(b.EXT_THETA)")
 
-        sqlLine.group("a." + filter + model + "RadiusErr", "b.EXT_WIDTH_MAJ_ERR") # these are not correctly defined.
-        sqlLine.group("a." + filter + model + "AbErr",     "b.EXT_WIDTH_MIN_ERR") # these are not correctly defined.
-        sqlLine.group("a." + filter + model + "PhiErr",    "b.EXT_THETA_ERR") # these are not correctly defined.
+        sqlLine.group("a." + filter + model + "RadiusErr", "b.EXT_WIDTH_MAJ_ERR")
+        sqlLine.group("a." + filter + model + "AbErr",     "b.EXT_WIDTH_MIN_ERR")
+        sqlLine.group("a." + filter + model + "PhiErr",    "DEGREES(b.EXT_THETA_ERR)")
 
         sqlLine.group("a." + filter + model + "Chisq",     "b.EXT_CHISQ / b.EXT_NDOF")
@@ -703,5 +705,9 @@
         # StackObjectAttributes, this is probably faster using that table:
         sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
-        sqlLine.group("a." + filter + model + "Mag",       "a." + filter + model + "Mag + b.zp")
+
+        sqlLine.group("a." + filter + model + "Mag",       "a." + filter + model + "Mag       + b.zp")
+        sqlLine.group("a." + filter + model + "Radius",    "a." + filter + model + "Radius    * b.PLTSCALE")
+        sqlLine.group("a." + filter + model + "RadiusErr", "a." + filter + model + "RadiusErr * b.PLTSCALE")
+
         sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
 
@@ -834,5 +840,5 @@
         sqlLine.group("a." + filter + "petRadiusErr", "b.PETRO_RADIUS_ERR")
         sqlLine.group("a." + filter + "petMag",       "b.PETRO_MAG - " + hdrZP)  
-        sqlLine.group("a." + filter + "petMagErr",    "1.0 / b.PETRO_MAG_ERR")  
+        sqlLine.group("a." + filter + "petMagErr",    "1.0 / b.PETRO_MAG_ERR")  # still inverted? (yes)
         sqlLine.group("a." + filter + "petR50",       "b.PETRO_RADIUS_50")
         sqlLine.group("a." + filter + "petR50Err",    "b.PETRO_RADIUS_50_ERR")
@@ -850,5 +856,14 @@
         # modify petMag to apply the zero point
         sqlLine = sqlUtility("UPDATE " + tablename + " AS a, " + self.scratchDb.dvoDetectionTable + " as b SET")
-        sqlLine.group("a." + filter + "petMag",       "a." + filter + "petMag + b.zp")
+
+        sqlLine.group("a." + filter + "petMag",       "a." + filter + "petMag    + b.zp")
+
+        sqlLine.group("a." + filter + "petRadius",    "a." + filter + "petRadius * b.PLTSCALE")
+        sqlLine.group("a." + filter + "petRadiusErr", "a." + filter + "petRadius * b.PLTSCALE")
+        sqlLine.group("a." + filter + "petR50",       "a." + filter + "petR50    * b.PLTSCALE")
+        sqlLine.group("a." + filter + "petR50Err",    "a." + filter + "petR50Err * b.PLTSCALE")
+        sqlLine.group("a." + filter + "petR90",       "a." + filter + "petR90    * b.PLTSCALE")
+        sqlLine.group("a." + filter + "petR90Err",    "a." + filter + "petR90Err * b.PLTSCALE")
+
         sql = sqlLine.makeEquals("WHERE a.objID = b.objID AND a." + filter + "ippDetectID = b.ippDetectID AND b.imageID = " + str(imageID))
 
