Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 38227)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 38228)
@@ -304,4 +304,55 @@
         self.scratchDb.replaceNullsInThisColumn(tableName, "polyOrder", "0")
 
+    '''
+    Populates the ImageDetEffMeta table for this OTA
+    '''
+    def populateImageDetEffMetaTable(self, ota, header):
+        ippTableName = ota + "_deteff"
+        tableName = "ImageDetEffMeta_" + ota
+
+        # we drop the table before calling this functoin so it is not left behind on failure
+        sql = "CREATE TABLE " + tableName + " LIKE ImageDetEffMeta"
+        try: self.scratchDb.execute(sql)
+        except: pass
+
+        if (ota[0:2] == "XY"): ccdID = ota[2:4]
+        else: ccdID = 0
+
+        # insert image metadata into table
+        sqlLine = sqlUtility("INSERT INTO " + tableName + "(")
+
+        sqlLine.group("frameID",          str(self.expID))
+        sqlLine.group("magref",           self.getKeyFloat(header,"%.8f","MAGREF")
+        sql = sqlLine.make(") VALUES ( ", ")")
+        try: self.scratchDb.execute(sql)
+        except:
+            self.logger.errorPair('failed sql: ', sql)
+            raise
+
+        # 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:
+                          self.logger.errorPair('failed sql: ', sql)
+                      raise
+        
+        
+                      
+
+        
     '''
     Populates the Detection table for this OTA
@@ -508,5 +559,8 @@
         self.populateImageMetaTable(chipname, header)
         self.updateImageID("ImageMeta_" + chipname, x, y) 
-            
+
+        self.populateImageDetEffTable(chipname, header)
+        self.updateImageID("ImageDetEffMeta_" + chipname, x, y)
+        
         return True
 
@@ -713,4 +767,7 @@
         self.logger.info("export ImageMeta")
 
+        self.tablesToExport.append("ImageDetEffMeta_" + chipname)
+        self.logger.info("export ImageDetEffMeta")
+        
         self.tablesToExport.append("Detection_" + chipname)
         self.logger.info("export Detection")
