Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 32285)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 32286)
@@ -406,4 +406,5 @@
                ,psfWidMinor \
                ,psfTheta \
+               ,psfLikelihood \
                ,psfCf \
                ,momentXX \
@@ -437,4 +438,5 @@
                ,PSF_MINOR \
                ,PSF_THETA \
+               ,psfLikelihood(EXT_NSIGMA) \
                ,PSF_QF \
                ,MOMENTS_XX \
@@ -459,4 +461,11 @@
         self.scratchDb.execute(sql)
 
+        # update cosmic ray and extended likelihoods
+        sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0"
+        self.scratchDb.execute(sql)
+        sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0"
+        self.scratchDb.execute(sql)
+
+        # remove detections will NULL inst flux or NULL peak ADU
         results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux")
         results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU")
@@ -566,34 +575,4 @@
 
         self.scratchDb.execute(sql)
-
-    '''
-    Generates psf, cosmic ray and extended source likelihoods
-    '''
-    def populateLikelihoods(self, tableName):
-
-        sql = "SELECT ippDetectID, psfLikelihood, crLikelihood, extendedLikelihood, sgSep FROM " + tableName
-        rs = self.scratchDb.executeUpdatableQuery(sql)
-
-        sqrt2 = Math.sqrt(2)
-
-        while rs.next():
-
-            sgSep = rs.getDouble(5)
-            psfLikelihood = Erf.erfc(Math.abs(sgSep)/sqrt2)
-        
-            if sgSep > 0:
-                crLikelihood = 0
-                extendedLikelihood = 1.0 - psfLikelihood
-            else:
-                crLikelihood = 1.0 - psfLikelihood
-                extendedLikelihood = 0
-
-            # update columns
-            rs.updateDouble(2, psfLikelihood )
-            rs.updateDouble(3, crLikelihood )
-            rs.updateDouble(4, extendedLikelihood )
-
-            # now 'commit' to database
-            rs.updateRow();
 
 
@@ -685,5 +664,4 @@
                 results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID")
                 self.updateImageID("Detection_" + ota, x, y) 
-                self.populateLikelihoods("Detection_" + ota)
                 rowCount = self.scratchDb.getRowCount("Detection_" + ota) 
                 self.logger.info("| %5s | %13d | %13d | %13d | %13d | %13d | %13d |", 
