Index: trunk/ippToPsps/jython/forcedwarpbatch.py
===================================================================
--- trunk/ippToPsps/jython/forcedwarpbatch.py	(revision 39061)
+++ trunk/ippToPsps/jython/forcedwarpbatch.py	(revision 39062)
@@ -57,9 +57,4 @@
                "FW",
                None) 
-
-       # gpc1Db.getForcedWarpStageSmf(forcedWarpID)
-       # there is a funny problem with order here: we need to open the file first to read the header to get 
-       # to skycell ID
-       # forcedWarpID = self.forcedWarpID   
 
        # make a set of lists (needs to be outside of the loop
@@ -99,5 +94,5 @@
            self.logger.infoPair("index",num)
            self.logger.infoPair("forcedWarpID", forcedWarpID)
-           self.logger.infoPair("getting the fits file for add_id",forcedWarpID)
+           self.logger.infoPair("getting the fits file for add_id", forcedWarpID)
            self.fits[num] = gpc1Db.getForcedWarpStageCmf(skychunk.dvoLabel, int(forcedWarpID))
            
@@ -169,54 +164,35 @@
            self.logger.infoPair("projection cell found ",self.projectionID[num])
            self.logger.infoPair("skycell found", self.skycellID[num])
-           self.dropTableVerbose("ForcedWarpMeasurement"+"_"+str(forcedWarpID))
-           self.dropTableVerbose("ForcedWarpMasked"+"_"+str(forcedWarpID))
-           self.dropTableVerbose("ForcedWarpExtended"+"_"+str(forcedWarpID))
-           self.dropTableVerbose("ForcedWarpMeta"+"_"+str(forcedWarpID))
-           self.dropTableVerbose("ForcedWarpToImage"+"_"+str(forcedWarpID))
-           self.dropTableVerbose("ForcedWarpLensing"+"_"+str(forcedWarpID))
+           self.dropTableVerbose("ForcedWarpMeasurement"+"_"+str(num))
+           self.dropTableVerbose("ForcedWarpMasked"+"_"+str(num))
+           self.dropTableVerbose("ForcedWarpExtended"+"_"+str(num))
+           self.dropTableVerbose("ForcedWarpMeta"+"_"+str(num))
+           self.dropTableVerbose("ForcedWarpToImage"+"_"+str(num))
+           self.dropTableVerbose("ForcedWarpLensing"+"_"+str(num))
            if not self.config.retry:
-               self.scratchDb.dropTable("ForcedWarpMeasurement"+"_"+str(forcedWarpID))
-               self.scratchDb.dropTable("ForcedWarpMasked"+"_"+str(forcedWarpID))
-               self.scratchDb.dropTable("ForcedWarpExtended"+"_"+str(forcedWarpID))
-               self.scratchDb.dropTable("ForcedWarpMeta"+"_"+str(forcedWarpID))
-               self.scratchDb.dropTable("ForcedWarpToImage"+"_"+str(forcedWarpID))
-               self.scratchDb.dropTable("ForcedWarpLensing"+"_"+str(forcedWarpID))
-       # get a few primary header values. if in test mode, then use defaults
-               # create the tables
-
-           # XXX why are these deleted?
-           sql = "CREATE TABLE  ForcedWarpMeasurement_" + str(forcedWarpID) + " like ForcedWarpMeasurement"
-           print sql
-           #try: self.scratchDb.execute(sql)
-           #except: raise
-           sql = "CREATE TABLE  ForcedWarpExtended_" + str(forcedWarpID) + " like ForcedWarpExtended"
-           #try: self.scratchDb.execute(sql)
-           #except: raise
-           sql = "CREATE TABLE  ForcedWarpMeta_" + str(forcedWarpID) + " like ForcedWarpMeta"
-           #try: self.scratchDb.execute(sql)
-           #except: raise
-           sql = "CREATE TABLE  ForcedWarpToImage_" + str(forcedWarpID) + " like ForcedWarpToImage"
-           #try: self.scratchDb.execute(sql)
-           #except: raise
-           sql = "CREATE TABLE  ForcedWarpLensing_" + str(forcedWarpID) + " like ForcedWarpLensing"
-           #try: self.scratchDb.execute(sql)
-           #except: raise
+               self.scratchDb.dropTable("ForcedWarpMeasurement"+"_"+str(num))
+               self.scratchDb.dropTable("ForcedWarpMasked"+"_"+str(num))
+               self.scratchDb.dropTable("ForcedWarpExtended"+"_"+str(num))
+               self.scratchDb.dropTable("ForcedWarpMeta"+"_"+str(num))
+               self.scratchDb.dropTable("ForcedWarpToImage"+"_"+str(num))
+               self.scratchDb.dropTable("ForcedWarpLensing"+"_"+str(num))
+
+           # get a few primary header values. if in test mode, then use defaults
 
            ## MEH md5sum test
 	   self.md5sum[num] = self.fits[num].getMd5sum()
 
