Changeset 31848
- Timestamp:
- Jul 8, 2011, 3:01:58 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/detectionbatch.py (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/detectionbatch.py
r31821 r31848 3 3 import os.path 4 4 import sys 5 import time 5 6 import stilts 6 7 from java.lang import * … … 32 33 gpc1Db, 33 34 ippToPspsDb, 34 camID, 35 inputFile): 35 camID): 36 36 37 37 super(DetectionBatch, self).__init__( … … 42 42 camID, 43 43 "detection", 44 inputFile,44 gpc1Db.getCameraStageSmf(camID), 45 45 #"MD04") # TODO 46 46 "3PI") 47 47 48 48 if not self.everythingOK: return 49 50 # get camera meta data 51 meta = self.gpc1Db.getCameraStageMeta(self.id) 52 self.expID = meta[0]; 53 self.expName = meta[1]; 54 self.distGroup = meta[2]; 55 self.analysisVer = meta[3]; 56 self.bias = meta[4]; 57 self.biasScat = meta[5]; 58 59 if not self.analysisVer: self.analysisVer = -999 49 60 50 61 # create an output filename, which is {expID}.FITS … … 89 100 super(DetectionBatch, self).printMe() 90 101 91 self.logger.info("Cam ID: %d" % self.id) 92 self.logger.info("Exp ID: %d" % self.expID) 93 self.logger.info("Exp name: %s" % self.expName) 94 self.logger.info("Distribution group: %s" % self.distGroup) 95 96 102 self.logger.infoPair("Cam ID", "%d" % self.id) 103 self.logger.infoPair("Exp ID", "%d" % self.expID) 104 self.logger.infoPair("Exp name", "%s" % self.expName) 105 self.logger.infoPair("Distribution group", "%s" % self.distGroup) 97 106 98 107 ''' … … 100 109 ''' 101 110 def populateFrameMeta(self): 102 self.logger.info ("Procesing FrameMeta table")111 self.logger.infoPair("Proccesing table", "FrameMeta") 103 112 104 113 sql = "INSERT INTO FrameMeta (\ … … 287 296 ," + self.safeDictionaryAccess(header, 'CNAXIS1') + " \ 288 297 ," + self.safeDictionaryAccess(header, 'CNAXIS2') + " \ 289 , " + str((float(self.safeDictionaryAccess(header, 'FWHM_MAJ')) + float(self.safeDictionaryAccess(header, 'FWHM_MIN')))/2.0) + "\298 , ( " + self.safeDictionaryAccess(header, 'FWHM_MAJ') + " + " + self.safeDictionaryAccess(header, 'FWHM_MIN') + " ) / 2.0 \ 290 299 ," + self.safeDictionaryAccess(header, 'FWHM_MAJ') + " \ 291 300 ," + self.safeDictionaryAccess(header, 'FWHM_MIN') + " \ 292 301 ," + self.safeDictionaryAccess(header, 'ANGLE') + " \ 293 , " + str((float(self.safeDictionaryAccess(header, 'IQ_FW1')) + float(self.safeDictionaryAccess(header, 'IQ_FW2')))/2.0) + "\302 , ( " + self.safeDictionaryAccess(header, 'IQ_FW1') + " + " + self.safeDictionaryAccess(header, 'IQ_FW2') + " ) / 2.0 \ 294 303 ," + self.safeDictionaryAccess(header, 'IQ_FW1') + " \ 295 304 ," + self.safeDictionaryAccess(header, 'IQ_FW2') + " \ … … 336 345 )" 337 346 338 self.scratchDb.execute(sql) 347 try: self.scratchDb.execute(sql) 348 except: print sql 349 339 350 self.scratchDb.updateFilterID(tableName, self.filter) 340 351 self.scratchDb.updateAllRows(tableName, "calibModNum", str(self.calibModNum)) … … 357 368 358 369 # insert all detections into table 359 sql = "INSERT I NTO " + tableName + " ( \370 sql = "INSERT IGNORE INTO " + tableName + " ( \ 360 371 ippDetectID \ 361 372 ,xPos \ … … 483 494 def alterPspsTables(self): 484 495 485 self.logger. info("Altering PSPS tables")486 self.logger. info("Creating indexes on PSPS tables")496 self.logger.debug("Altering PSPS tables") 497 self.logger.debug("Creating indexes on PSPS tables") 487 498 self.scratchDb.makeColumnUnique("Detection", "objID") 488 499 self.scratchDb.makeColumnPrimaryKey("Detection", "ippDetectID") … … 493 504 def indexIppTables(self): 494 505 495 self.logger.info ("Creating indexes onIPP tables")506 self.logger.infoPair("Creating indexes on", "IPP tables") 496 507 497 508 for x in range(self.startX, self.endX): … … 567 578 imageIDs = {} 568 579 569 file = open(self.inputFitsPath, 'r')570 571 580 # loop through all OTAs and populate ImageMeta extensions 572 self.logger.info("Reading all fits headers and populating ImageMeta tables") 581 self.logger.infoPair("Reading", "FITS headers") 582 self.logger.infoPair("Populating table", "ImageMeta") 573 583 for x in range(self.startX, self.endX): 574 584 for y in range(self.startY, self.endY): … … 583 593 584 594 # load corresponding header into memory 585 header = self.fi ndAndReadFITSHeader(ota + ".hdr", file)595 header = self.fits.findAndReadHeader(ota + ".hdr") 586 596 if not header: 587 597 self.logger.error("No header found for OTA " + ota) 588 598 continue 589 590 599 591 600 # store sourceID/imageID combo in Db so DVO can look up later … … 626 635 if ota not in sourceIDs: continue 627 636 628 self.logger.info ("******************* Dealing with OTA " + ota + " *******************")637 self.logger.infoMiniSeparator() 629 638 630 639 # populate remainder of tables … … 639 648 # check we have something in this Detection table 640 649 if self.scratchDb.getRowCount("Detection_" + ota) < 1: 641 self.logger.info ("Empty tables for ota " + ota + ". Skipping.")650 self.logger.infoPair("Skipping empty table for ota", ota) 642 651 continue; 643 652 … … 682 691 683 692 ''' 684 Checks whether this batch has already been processed and published685 '''686 def alreadyProcessed(self):687 688 meta = self.gpc1Db.getCameraStageMeta(self.id)689 self.expID = meta[0];690 self.expName = meta[1];691 self.distGroup = meta[2];692 self.analysisVer = meta[3];693 self.bias = meta[4];694 self.biasScat = meta[5];695 696 if not self.analysisVer: self.analysisVer = -999697 698 #return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID)699 return 0700 701 702 '''703 693 Overriding this method 704 694 ''' … … 728 718 return super(DetectionBatch, self).exportPspsTablesToFits("([a-zA-Z]+)") 729 719 730 731 logging.config.fileConfig("logging.conf")732 logger = logging.getLogger("ippToPspsLog")733 logger.setLevel(logging.INFO)734 logger.info("Starting")735 736 configDoc = ElementTree(file="config.xml")737 dvoGpc1Label = configDoc.find("dvo/gpc1Label").text738 739 gpc1Db = Gpc1Db(logger)740 ippToPspsDb = IppToPspsDb(logger)741 742 ids = gpc1Db.getIDsInThisDVODbForThisStage(dvoGpc1Label, "cam")743 for id in ids:744 745 if not int(configDoc.find("options/force").text) and ippToPspsDb.alreadyProcessed(id): continue746 747 file = gpc1Db.getCameraStageSmf(id)748 749 detectionBatch = DetectionBatch(logger,750 configDoc,751 gpc1Db,752 ippToPspsDb,753 id,754 file)755 detectionBatch.printMe()756 detectionBatch.run()757
Note:
See TracChangeset
for help on using the changeset viewer.
