IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31821 for trunk/ippToPsps


Ignore:
Timestamp:
Jul 1, 2011, 4:00:52 PM (15 years ago)
Author:
rhenders
Message:

now making ippDetectID the primary key in order that we can use a cursor to update likelihoods - shouldn't change anything as it was unique before anyway; method to populate likelihoods using a cursor. this uses newly imported math libraries for the error function erfc()

File:
1 edited

Legend:

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

    r31810 r31821  
    66from java.lang import *
    77from java.sql import *
     8
     9from java.lang import Math
     10from org.apache.commons.math.special import Erf
    811
    912from xml.etree.ElementTree import ElementTree, Element, tostring
    … …  
    483486        self.logger.info("Creating indexes on PSPS tables")
    484487        self.scratchDb.makeColumnUnique("Detection", "objID")
    485         self.scratchDb.createIndex("Detection", "ippDetectID")
     488        self.scratchDb.makeColumnPrimaryKey("Detection", "ippDetectID")
    486489
    487490    '''
    … …  
    521524
    522525        self.scratchDb.execute(sql)
     526
     527    '''
     528    Generates psf, cosmic ray and extended source likelihoods
     529    '''
     530    def populateLikelihoods(self, tableName):
     531
     532        sql = "SELECT ippDetectID, psfLikelihood, crLikelihood, extendedLikelihood, sgSep FROM " + tableName
     533        rs = self.scratchDb.executeUpdatableQuery(sql)
     534
     535        sqrt2 = Math.sqrt(2)
     536
     537        while rs.next():
     538
     539            sgSep = rs.getDouble(5)
     540            psfLikelihood = Erf.erfc(Math.abs(sgSep)/sqrt2)
     541       
     542            if sgSep > 0:
     543                crLikelihood = 0
     544                extendedLikelihood = 1.0 - psfLikelihood
     545            else:
     546                crLikelihood = 1.0 - psfLikelihood
     547                extendedLikelihood = 0
     548
     549            # update columns
     550            rs.updateDouble(2, psfLikelihood )
     551            rs.updateDouble(3, crLikelihood )
     552            rs.updateDouble(4, extendedLikelihood )
     553
     554            # now 'commit' to database
     555            rs.updateRow();
    523556
    524557
    … …  
    602635                self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID")
    603636                self.updateImageID("Detection_" + ota, x, y)
     637                self.populateLikelihoods("Detection_" + ota)
    604638               
    605639                # check we have something in this Detection table
Note: See TracChangeset for help on using the changeset viewer.