-           self.logger.infoPair("calculating ObsTime","ok")
            # MJD-OBS is the exposure start, EXTIME / 172800 = (EXPTIME sec / 84600 sec/day) / 2
-
            self.obsTime[num] = float(self.header[num]['MJD-OBS']) + (float(self.expTime[num]) / 172800.0)
-
            self.logger.infoPair("obstime",self.obsTime[num])
+
            self.filterID[num] = self.scratchDb.getFilterID(self.filterName[num][0])
            self.logger.infoPair("filterID is ",self.filterID[num])
-           self.logger.infoPair("inserting basics into ","ForcedWarpMeta"+"_"+forcedWarpID)
-           
+
+           self.logger.infoPair("inserting basics into ", "ipptopsps.forcedwarp")
            self.ippToPspsDb.insertForcedWarpMeta( int(self.batchID), int(self.expID[num]), self.filterName[num][0])       
 
            num=num+1
+
        # create an output filename, which is {expID}.FITS
        self.outputFitsFile = "%08d.FITS" % self.id
@@ -231,5 +207,5 @@
     def populateForcedWarpMeta(self,num):
         forcedWarpID = self.number[num]
-        tableName = "ForcedWarpMeta_" + forcedWarpID
+        tableName = "ForcedWarpMeta_" + str(num)
 
         self.logger.infoPair("Processing table", tableName)
@@ -330,29 +306,21 @@
         forcedwarpID = self.number[num]
         self.logger.infoPair("Procesing table", "ForcedWarpToImage")
-        sql = "CREATE TABLE ForcedWarpToImage_"+forcedwarpID+" LIKE ForcedWarpToImage"
-        try: self.scratchDb.execute(sql)
-        except: pass
-
-        #forcedwarpID = self.forcedWarpID
+
+        tableName = "ForcedWarpToImage_" + str(num)
+
+        sql = "CREATE TABLE " + tableName + " LIKE ForcedWarpToImage"
+        self.scratchDb.execute(sql)
+
         if forcedwarpID > 0:
-    
+
                 imageIDs = self.gpc1Db.getImageIDsForThisForcedWarpID(forcedwarpID)
 
                 for imageID in imageIDs:
 
-                    sql = "INSERT INTO ForcedWarpToImage_"+str(forcedwarpID)+" (forcedwarpID, imageID) \
-                   VALUES (\
-                   " + str(forcedwarpID) + ", " + imageID + ")"
+                    sql = "INSERT INTO " + tableName + " (forcedwarpID, imageID) VALUES ( " + str(forcedwarpID) + ", " + imageID + ")"
                     try: self.scratchDb.execute(sql)
                     except:
                        self.logger.infoPair("can't execute sql",sql)
                        raise
