Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 39543)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 39544)
@@ -686,7 +686,11 @@
             if self.config.test: self.logger.errorPair("No header found for chip", chipname)
             return False
-        
+#        self.logger.infoPair("extname is ",self.fits[0])
+
         # check we have valid sourceID/imageID pair from the header
-        if self.getKeyValue(header, 'SOURCEID') == "NULL": return False
+        # hardwire it
+        if self.getKeyValue(header, 'SOURCEID') == "NULL": 
+            header['SOURCEID']=0
+            self.logger.infoPair("no sourceid, using:",header['SOURCEID'])
         if self.getKeyValue(header, 'IMAGEID') == "NULL": return False
         
@@ -697,4 +701,5 @@
         self.imageIDs[chipname] = header['IMAGEID']
         self.sourceIDs[chipname] = header['SOURCEID']
+        #self.sourceIDs[chipname] = 33
             
         # populate ImageMeta
Index: trunk/ippToPsps/jython/gpc1db.py
===================================================================
--- trunk/ippToPsps/jython/gpc1db.py	(revision 39543)
+++ trunk/ippToPsps/jython/gpc1db.py	(revision 39544)
@@ -286,4 +286,6 @@
         rs.close()
 
+        
+
         return addIDs
 
@@ -331,4 +333,5 @@
             self.logger.exception("Can't query for addIDs using :" + sql )
 
+
         addIDs = []
         while (rs.next()):
@@ -402,4 +405,6 @@
         if not rs.first():
             self.logger.errorPair("Can't query for", "forced warp meta data")
+            self.logger.errorPair("this failed", sql)
+
             os._exit(3)
 
@@ -506,4 +511,5 @@
         if len(files) < 1: return None
         fits = Fits(self.logger, self.config, files[0])
+        self.logger.infoPair("cmf file",files[0])
         return fits
 
@@ -651,4 +657,69 @@
 
         return imageIDs
+
+
+
+    '''
+    Gets a list of PSPS image IDs for this diff ID
+    '''
+    def getWarpSkyFileIDforThisAddIDforFW(self, addID):
+
+        self.logger.debug("Querying GPC1 for stage_extra1 for add ID: " + str(addID))
+
+
+        sql = "select warp_skyfile_id from addRun join fullForceInput \
+              on stage_id = ff_id and stage = 'fullforce' and stage_extra1 = warp_id \
+              join fullForceRun using (ff_id) \
+              join fullForceResult using (ff_id, warp_id) \
+              JOIN skycalRun using (skycal_id) \
+              join stackRun using (stack_id) \
+              join warpImfile using (warp_id, skycell_id) \
+              where add_id = "+str(addID)
+        try:
+            rs = self.executeQuery(sql)
+        except:
+            self.logger.infoPair("failed sql:",sql)
+            self.logger.exception("Can't query for imageIDs")
+            
+
+        #imageIDs = []
+        #while (rs.next()):
+        #    imageIDs.append(rs.getString(1))
+        #rs.close()
+
+        rs.first()
+        imageID=rs.getString(1)
+        rs.close()
+        return imageID
+
+    '''
+    Gets a list of PSPS image IDs for this diff ID
+    '''
+    def getWarpSkyFileIDforThisAddIDforST(self, addID):
+
+        self.logger.debug("Querying GPC1 for stage_extra1 for add ID: " + str(addID))
+
+
+        sql = "select warp_skyfile_id from addRun join skycalRun \
+              on stage_id = skycal_id and stage = 'skycal' \
+              join stackRun using (stack_id) \
+              join warpImfile using (warp_id, skycell_id) \
+              where add_id = "+str(addID)
+        try:
+            rs = self.executeQuery(sql)
+        except:
+            self.logger.infoPair("failed sql:",sql)
+            self.logger.exception("Can't query for imageIDs")
+            
+
+        #imageIDs = []
+        #while (rs.next()):
+        #    imageIDs.append(rs.getString(1))
+        #rs.close()
+
+        rs.first()
+        imageID=rs.getString(1)
+        rs.close()
+        return imageID
 
     
@@ -882,4 +953,5 @@
         # if we get here, then the cmf is readable, now check the stack_id
         fits = Fits(self.logger, self.config, files[0])
+        print self.logger.infoPair("cmf file",files[0])
         return fits
 
Index: trunk/ippToPsps/jython/scratchdb.py
===================================================================
--- trunk/ippToPsps/jython/scratchdb.py	(revision 39543)
+++ trunk/ippToPsps/jython/scratchdb.py	(revision 39544)
@@ -177,4 +177,5 @@
                
         sql = "SELECT IMAGE_ID FROM " + self.dvoImagesTable + " WHERE EXTERN_ID = %s" % (externID) 
+        self.logger.info(sql)
         try: 
             rs = self.executeQuery(sql)   
Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 39543)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 39544)
@@ -112,9 +112,12 @@
 
            self.logger.infoPair(filter + " stackID = ", stackID)       
-
-           if not (str(stackID) == header['IMAGEID']): 
-               self.logger.errorPair("inconsistency: header IMAGEID does not match stackID", str(stackID) + " vs " + header['IMAGEID'])
-               raise
-
+           self.logger.info("got here")
+
+           #header['IMAGEID'] = self.getWarpSkyFileIDforThisAddIDforST(stackID)
+           #self.logger.infoPair("header['IMAGEID']",header['IMAGEID'])
+           #if not (str(stackID) == header['IMAGEID']): 
+           #    self.logger.errorPair("inconsistency: header IMAGEID does not match stackID", str(stackID) + " vs " + header['IMAGEID'])
+           #    raise
+           self.logger.infoPair("getImageIDFromExternID()",stackID)
            imageID = self.scratchDb.getImageIDFromExternID(stackID)
            self.logger.infoPair(filter + " imageID = ", imageID)       
