Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 38237)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 38290)
@@ -307,8 +307,8 @@
     Populates the ImageDetEffMeta table for this OTA
     '''
-    def populateImageDetEffMetaTable(self, ota, header):
+    def populateImageDetEffMetaTablePart1(self, ota, header):
         ippTableName = ota + "_deteff"
         tableName = "ImageDetEffMeta_" + ota
-
+        self.scratchDb.dropTable(tableName)
         # we drop the table before calling this functoin so it is not left behind on failure
         sql = "CREATE TABLE " + tableName + " LIKE ImageDetEffMeta"
@@ -323,5 +323,5 @@
 
         sqlLine.group("frameID",          str(self.expID))
-        sqlLine.group("magref",           self.getKeyFloat(header,"%.8f","MAGREF"))
+        sqlLine.group("magref",           self.getKeyFloat(header,"%.8f","DETEFF.MAGREF"))
         sql = sqlLine.make(") VALUES ( ", ")")
                       
@@ -337,21 +337,45 @@
 
         # for loop
+
+    '''
+    Populates the ImageDetEffMeta table for this OTA
+    '''
+    def populateImageDetEffMetaTablePart2(self, ota):
+        ippTableName = ota + "_deteff"
+        tableName = "ImageDetEffMeta_" + ota
+
+              # ok, this is a bit tricky - Ideally I just want this all in one table, however, the way the table is layed out is 90 degrees from how I want it.
+        # the steps out of this mess are as follows:
+        # give an index to XYxy_deteff (already done, called table_index)
+        # do a loop to grab the 5 colums and fill them
+
+        # for loop
         for i in xrange(1, 14):
-                      stringint = str(i)
-                      stringint.rjust(2, '0')
-                      sqlLine = sqlUtility("INSERT INTO " + tableName + "(")
-                      sqlLine.group("offset"+stringint, "OFFSET")
-                      sqlLine.group("counts"+stringint, "COUNTS")
-                      sqlLine.group("diffMean"+stringint, "DIFF.MEAN")
-                      sqlLine.group("diffStdev01"+stringint, "DIFF.STDEV")
-                      sqlLine.group("errMean01"+stringing, "ERR.MEAN")
-                      sql = sqlLine.makeRaw(") SELECT ", "FROM " + ippTableName + " WHERE table_index = " + str(i))
-                      try: self.scratchDb.execute(sql)
-                      except:
+                       stringint = str(i)
+                       if i < 10:
+                          stringint = '0'+str(i)
+      
+#                      stringint.rjust(2, '0')
+                       sql = "UPDATE " +tableName+ " , " + ippTableName + " SET   \
+                             offset"+stringint + " = OFFSET  \
+                             ,counts" +stringint + " = COUNTS \
+                             ,diffMean" + stringint + " = DIFF_MEAN \
+                             ,diffStdev" + stringint + " = DIFF_STDEV \
+                             ,errMean" + stringint + " = ERR_MEAN \
+                             WHERE table_index = " + str(i)   
+ 
+#                      sqlLine = sqlUtility("UPDATE " + tableName + "," + ippTableName " SET ")
+#                      sqlLine.group("offset ="+stringint, "OFFSET")
+#                      sqlLine.group(",counts ="+stringint, "COUNTS")
+#                      sqlLine.group(",diffMean ="+stringint, "DIFF_MEAN")
+#                      sqlLine.group(",diffStdev ="+stringint, "DIFF_STDEV")
+#                      sqlLine.group(",errMean ="+stringint, "ERR_MEAN")
+#                      sql = sqlLine.makeRaw(" SELECT ", "FROM " + ippTableName + " WHERE table_index = " + str(i) + " and frameID = " + str(self.expID))
+
+                       try: self.scratchDb.execute(sql)
+                       except:
                           self.logger.errorPair('failed sql: ', sql)
-                      raise
-        
-        
-                      
+                          raise
+               
 
         
@@ -405,5 +429,6 @@
             sqlLine.group("posAngle",        "-999")                                      
             sqlLine.group("raErr",           "X_PSF_SIG * 0.257") 
-            sqlLine.group("decErr",          "Y_PSF_SIG * 0.257") 
+            sqlLine.group("decErr",          "Y_PSF_SIG * 0.257")
+        sqlLine.group("extNSigma","EXT_NSIGMA")    
         sqlLine.group("psfFlux",         "PSF_INST_FLUX / " + extTimeString)
         sqlLine.group("psfFluxErr",      "PSF_INST_FLUX_SIG / " + extTimeString)
@@ -561,5 +586,5 @@
         self.updateImageID("ImageMeta_" + chipname, x, y) 
 
-        self.populateImageDetEffTable(chipname, header)
+        self.populateImageDetEffMetaTablePart1(chipname, header)
         self.updateImageID("ImageDetEffMeta_" + chipname, x, y)
         
@@ -818,4 +843,7 @@
                     self.logger.error("fatal problem for exposure, skipping")
                     return False
+                                
+                self.populateImageDetEffMetaTablePart2(ota)
+
 
         if "Chip" in self.imageIDs:
@@ -925,4 +953,5 @@
         
         regex = ".*.psf"
+    
         if False and self.config.test and self.config.camera == "gpc1":
             regex = "XY01.psf"
@@ -937,4 +966,9 @@
             columns = "IPP_IDET X_PSF Y_PSF X_PSF_SIG Y_PSF_SIG POSANGLE PLTSCALE PSF_INST_FLUX PSF_INST_FLUX_SIG PSF_FWHM_MAJ PSF_FWHM_MIN PSF_THETA PSF_CORE PSF_QF PSF_QF_PERFECT PSF_CHISQ EXT_NSIGMA MOMENTS_XX MOMENTS_XY MOMENTS_YY MOMENTS_R1 MOMENTS_RH MOMENTS_M3C MOMENTS_M3S MOMENTS_M4C MOMENTS_M4S AP_FLUX AP_FLUX_SIG AP_NPIX AP_MAG_RADIUS KRON_FLUX KRON_FLUX_ERR SKY SKY_SIGMA FLAGS FLAGS2"
 
+            #### crap crap crap
+
+        regex = ".*"
+        columns = "*"
+
         return super(DetectionBatch, self).importIppTables(columns, regex)
 