-                    # now update StackMeta with correct number of inputs
-
-        #self.tablesToExport.append("ForcedWarpToImage")
-
-
-
-
 
     '''
@@ -361,18 +329,15 @@
     def populateForcedWarpMeasurement(self,num):
         forcedWarpID = self.number[num]
-        pspsTableName = "ForcedWarpMeasurement_"+forcedWarpID
-        ippTableName = "SkyChip_psf_"+forcedWarpID
-
-        sql = "CREATE TABLE ForcedWarpMeasurement_"+forcedWarpID+" LIKE ForcedWarpMeasurement"
-        try: self.scratchDb.execute(sql)
-        except: pass
-
-        self.logger.infoPair("Procesing table", "ForcedWarpMeasurement_"+forcedWarpID)
-
-        BEFORE = self.scratchDb.getRowCount(ippTableName)
+        pspsTableName = "ForcedWarpMeasurement_" + str(num)
+        maskTableName = "ForcedWarpMasked_" + str(num)
+        ippTableName = "SkyChip_psf_" + str(num)
+
+        sql = "CREATE TABLE " + pspsTableName + " LIKE ForcedWarpMeasurement"
+        self.scratchDb.execute(sql)
+
+        self.logger.infoPair("Procesing table", pspsTableName)
+
         expTimeString = str(self.expTime[num])
 
-#missing are zp, telluricExt, airmass (not easy to get ?)
-      
         sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
         sqlLine.group("ippDetectID",       "IPP_IDET")
@@ -401,5 +366,4 @@
         sqlLine.group("FpsfQfPerfect",     "PSF_QF_PERFECT")
         sqlLine.group("FpsfChiSq",         "PSF_CHISQ")
-#       sqlLine.group("FpsfLikelihood",    "psfLikelihood(EXT_NSIGMA)") -- deprecated in r38867 (not measured in FW cmfs)
         sqlLine.group("FmomentXX",         "MOMENTS_XX * PLTSCALE * PLTSCALE")
         sqlLine.group("FmomentXY",         "MOMENTS_XY * PLTSCALE * PLTSCALE")
@@ -429,9 +393,9 @@
         # insert the per-object data (IDs, random stack ID, processingVersion, etc)
         # self.selectDvoObjIDs()
-        self.logger.infoPair("inserting dvo info: find imageID","from externID")
+        self.logger.infoPair("inserting dvo info: find imageID", "from externID")
         imageID = self.scratchDb.getImageIDFromExternID(self.warpSkyFileID[num])
-        self.logger.infoPair("updating","forcedWarpMeasurement_"+forcedWarpID)
-
-        sqlLine = sqlUtility("UPDATE ForcedWarpMeasurement_"+forcedWarpID+" as a, " + self.scratchDb.dvoDetectionTable + " as b SET ")
+        self.logger.infoPair("updating", pspsTableName)
+
+        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, " + self.scratchDb.dvoDetectionTable + " as b SET ")
         sqlLine.group("a.objID",      "b.objID")
         sqlLine.group("a.detectID",   "b.detectID")
@@ -456,7 +420,7 @@
 
         self.logger.infoPair("need to cull"," nulls objid")
-        rowCountBefore = self.scratchDb.getRowCount("ForcedWarpMeasurement_"+forcedWarpID)
-        results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpMeasurement_"+forcedWarpID, "objID")
-        rowCountAfter =  self.scratchDb.getRowCount("ForcedWarpMeasurement_"+forcedWarpID)
+        rowCountBefore = self.scratchDb.getRowCount(pspsTableName)
+        results= self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "objID")
+        rowCountAfter =  self.scratchDb.getRowCount(pspsTableName)
         self.logger.infoPair("row count of ForcedWarpMeasurement", rowCountBefore)
         self.logger.infoPair("row count of ForcedWarpMeasurement after cull of null objID ", rowCountAfter)
@@ -465,18 +429,18 @@
             self.logger.infoPair ("skip this batch", "it is bad")
             return False
-#        self.generateRandomIDs()
-
-        self.logger.infoPair("Adding 'row' columns to", "ForcedWarpMeasurement_"+forcedWarpID)
-        self.scratchDb.addRowCountColumn("ForcedWarpMeasurement_"+forcedWarpID, "row")
-        self.logger.infoPair("Adding unique ids to", "ForcedWarpMeasurement_"+forcedWarpID)
-        self.generateUniquePspsIDs(num)
-        self.logger.infoPair("Dropping row column from", "ForcedWarpMeasurement_"+forcedWarpID+" table")
-        self.scratchDb.dropColumn("ForcedWarpMeasurement_"+forcedWarpID, "row")
+
+        self.logger.infoPair("Adding 'row' columns to", pspsTableName)
+        self.scratchDb.addRowCountColumn(pspsTableName, "row")
+
+        self.logger.infoPair("Adding unique ids to", pspsTableName)
+        self.generateUniquePspsIDs(tableName, num)
+
+        self.logger.infoPair("Dropping row column from", pspsTableName)
+        self.scratchDb.dropColumn(pspsTableName, "row")
 
         # now move the rows with no data to ForcedWarpMasked
-        self.logger.infoPair("Procesing table", "ForcedWarpMasked_"+forcedWarpID)
-        sql = "CREATE TABLE ForcedWarpMasked_"+forcedWarpID+" LIKE ForcedWarpMasked"
-        try: self.scratchDb.execute(sql)
-        except: pass
+        self.logger.infoPair("Procesing table", maskTableName)
+        sql = "CREATE TABLE " + maskTableName + " LIKE ForcedWarpMasked"
+        self.scratchDb.execute(sql)
 
         # This is the definition of a "masked measurement".
@@ -484,23 +448,21 @@
         maskedCondition = "FpsfQfPerfect < .0001 OR FpsfQfPerfect is NULL"
 
-        sql = "INSERT INTO ForcedWarpMasked_"+forcedWarpID+" \
-               SELECT objID, uniquePspsFWid, ippObjID, ippDetectID, filterID, surveyID, \
-                forcedSummaryID, forcedWarpID, randomWarpID, tessID, projectionID, \
-                skyCellID, dvoRegionID, obsTime \
-               FROM ForcedWarpMeasurement_"+forcedWarpID+" WHERE "+maskedCondition
-        try: self.scratchDb.execute(sql)
-        except: pass
-
-        sql = "DELETE FROM ForcedWarpMeasurement_"+forcedWarpID+" WHERE "+maskedCondition
-        try: self.scratchDb.execute(sql)
-        except: pass
+        sql  = "INSERT INTO " + maskTableName
+        sql += " SELECT objID, uniquePspsFWid, ippObjID, ippDetectID, filterID, surveyID," 
+        sql += " forcedSummaryID, forcedWarpID, randomWarpID, tessID, projectionID,"
+        sql += " skyCellID, dvoRegionID, obsTime"
+        sql += " FROM " + pspsTableName + " WHERE " + maskedCondition
+        self.scratchDb.execute(sql)
+
+        sql = "DELETE FROM " pspsTableName + " WHERE " + maskedCondition
+        self.scratchDb.execute(sql)
            
         # add indexes ForcedWarpMeasurement
-        self.scratchDb.createIndex("ForcedWarpMeasurement_"+forcedWarpID, "objID")
-        self.scratchDb.createIndex("ForcedWarpMeasurement_"+forcedWarpID, "ippDetectID")
+        self.scratchDb.createIndex(pspsTableName, "objID")
+        self.scratchDb.createIndex(pspsTableName, "ippDetectID")
 
         # add indexes ForcedWarpMasked
-        self.scratchDb.createIndex("ForcedWarpMasked_"+forcedWarpID, "objID")
-        self.scratchDb.createIndex("ForcedWarpMasked_"+forcedWarpID, "ippDetectID")
+        self.scratchDb.createIndex(maskTableName, "objID")
+        self.scratchDb.createIndex(maskTableName, "ippDetectID")
 
     '''
