Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 38095)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 38358)
@@ -169,7 +169,7 @@
 
        self.dropTableVerbose("StackApFlx")
-       self.dropTableVerbose("StackApFlxEGUnc")
-       self.dropTableVerbose("StackApFlxEGCon6")
-       self.dropTableVerbose("StackApFlxEGCon8")
+       self.dropTableVerbose("StackApFlxExGalUnc")
+       self.dropTableVerbose("StackApFlxExGalCon6")
+       self.dropTableVerbose("StackApFlxExGalCon8")
 
        self.dropTableVerbose("StackPetrosian")
@@ -360,6 +360,6 @@
             sqlLine.group("a."+filter+"raErr",         "b.X_PSF_SIG * b.PLTSCALE")
             sqlLine.group("a."+filter+"decErr",        "b.Y_PSF_SIG * b.PLTSCALE")
-            sqlLine.group("a."+filter+"sky",           "b.SKY / " + str(exptime))
-            sqlLine.group("a."+filter+"skyErr",        "b.SKY_SIGMA / " + str(exptime))
+#            sqlLine.group("a."+filter+"sky",           "b.SKY / " + str(exptime))
+#            sqlLine.group("a."+filter+"skyErr",        "b.SKY_SIGMA / " + str(exptime))
             sqlLine.group("a."+filter+"infoFlag",      "b.FLAGS")
             sqlLine.group("a."+filter+"infoFlag2",     "b.FLAGS2 | a."+filter+"infoFlag2")
@@ -451,5 +451,6 @@
             sqlLine.group("a."+filter+"PlateScale",    "b.PLTSCALE")
             sqlLine.group("a."+filter+"ExtNSigma",     "b.EXT_NSIGMA")
-
+            sqlLine.group("a."+filter+"sky",           "b.SKY / " + str(exptime))
+            sqlLine.group("a."+filter+"skyErr",        "b.SKY_SIGMA / " + str(exptime))
             sql = sqlLine.makeEquals("WHERE a." + filter + "ippDetectID = b.IPP_IDET")
 
@@ -484,10 +485,78 @@
     '''
     def populateStackModelFitExtra(self):
+        tablename = "StackModelFitExtra"
 
         self.logger.infoPair("Procesing table", "StackModelFitExtra")
         self.insertDvoIDs("StackModelFitExtra", "StackObjectThin")
+        self.scratchDb.createIndex(tablename, "objID") 
 
         # if we are going to add a key, do it here so it is useful
         # self.scratchDb.createIndex(tablename, "objID") 
+
+        #objid
+        #uniquepsps id
+        # ippobjid
+        # randomstackobjid
+        # stackdetectrowid
+        # primarydetection
+        #bestdetection
+
+        #g / r / i /z / y
+
+        self.logger.infoPair("inserting filter dependent cmf items into", tablename)
+        for filter in self.filters:
+            self.logger.infoPair("filter", filter)
+
+            stackID = self.stackIDs[filter]
+            self.logger.infoPair(filter + "stackID = ", stackID)
+
+            if stackID <= 0:  
+                self.logger.infoPair("no stack data for filter" , filter) 
+                continue
+
+            header = self.headerSet[filter]
+            exptime = self.getKeyFloat(header, "%.5f", "EXPTIME")
+
+            # insert all the detections
+            sqlLine = sqlUtility("UPDATE " + tablename + " AS a , " + filter + "SkyChip_xsrc AS b SET")
+
+            sqlLine.group("a."+filter+"haveData",      "'1'")
+            sqlLine.group("a."+filter+"S2",          "b.G_S2")
+            sqlLine.group("a."+filter+"logRT",          "b.G_RT")
+            sqlLine.group("a."+filter+"logRA",          "b.G_RA")
+           # sqlLine.group("a."+filter+"logC",          "b.G_C")
+            sqlLine.group("a."+filter+"logA",          "b.G_A")
+
+            sqlLine.group("a."+filter+"bumpy",          "b.G_BUMPY")
+            sqlLine.group("a."+filter+"halfLightRad",          "b.HALF_LIGHT_RADIUS")
+            sql = sqlLine.makeEquals("WHERE a." + filter + "ippDetectID = b.IPP_IDET")
+
+            try:
+                self.scratchDb.execute(sql)
+            except:
+                self.logger.errorPair('failed sql',sql)
+                raise
+
+        self.deleteRowsWithNoStackData(tablename)
+        self.tablesToExport.append(tablename)
+
+
+
+        # gippdetectic
+        # gstackmeta
+        # gS2
+        # glogRT
+        # glogRA
+        # glogC
+        # glogA
+        # gbumpy
+        # ghalfLightRad
+
+
+
+
+
+
+
 
         # currently, none of the fields defined by the table are generated
@@ -735,7 +804,7 @@
     Populates the StackApFlxEG table
     '''
-    def populateStackApFlxEG(self, version):
-
-        tablename = "StackApFlxEG" + version
+    def populateStackApFlxExGal(self, version):
+
+        tablename = "StackApFlxExGal" + version
 
         if self.config.camera == "simtest":
@@ -794,8 +863,9 @@
             if radius < minRadius: continue
             if radius > maxRadius: continue
-            sqlLine.group(filter + prefix + "flxR" + str(radius),          "-999")
-            sqlLine.group(filter + prefix + "flxR" + str(radius) + "Err",  "-999")
-            sqlLine.group(filter + prefix + "flxR" + str(radius) + "Std",  "-999")
-            sqlLine.group(filter + prefix + "flxR" + str(radius) + "Fill", "-999")
+            pspsRadius = radius + 2
+            sqlLine.group(filter + prefix + "flxR" + str(pspsRadius),          "-999")
+            sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Err",  "-999")
+            sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Std",  "-999")
+            sqlLine.group(filter + prefix + "flxR" + str(pspsRadius) + "Fill", "-999")
 
         sql = sqlLine.makeEquals("")
@@ -1118,7 +1188,7 @@
             self.populateStackApFlx()
 
-            self.populateStackApFlxEG("Unc")
-            self.populateStackApFlxEG("Con6")
-            self.populateStackApFlxEG("Con8")
+            self.populateStackApFlxExGal("Unc")
+            self.populateStackApFlxExGal("Con6")
+            self.populateStackApFlxExGal("Con8")
 
         # delete rows with no content. for the other tables, this is done in 
