Index: /trunk/ippToPsps/jython/forcedwarpbatch.py
===================================================================
--- /trunk/ippToPsps/jython/forcedwarpbatch.py	(revision 38920)
+++ /trunk/ippToPsps/jython/forcedwarpbatch.py	(revision 38921)
@@ -84,4 +84,5 @@
        self.skycellID = {}
        self.projectionID = {}
+       self.tessID = {}
 
        #I give a number to the forcedwarp stuff, I am not sure if this is the best way but it might work
@@ -131,6 +132,5 @@
            self.logger.infoPair("found tess_id",self.tessName[num])
 
-           # tessName = self.getKeyValue(self.header, 'TESS_ID')
-           # self.tessID = self.scratchDb.getTessID(tessName)
+           self.tessID[num] = self.scratchDb.getTessID(self.tessName[num])
 
            # As the database doesn't have the software_ver entry, pull the photometry version as the analysis version.
@@ -160,4 +160,5 @@
            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))
@@ -166,4 +167,5 @@
            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))
@@ -255,4 +257,5 @@
 
         sqlLine.group("forcedWarpID",   str(forcedWarpID))
+	sqlLine.group("tessID",         str(self.tessID[num]))
 	sqlLine.group("projectionID",   str(self.projectionID[num]))
         sqlLine.group("skyCellID",      str(self.skycellID[num])) 
@@ -336,5 +339,5 @@
 
     '''
-    Populates the ForcedWarpMeasurement table
+    Populates the ForcedWarpMeasurement and ForcedWarpMasked tables
     '''
     def populateForcedWarpMeasurement(self,num):
@@ -361,4 +364,6 @@
         sqlLine.group("filterID",          str(self.filterID[num]))
         sqlLine.group("surveyID",          str(self.surveyID))
+	sqlLine.group("tessID",            str(self.tessID[num]))
+	sqlLine.group("projectionID",      str(self.projectionID[num]))
         sqlLine.group("skycellID",         str(self.skycellID[num]))
         sqlLine.group("expTime",           str(self.expTime[num]))
@@ -447,8 +452,34 @@
         self.logger.infoPair("Dropping row column from", "ForcedWarpMeasurement_"+forcedWarpID+" table")
         self.scratchDb.dropColumn("ForcedWarpMeasurement_"+forcedWarpID, "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
+
+        # This is the definition of a "masked measurement".
+        # Do we have NULL columns at this point or are they already -999? This test catches them either way
+        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
            
         # add indexes ForcedWarpMeasurement
         self.scratchDb.createIndex("ForcedWarpMeasurement_"+forcedWarpID, "objID")
         self.scratchDb.createIndex("ForcedWarpMeasurement_"+forcedWarpID, "ippDetectID")
+
+        # add indexes ForcedWarpMasked
+        self.scratchDb.createIndex("ForcedWarpMasked_"+forcedWarpID, "objID")
+        self.scratchDb.createIndex("ForcedWarpMasked_"+forcedWarpID, "ippDetectID")
 
     '''
@@ -617,4 +648,5 @@
             self.populateForcedWarpMeasurement(num)          
             self.tablesToExport.append("ForcedWarpMeasurement_"+forcedWarpID)
+            self.tablesToExport.append("ForcedWarpMasked_"+forcedWarpID)
             
             self.logger.infoPair("Populating","ForcedWarpExtended_"+forcedWarpID)