@@ -509,13 +471,13 @@
     def populateForcedWarpExtended(self,num):
         forcedWarpID = self.number[num]
-        pspsTableName = "ForcedWarpExtended_"+forcedWarpID
-        ippTableName = "SkyChip_xrad_"+forcedWarpID
-        sql = "CREATE TABLE ForcedWarpExtended_"+forcedWarpID+" LIKE ForcedWarpExtended"
-        try: self.scratchDb.execute(sql)
-        except: pass
-
-        #self.tablesToExport.append("ForcedWarpExtended")
-
-        #isert stuff from SkyChip_psf
+        pspsTableName = "ForcedWarpExtended_" + str(num)
+        ippTableName = "SkyChip_xrad_" + str(num)
+        fMeasTableName = "ForcedWarpMeasurement_" + str(num)
+
+        sql = "CREATE TABLE " + pspsTableName + " LIKE ForcedWarpExtended"
+        self.scratchDb.execute(sql)
+
+        # insert stuff from SkyChip_xrad
+        self.logger.infoPair("inserting data from", ippTableName)
         sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
         sqlLine.group("ippDetectID",     "IPP_IDET")
@@ -534,13 +496,9 @@
 
         sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName)
-
-        try: self.scratchDb.execute(sql)
-        except:
-            self.logger.errorPair("failed sql: ", sql)
-            raise
-
-        #insert the things from FOrcedWarpMeasurement
-        self.logger.infoPair("inserting objID,etc from","ForcedWarpMeasurement_"+forcedWarpID)
-        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, ForcedWarpMeasurement_"+forcedWarpID+" as b SET ")
+        self.scratchDb.execute(sql)
+
+        # insert the things from ForcedWarpMeasurement
+        self.logger.infoPair("adding objID, etc from", fMeasTableName)
+        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, " + fMeasTableName + " as b SET ")
         sqlLine.group("a.objID","b.objID")
         sqlLine.group("a.uniquePspsFWid","b.uniquePspsFWid")
