Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 34615)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 34630)
@@ -197,6 +197,6 @@
         sql = "UPDATE StackModelFit AS a, SkyChip_xfit AS b SET \
         "+model+"Radius=b.EXT_WIDTH_MAJ,  \
-        "+model+"Flux=b.EXT_INST_MAG,  \
-        "+model+"FluxErr=b.EXT_INST_MAG_SIG,  \
+        "+model+"Flux=POW(10, -0.4 * b.EXT_INST_MAG) " + str(self.expTime) " ,  \
+        "+model+"FluxErr=ABS(b.EXT_INST_MAG_SIG) * POW(10, -0.4 * b.EXT_INST_MAG) " + str(self.expTime) " / 1.085736, \
         "+model+"Ab=b.EXT_WIDTH_MAJ/b.EXT_WIDTH_MIN, \
         "+model+"Phi=b.EXT_THETA,  \
@@ -230,6 +230,4 @@
         "+modelLong+"Covar77=b.EXT_COVAR_06_06   \
         WHERE a.ippDetectID=b.IPP_IDET AND b.MODEL_TYPE = '"+ippModelType+"'"
-
-        #SA10 convert mag to flux in calculation above
 
         self.scratchDb.execute(sql)
@@ -369,6 +367,6 @@
                ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + str(self.expTime) + ")) / 1.085736) \
                ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + str(self.expTime) + " \
-               ,SKY \
-               ,SKY_SIGMA \
+               ,SKY / " + str(self.expTime) + " \
+               ,SKY_SIGMA / " + str(self.expTime) + " \
                ,EXT_NSIGMA \
                ,PSF_MAJOR \
@@ -388,5 +386,5 @@
                ,MOMENTS_R1 \
                ,MOMENTS_RH \
-               ,AP_MAG \
+               ,POW(10.0, (-0.4*AP_MAG) / " + str(self.expTime) + " \
                , NULL \
                ,KRON_FLUX / " + str(self.expTime) + " \
@@ -398,8 +396,4 @@
                ," + self.historyModNum + " \
                FROM SkyChip_psf"
-
-               #SA10 to do
-               # put in correct formula for apFlux, psfFlux, psfLikelihood, sgsep
-               # need correct units of anything in Flux
         self.scratchDb.execute(sql)
         
@@ -481,6 +475,6 @@
         petRadius=b.PETRO_RADIUS \
         ,petRadiusErr=b.PETRO_RADIUS_ERR \
-        ,petFlux=b.PETRO_MAG \
-        ,petFluxErr=b.PETRO_MAG_ERR \
+        ,petFlux=POW(10.0, -0.4 * b.PETRO_MAG) /" + str(self.expTime) + " \
+        ,petFluxErr=ABS((b.PETRO_MAG_ERR * POW(10.0, (-0.4*b.petroMag))) / " + str(self.expTime) + " / 1.085736  \
         ,petR50=b.PETRO_RADIUS_50 \
         ,petR50Err=b.PETRO_RADIUS_50_ERR \
@@ -489,5 +483,4 @@
         ,petCf=b.PETRO_FILL \
         WHERE a.ippDetectID=b.IPP_IDET"
-        #SA10 Put correct calculation for PetFlux
         self.scratchDb.execute(sql)
 
@@ -620,8 +613,15 @@
         self.logger.info(sql)
         self.scratchDb.execute(sql)
-        #SA10 TODO
-        # insert ra/dec/calstuff into Table
-        # heather discovered dec is called 'dec_'
-        sql = "UPDATE " + tableName + " SET ra = -999, dec_ =-999, raErr = -999, decErr = -999, zp = -999, zpErr = -999, expTime = -999, airMass = -999"
+        # insert calibration information from dvoDetections into the Table
+        sql = "UPDATE " + tableName + " AS a, "  + self.scratchDb.dvoDetectionTable + " AS b \
+            SET a.ra = b.ra, \
+            a.dec_ = b.dec_, \
+            a.raErr = b.raErr, \
+            a.decErr = b.decErr, \
+            a.zp = b.zp, \
+            a.zpErr = b.zpErr, \
+            a.expTime = b.expTime, \
+            a.airMass = b.airMass   \
+            WHERE a.objID = b.objID AND a.detectID = b.detectID"
         self.logger.info(sql)
         self.scratchDb.execute(sql)
