IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 5, 2011, 9:51:54 AM (15 years ago)
Author:
rhenders
Message:

shifted ImageMeta and FrameMeta population into different method so that we can abort batch before importing smf if there are no DVO IDs

File:
1 edited

Legend:

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

    r32305 r32327  
    538538        self.scratchDb.makeColumnPrimaryKey("Detection", "ippDetectID")
    539539
    540     '''
    541     Applies indexes to the IPP tables
    542     '''
    543     def indexIppTables(self):
    544 
    545         self.logger.infoPair("Creating indexes on", "IPP tables")
    546 
    547         for x in range(self.startX, self.endX):
    548             for y in range(self.startY, self.endY):
    549 
    550                 # dodge the corners
    551                 if x==0 and y==0: continue
    552                 if x==0 and y==7: continue
    553                 if x==7 and y==0: continue
    554                 if x==7 and y==7: continue
    555 
    556                 extension = "XY%d%d_psf" % (x, y)
    557                 self.scratchDb.createIndex(extension, "IPP_IDET")
    558 
    559     '''
    560     Updates provided table with DVO IDs from DVO table
    561     '''
    562     def updateDvoIDs(self, table, sourceID, externID):
    563 
    564         imageID = self.scratchDb.getImageIDFromExternID(sourceID, externID)
    565         self.logger.debug("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID)
    566         sql = "UPDATE IGNORE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \
    567                a.ippObjID = b.ippObjID, \
    568                a.detectID = b.detectID, \
    569                a.objID = b.objID, \
    570                a.infoFlag = b.flags << 32 | a.infoFlag \
    571                WHERE a.ippDetectID = b.ippDetectID \
    572                AND b.sourceID = " + str(sourceID) + " \
    573                AND b.imageID = " + str(imageID)
    574 
    575         self.scratchDb.execute(sql)
    576 
    577 
    578     '''
    579     Does the processing, i.e. pulling stuff from IPP tables into PSPS tables
    580     '''
    581     def populatePspsTables(self):
    582 
    583540        self.populateFrameMeta()
    584541     
    585542        # dictionary objects to hold sourceIDs and imageIDs for later
    586         sourceIDs = {}
    587         imageIDs = {}
     543        self.sourceIDs = {}
     544        self.imageIDs = {}
    588545
    589546        # loop through all OTAs and populate ImageMeta extensions
     
    608565
    609566                # check we have valid sourceID/imageID pair from the header
    610                 if self.safeDictionaryAccess(header, 'SOURCEID') == "NULL":
    611                     continue
    612                 if self.safeDictionaryAccess(header, 'IMAGEID') == "NULL":
    613                     continue
     567                if self.safeDictionaryAccess(header, 'SOURCEID') == "NULL": continue
     568                if self.safeDictionaryAccess(header, 'IMAGEID') == "NULL": continue
    614569
    615570                # store sourceID/imageID combo in Db so DVO can look up later
     
    618573
    619574                # store these for later
    620                 sourceIDs[ota] = header['SOURCEID']
    621                 imageIDs[ota] = header['IMAGEID']
     575                self.sourceIDs[ota] = header['SOURCEID']
     576                self.imageIDs[ota] = header['IMAGEID']
    622577
    623578                # populate ImageMeta
     
    628583        if not self.useFullTables:
    629584            if not self.getIDsFromDVO(): return False
     585
     586        return True
     587
     588
     589    '''
     590    Applies indexes to the IPP tables
     591    '''
     592    def indexIppTables(self):
     593
     594        self.logger.infoPair("Creating indexes on", "IPP tables")
     595
     596        for x in range(self.startX, self.endX):
     597            for y in range(self.startY, self.endY):
     598
     599                # dodge the corners
     600                if x==0 and y==0: continue
     601                if x==0 and y==7: continue
     602                if x==7 and y==0: continue
     603                if x==7 and y==7: continue
     604
     605                extension = "XY%d%d_psf" % (x, y)
     606                self.scratchDb.createIndex(extension, "IPP_IDET")
     607
     608    '''
     609    Updates provided table with DVO IDs from DVO table
     610    '''
     611    def updateDvoIDs(self, table, sourceID, externID):
     612
     613        imageID = self.scratchDb.getImageIDFromExternID(sourceID, externID)
     614        self.logger.debug("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID)
     615        sql = "UPDATE IGNORE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \
     616               a.ippObjID = b.ippObjID, \
     617               a.detectID = b.detectID, \
     618               a.objID = b.objID, \
     619               a.infoFlag = b.flags << 32 | a.infoFlag \
     620               WHERE a.ippDetectID = b.ippDetectID \
     621               AND b.sourceID = " + str(sourceID) + " \
     622               AND b.imageID = " + str(imageID)
     623
     624        self.scratchDb.execute(sql)
     625
     626
     627    '''
     628    Does the processing, i.e. pulling stuff from IPP tables into PSPS tables
     629    '''
     630    def populatePspsTables(self):
    630631
    631632        # loop through all OTAs again to update with DVO IDs
     
    649650
    650651                ota = "XY%d%d" % (x, y)
    651                 if ota not in sourceIDs: continue
     652                if ota not in self.sourceIDs: continue
    652653
    653654                #self.logger.infoTitle("Processing " + ota)
     
    660661
    661662                # now add DVO IDs
    662                 self.updateDvoIDs("Detection_" + ota, sourceIDs[ota], imageIDs[ota])
     663                self.updateDvoIDs("Detection_" + ota, self.sourceIDs[ota], self.imageIDs[ota])
    663664                results['NULLOBJID'] = self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID")
    664665                self.updateImageID("Detection_" + ota, x, y)
     
    687688                # update ImageMeta with count of detections for this OTA and photoCodeID
    688689                sql = "UPDATE ImageMeta_" + ota + " \
    689                        SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(sourceIDs[ota], imageIDs[ota]))
     690                       SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(self.sourceIDs[ota], self.imageIDs[ota]))
    690691                self.scratchDb.execute(sql)
    691692
Note: See TracChangeset for help on using the changeset viewer.