@@ -555,34 +513,25 @@
         sqlLine.group("a.obsTime","b.obsTime")
         sql = sqlLine.makeEquals("Where a.ippDetectID = b.ippDetectID")
-        try: self.scratchDb.execute(sql)
-        except:
-            self.logger.errorPair("failed sql: ", sql)
-            raise
+        self.scratchDb.execute(sql)
         
-       # add in the psps unique ids from stuff
-        self.logger.infoPair("adding information from Skychip_xrad_"+forcedWarpID+" into","ForcedWarpExtended_"+forcedWarpID)
-        
-        # cull bad d
+        # cull bad entris
         self.logger.infoPair("need to cull"," nulls objid")
-        results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpExtended_"+forcedWarpID, "objID")
-        
-        self.scratchDb.createIndex("ForcedWarpExtended_"+forcedWarpID, "objID")
-               
-
-
-    '''                                                                                                                                                                  
-    Populates the ForcedWarpExtended table                                                                                                                               
+        results = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "objID")
+        self.scratchDb.createIndex(pspsTableName, "objID")
+
+    ''' 
+    Populates the ForcedWarpExtended table 
     '''
     def populateForcedWarpLensing(self, num):
-        forcedWarpID = self.number[num]
-        pspsTableName = "ForcedWarpLensing_"+forcedWarpID
-        ippTableName = "SkyChip_psf_"+forcedWarpID
-        sql = "CREATE TABLE ForcedWarpLensing_"+forcedWarpID+" LIKE ForcedWarpLensing"
-        try: self.scratchDb.execute(sql)
-        except: pass
-
-        #self.tablesToExport.append("ForcedWarpExtended")                                                                                                                
-
-        #isert stuff from SkyChip_psf                                                                                                                                    
+        forcedWarpID   = self.number[num]
+        ippTableName   = "SkyChip_psf_" + str(num)
+        pspsTableName  = "ForcedWarpLensing_" + str(num)
+        fMeasTableName = "ForcedWarpMeasurement_" + str(num)
+
+        sql = "CREATE TABLE " + pspsTableName + " LIKE ForcedWarpLensing"
+        self.scratchDb.execute(sql)
+
+        # insert stuff from SkyChip_psf 
+        self.logger.infoPair("adding information from " + ippTableName + " into", pspsTableName)
         sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (")
         sqlLine.group("ippDetectID",     "IPP_IDET")
@@ -609,14 +558,11 @@
         sqlLine.group("psfE1", "LENS_E1_PSF")
         sqlLine.group("psfE2", "LENS_E2_PSF")
+
         sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName)
-
-        try: self.scratchDb.execute(sql)
-        except:
-            self.logger.errorPair("failed sql: ", sql)
-            raise
-
-        #insert the things from FOrcedWarpMeasurement                                                                                                                    
-        self.logger.infoPair("inserting objID,etc from","ForcedWarpMeasurement_"+forcedWarpID)
-        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, ForcedWarpMeasurement_"+forcedWarpID+" as b SET ")
+        self.scratchDb.execute(sql)
+
+        # insert the things from ForcedWarpMeasurement 
+        self.logger.infoPair("inserting objID,etc from", fMeasTableName)
+        sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, " + fMeasTableName + " as b SET ")
         sqlLine.group("a.objID","b.objID")
         sqlLine.group("a.uniquePspsFWid","b.uniquePspsFWid")
@@ -630,20 +576,13 @@
         sqlLine.group("a.dvoRegionID","b.dvoRegionID")
         sqlLine.group("a.obsTime","b.obsTime")
+
         sql = sqlLine.makeEquals("Where a.ippDetectID = b.ippDetectID")
-        try: self.scratchDb.execute(sql)
-        except:
-            self.logger.errorPair("failed sql: ", sql)
-            raise
-
-       # add in the psps unique ids from stuff                                                                                                                           
-        self.logger.infoPair("adding information from Skychip_psf_"+forcedWarpID+" into","ForcedWarpLensing_"+forcedWarpID)
-
-        # cull bad d                                                                                                                                                     
+        self.scratchDb.execute(sql)
+
+        # cull bad entries
         self.logger.infoPair("need to cull"," nulls objid")
-        results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpLensing_"+forcedWarpID, "objID")
-
-        self.scratchDb.createIndex("ForcedWarpLensing_"+forcedWarpID, "objID")
-
-
+        results= self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "objID")
+
+        self.scratchDb.createIndex(pspsTableName, "objID")
 
     '''
