Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 38929)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 38951)
@@ -199,4 +199,9 @@
     def populateImageMetaTable(self, ota, header):
 
+        # does this chip exist in the DVO image table? (if NOT, then skip it)
+        if not self.scratchDb.haveThisChip(self.imageIDs[ota], self.sourceIDs[ota]):
+            self.logger.info("| %5s |            ------------- Chip not in DVO : rejecting ------------                    |" % ota)
+            return False
+
         # the supplied 'header' matches this chip
         # self.header is the PHU header for this smf
@@ -231,6 +236,8 @@
         zp      = self.getKeyFloat(header, "%.8f", 'ZPT_OBS')
 
+        zpImage = self.scratchDb.getImageZeroPoint(self.imageIDs[ota])
+
         # XXX zp correction should come from DVO
-        detectionThreshold = detectionThreshold + zp - 2.5 * math.log10(expTime)
+        detectionThreshold = detectionThreshold + zpImage - 2.5 * math.log10(expTime)
         
         # insert image metadata into table
@@ -246,5 +253,5 @@
         sqlLine.group("astroScat",          astroscat)
         sqlLine.group("photoScat",          self.getKeyFloat(header, "%.8f", 'ZPT_ERR'))
-        sqlLine.group("photoZero",          zp)
+        sqlLine.group("photoZero",          zpImage)
         sqlLine.group("nAstroRef",          self.getKeyValue(header, 'NASTRO'))
         sqlLine.group("nPhotoRef",          self.getKeyValue(header, 'NASTRO'))
@@ -629,5 +636,8 @@
             
         # populate ImageMeta
-        self.populateImageMetaTable(chipname, header)
+        if not self.populateImageMetaTable(chipname, header):
+            self.logger.infoPair("skipping chip: ", chipname)
+            return False
+
         self.updateImageID("ImageMeta_" + chipname, x, y) 
 
@@ -810,5 +820,4 @@
         ota = x*10+y
 
-
         self.logger.info("add psps unique p2 ids")
         self.updatePspsUniqueIDs("Detection_" + chipname, ota)
@@ -901,22 +910,30 @@
                 if x==7 and y==7: continue
 
+                # skip chips which were not loaded
                 ota = "XY%d%d" % (x, y)
                 extension = ota + ".psf"
                 if extension not in self.tablesLoaded: continue
 
-                if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1
+                # skip chips which had a problem (e.g., not in DVO)
+                if not self.populatePspsTablesChip(ota, x, y, results, tables):
+                    if self.skipBatch: 
+                        self.logger.error("fatal problem for exposure, skipping")
+                        return False
+                    continue
+                                
+                otaCount = otaCount + 1
+                self.populateImageDetEffMetaTablePart2(ota)
+
+        extension = "Chip.psf"
+        if extension in self.tablesLoaded:
+            if not self.populatePspsTablesChip("Chip", 0, 0, results, tables):
+                print "--- skipped Chip.psf"
                 if self.skipBatch: 
                     self.logger.error("fatal problem for exposure, skipping")
                     return False
-                                
-                self.populateImageDetEffMetaTablePart2(ota)
-
-
-        extension = "Chip.psf"
-        if extension in self.tablesLoaded:
-            if self.populatePspsTablesChip("Chip", 0, 0, results, tables): otaCount = otaCount + 1
-            if self.skipBatch: 
-                self.logger.error("fatal problem for exposure, skipping")
-                return False
+            else:
+                otaCount = otaCount + 1
+
+            print "--- tried Chip.psf"
 
         # print totals
@@ -931,4 +948,6 @@
         self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+")
 
+        print "--- tried Chip.psf (2)"
+
         # if we only have one table export, i.e. FrameMeta, then get out of here (skip batch, but do not abort)
         if len(self.tablesToExport) == 1:
