Changeset 31403
- Timestamp:
- Apr 28, 2011, 3:55:01 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/detectionbatch.py (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/detectionbatch.py
r31389 r31403 1 1 #!/usr/bin/env jython 2 2 3 import os.path 4 import sys 3 5 import stilts 4 6 from java.lang import * … … 17 19 Constructor 18 20 ''' 19 def __init__(self, logger, camID, inputFile, test=False ):21 def __init__(self, logger, camID, inputFile, test=False, useFullTables=False): 20 22 super(DetectionBatch, self).__init__( 21 23 logger, 22 24 "detection", 23 25 inputFile, 24 "MD04") # TODO 26 "MD04", 27 useFullTables) # TODO 25 28 #"3PI") # TODO 26 29 … … 177 180 178 181 tableName = "ImageMeta_" + ota 179 self.logger.info(" Dealing with table " + tableName)180 182 181 183 # drop then re-create table … … 321 323 322 324 tableName = "Detection_" + ota 323 self.logger.info(" Dealing with table " + tableName)324 325 325 326 # drop then re-create table … … 396 397 397 398 tableName = "SkinnyObject_" + ota 398 self.logger.info(" Dealing with table " + tableName)399 399 400 400 # drop then re-create table … … 425 425 426 426 tableName = "ObjectCalColor_" + ota 427 self.logger.info(" Dealing with table " + tableName)428 427 429 428 # drop then re-create table … … 451 450 452 451 ''' 453 Applies indexes to the PSPS tables TODO need this? 454 ''' 455 def indexPspsTables(self): 456 452 Applies indexes and other constraints to the PSPS tables 453 ''' 454 def alterPspsTables(self): 455 456 self.logger.info("Altering PSPS tables") 457 457 self.logger.info("Creating indexes on PSPS tables") 458 # self.createIndex("StackDetection", "ippDetectID") 459 # self.createIndex("StackApFlx", "ippDetectID") 460 # self.createIndex("StackModelFit", "ippDetectID") 458 self.scratchDb.makeColumnUnique("Detection", "objID") 459 self.scratchDb.createIndex("Detection", "ippDetectID") 461 460 462 461 ''' … … 482 481 Updates provided table with DVO IDs from DVO table 483 482 ''' 484 def updateDvoIDs(self, table, sourceID, imageID): 485 486 self.logger.info("Updating table '" + table + "' with DVO IDs...") 487 sql = "UPDATE " + table + " AS a, dvoDetection AS b SET \ 483 def updateDvoIDs(self, table, sourceID, externID): 484 485 imageID = self.scratchDb.getImageIDFromExternID(sourceID, externID) 486 self.logger.info("Updating table '" + table + "' with DVO IDs using imageID = %d" % imageID) 487 sql = "UPDATE IGNORE " + table + " AS a, " + self.scratchDb.dvoDetection + " AS b SET \ 488 488 a.ippObjID = b.ippObjID, \ 489 489 a.detectID = b.detectID, \ … … 495 495 496 496 self.scratchDb.stmt.execute(sql) 497 self.logger.info("...done")498 497 499 498 … … 527 526 528 527 # store sourceID/imageID combo in Db so DVO can look up later 529 self.scratchDb.insertNewDvoImage(header['SOURCEID'], header['IMAGEID']) 528 if not self.useFullTables: 529 self.scratchDb.insertNewDvoImage(header['SOURCEID'], header['IMAGEID']) 530 530 531 531 # store these for later … … 538 538 539 539 # now run DVO code to get all IDs 540 self.getIDsFromDVO()540 if not self.useFullTables: self.getIDsFromDVO() 541 541 542 542 # loop through all OTAs again to update with DVO IDs … … 555 555 556 556 ota = "XY%d%d" % (x, y) 557 self.logger.info("******************* Dealing with OTA " + ota + " *******************") 557 558 558 559 # populate remainder of tables … … 561 562 # now add DVO IDs 562 563 self.updateDvoIDs("Detection_" + ota, sourceIDs[ota], imageIDs[ota]) 563 564 564 self.scratchDb.reportAndDeleteRowsWithNULLS("Detection_" + ota, "objID") 565 565 self.updateImageID("Detection_" + ota, x, y) … … 571 571 572 572 # update ImageMeta with count of detections for this OTA and photoCodeID 573 sql = "UPDATE ImageMeta_" + ota + " SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID( header['SOURCEID'], header['IMAGEID']))573 sql = "UPDATE ImageMeta_" + ota + " SET nDetect = %d, photoCalID = %d" % (self.scratchDb.getRowCount("Detection_" + ota), self.scratchDb.getPhotoCalID(sourceIDs[ota], imageIDs[ota])) 574 574 self.scratchDb.stmt.execute(sql) 575 575 … … 633 633 gpc1Db = Gpc1Db(logger) 634 634 camIDs = gpc1Db.getIDsInThisDVODbForThisStage("MD04.V2", "cam") 635 #camIDs = gpc1Db.getIDsInThisDVODbForThisStage("ThreePi.V1", "cam")636 635 637 636 logger.info("Found %d exposures" % len(camIDs)) … … 640 639 for camID in camIDs: 641 640 641 logger.info("-------------------------------------------------- cam ID: %d" % camID) 642 642 643 file = gpc1Db.getCameraStageSmf(camID) 643 detectionBatch = DetectionBatch(logger, camID, file, False) 644 645 if detectionBatch.alreadyProcessed(): 644 if not os.path.isfile(file): 645 logger.error("Cannot read file at '" + file) 646 continue 647 648 detectionBatch = DetectionBatch(logger, camID, file, False, True) 649 650 if not detectionBatch.alreadyProcessed(): 646 651 647 652 detectionBatch.createEmptyPspsTables() 648 #detectionBatch.importIppTables(".*.psf")653 detectionBatch.importIppTables(".*.psf") 649 654 if detectionBatch.populatePspsTables(): 650 655 detectionBatch.exportPspsTablesToFits("([a-zA-Z]+)") 651 656 detectionBatch.writeBatchManifest() 652 detectionBatch.reportNullsInAllPspsTables(False)653 detectionBatch.createTarball()654 detectionBatch.publishToDatastore()657 #detectionBatch.reportNullsInAllPspsTables(False) 658 #detectionBatch.createTarball() 659 #detectionBatch.publishToDatastore() 655 660 656 i = i+1657 if i > 0: break658 661 i = i+1 662 # if i > 0: sys.exit() 663
Note:
See TracChangeset
for help on using the changeset viewer.