@@ -656,35 +595,36 @@
         self.tablesToExport=[]
     
-        #this should be done
-        #number  = 0
-        #for forcedWarpID in self.forcedWarpIds: 
         for num in self.number:    
-            print "hawaht?"
             forcedWarpID = self.number[num]
-            self.logger.infoPair("Populating","ForcedWarpMeta_"+forcedWarpID)
+            myTable = "ForcedWarpMeta_" + str(num)
+            self.logger.infoPair("Populating", myTable)
             self.populateForcedWarpMeta(num)          
-            self.tablesToExport.append("ForcedWarpMeta_"+forcedWarpID)
+            self.tablesToExport.append(myTable)
             
-            self.logger.infoPair("Populating","ForcedWarpMeasurement_"+forcedWarpID)
+            myTable = "ForcedWarpMeasurement_" + str(num)
+            self.logger.infoPair("Populating", myTable)
             self.populateForcedWarpMeasurement(num)          
-            self.tablesToExport.append("ForcedWarpMeasurement_"+forcedWarpID)
-            self.tablesToExport.append("ForcedWarpMasked_"+forcedWarpID)
+            self.tablesToExport.append(myTable)
+
+            self.logger.infoPair("setting min/max objid from", myTable)
+            self.setMinMaxObjID([myTable])
+
+            # populateForcedWarpMeasurement also populates ForcedWarpMasked (from ForcedWarpMeasurement)
+            self.tablesToExport.append("ForcedWarpMasked_" + str(num))
             
-            self.logger.infoPair("Populating","ForcedWarpExtended_"+forcedWarpID)
+            myTable = "ForcedWarpExtended_" + str(num)
+            self.logger.infoPair("Populating", myTable)
             self.populateForcedWarpExtended(num)
-            self.tablesToExport.append("ForcedWarpExtended_"+forcedWarpID)
-
-            self.logger.infoPair("Populating","ForcedWarpLensing_"+forcedWarpID)
+            self.tablesToExport.append(myTable)
+
+            myTable = "ForcedWarpLensing_" + str(num)
+            self.logger.infoPair("Populating", myTable)
             self.populateForcedWarpLensing(num)
-            self.tablesToExport.append("ForcedWarpLensing_"+forcedWarpID)
-
-
-            self.logger.infoPair("Populating","ForcedWarpToImage_"+forcedWarpID)
+            self.tablesToExport.append(myTable)
+
+            myTable = "ForcedWarpToImage_" + str(num)
+            self.logger.infoPair("Populating", myTable)
             self.populateForcedWarpToImage(num)
-            self.tablesToExport.append("ForcedWarpToImage_"+forcedWarpID)             
-
-
-            self.logger.infoPair("setting min/max objid from","ForcedWarpMeasurement_"+forcedWarpID)
-            self.setMinMaxObjID(["ForcedWarpMeasurement_"+forcedWarpID])
+            self.tablesToExport.append(myTable)
             
             self.logger.infoPair("finishing","populatePspsTables")
@@ -730,5 +670,5 @@
         
             ## output table names need to have "_num" appended.  
-            fitsOptions  = "-tablesuffix _" + str(forcedWarpID)
+            fitsOptions  = "-tablesuffix _" + str(num)
 
             # this option is equivalent to the stilts "addcol table_index $0" call
@@ -750,12 +690,12 @@
 
             for table in tables:
