IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32286 for trunk/ippToPsps


Ignore:
Timestamp:
Sep 2, 2011, 12:05:34 AM (15 years ago)
Author:
rhenders
Message:

now using a stored procedure to calculate likelihoods. much, much faster than using the cursor, as previously

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/detectionbatch.py

    r32285 r32286  
    406406               ,psfWidMinor \
    407407               ,psfTheta \
     408               ,psfLikelihood \
    408409               ,psfCf \
    409410               ,momentXX \
     
    437438               ,PSF_MINOR \
    438439               ,PSF_THETA \
     440               ,psfLikelihood(EXT_NSIGMA) \
    439441               ,PSF_QF \
    440442               ,MOMENTS_XX \
     
    459461        self.scratchDb.execute(sql)
    460462
     463        # update cosmic ray and extended likelihoods
     464        sql="UPDATE " + pspsTableName + " SET extendedLikelihood = 0, crLikelihood = 1.0 - psfLikelihood WHERE sgSep <= 0"
     465        self.scratchDb.execute(sql)
     466        sql="UPDATE " + pspsTableName + " SET crLikelihood = 0, extendedLikelihood = 1.0 - psfLikelihood WHERE sgSep > 0"
     467        self.scratchDb.execute(sql)
     468
     469        # remove detections will NULL inst flux or NULL peak ADU
    461470        results['NULLINSTFLUX'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "instFlux")
    462471        results['NULLPEAKADU'] = self.scratchDb.reportAndDeleteRowsWithNULLS(pspsTableName, "peakADU")
     
    566575
    567576        self.scratchDb.execute(sql)
    568 
    569     '''
    570     Generates psf, cosmic ray and extended source likelihoods
    571     '''
    572     def populateLikelihoods(self, tableName):
    573 
    574         sql = "SELECT ippDetectID, psfLikelihood, crLikelihood, extendedLikelihood, sgSep FROM " + tableName
    575         rs = self.scratchDb.executeUpdatableQuery(sql)
    576 
    577         sqrt2 = Math.sqrt(2)
    578 
    579         while rs.next():
    580 
    581             sgSep = rs.getDouble(5)
    582             psfLikelihood = Erf.erfc(Math.abs(sgSep)/sqrt2)
    583        
    584             if sgSep > 0:
    585                 crLikelihood = 0
    586                 extendedLikelihood = 1.0 - psfLikelihood
    587             else:
    588                 crLikelihood = 1.0 - psfLikelihood
    589                 extendedLikelihood = 0
    590 
    591             # update columns
    592             rs.updateDouble(2, psfLikelihood )
    593             rs.updateDouble(3, crLikelihood )
    594             rs.updateDouble(4, extendedLikelihood )
    595 
    596             # now 'commit' to database
    597             rs.updateRow();
    598577
    599578
     
    685664                results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID")
    686665                self.updateImageID("Detection_" + ota, x, y)
    687                 self.populateLikelihoods("Detection_" + ota)
    688666                rowCount = self.scratchDb.getRowCount("Detection_" + ota)
    689667                self.logger.info("| %5s | %13d | %13d | %13d | %13d | %13d | %13d |",
Note: See TracChangeset for help on using the changeset viewer.