-                myTable = table.name + "_" + str(forcedWarpID)
+                myTable = table.name + "_" + str(num)
                 count = count + 1
                       
                 self.tablesLoaded.append(myTable)
 
-            self.indexIppTables(forcedWarpID)
+            # after all tables are read for this forcedWarpID, then index the set
+            self.indexIppTables(num)
                       
-        # after all tables are read for this forcedWarpID, then index the set
         self.logger.infoPair("Done. Imported", "%d tables" % count)
         return True
@@ -765,4 +705,7 @@
     '''
     def importIppTablesStilts(self, columns="*", tableRE=""):
+
+        print "*** STILTS import is now deprecated ***"
+        os._exit(4)
 
         self.tablesLoaded = []
@@ -819,24 +762,11 @@
 
 
-    def generateRandomIDs(self,forcedWarpID):
-        sql = "UPDATE ForcedWarpMeasurement_"+forcedWarpID+" set randomWarpID = RAND("+str(self.batchID)+")"
-        try: 
-            self.scratchDb.execute(sql)
-        except:
-            self.logger.errorPair('failed sql',sql)
-            raise
-
-
     '''
     Updates table and generates pspsuniqueids
     '''
-
-    def generateUniquePspsIDs(self,num):
+    def generateUniquePspsIDs(self, tableName, num):
         
-        sql = "UPDATE ForcedWarpMeasurement_"+str(self.number[num])+" set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + ("+str(num)+"*1000000 ) + row)"
-        try: self.scratchDb.execute(sql)
-        except:
-           self.logger.errorPair('failed sql',sql)
-           raise
+        sql = "UPDATE " + tableName + " set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + ("+str(num)+"*1000000 ) + row)"
+        self.scratchDb.execute(sql)
 
     '''
@@ -869,39 +799,23 @@
     Applies indexes to the IPP tables
     '''
-    def indexIppTables(self,forcedWarpID):
-
-        self.logger.infoPair("Creating indexes on " + forcedWarpID, "IPP tables")
+    def indexIppTables(self,num):
+
+        self.logger.infoPair("Creating indexes on " + str(num), "IPP tables")
 
         # it probably should not be an error not to have one of these:
-        cmfTable = "SkyChip_psf_" + forcedWarpID
+        cmfTable = "SkyChip_psf_" + str(num)
         if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
 
-        cmfTable = "SkyChip_xfit_" + forcedWarpID
+        cmfTable = "SkyChip_xfit_" + str(num)
         if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
 
-        cmfTable = "SkyChip_xrad_" + forcedWarpID
+        cmfTable = "SkyChip_xrad_" + str(num)
         if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
 
-        cmfTable = "SkyChip_xsrc_" + forcedWarpID
+        cmfTable = "SkyChip_xsrc_" + str(num) 
         if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
 
-        cmfTable = "SkyChip_xgal_" + forcedWarpID
+        cmfTable = "SkyChip_xgal_" + str(num) 
         if cmfTable in self.tablesLoaded: self.scratchDb.createIndex(cmfTable,  "IPP_IDET")
 
-        ## self.scratchDb.createIndex("SkyChip_xfit_"+forcedWarpID, "IPP_IDET")
-        ## self.scratchDb.createIndex("SkyChip_xrad_"+forcedWarpID, "IPP_IDET")
-        ## self.scratchDb.createIndex("SkyChip_xsrc_"+forcedWarpID, "IPP_IDET")
-        ## self.scratchDb.createIndex("SkyChip_xgal_"+forcedWarpID, "IPP_IDET")
-
         return True
-
-    '''
-    Updates table and generates pspsuniqueids
-    '''
-
-    def updatePspsUniqueIDs(self,table):
-        sql = "UPDATE ForcedWarpMeasurement_"+forcedWarpID+" set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + (str(number)*1000000 ) + row)"
-        try: self.scratchDb.execute(sql)
-        except:
-           self.logger.errorPair('failed sql',sql)
-           raise
Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 39061)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 39062)
@@ -55,5 +55,5 @@
                None)
 
-       self.stackType = "DEEP_STACK" # TODO
+       self.stackType = "DEEP_STACK" # XXX NOTE:this is currently hard-wired for 3pi.  Before we run MD, this needs to be updated.
        self.stackTypeID = self.getStackTypeID()
        
