Changeset 35097 for trunk/ippToPsps/jython/batch.py
- Timestamp:
- Feb 6, 2013, 3:16:35 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
-
trunk/ippToPsps/jython
- Property svn:ignore
-
old new 1 1 *.class 2 Makefile 3 Makefile.in
-
- Property svn:ignore
-
trunk/ippToPsps/jython/batch.py
r33787 r35097 30 30 logger, 31 31 config, 32 skychunk, 32 33 gpc1Db, 33 34 ippToPspsDb, … … 39 40 useFullTables): 40 41 42 # print "starting the batch" 43 44 # self.printline = 0 45 # self.testprint() 46 41 47 self.readHeader = False 42 48 self.config = config 49 self.skychunk = skychunk 43 50 self.fits = fits 44 51 self.useFullTables = useFullTables … … 48 55 self.logger.infoSeparator() 49 56 self.logger.debug("Batch class constructor") 57 58 # self.testprint() 50 59 51 60 # set up class variables … … 56 65 self.scratchDb = scratchDb 57 66 self.batchType = batchType; 58 self.pspsVoTableFilePath = "../config/" + batchType + "/tables.vot" 67 self.pspsVoTableFilePath = self.config.configDir + "tables." + batchType + ".vot" 68 69 # self.testprint() 59 70 60 71 # check FITS file is ok … … 64 75 # now check that the fits header is readable 65 76 if not self.header: 66 logger.errorPair("Could not read FITS for id", "%d" % id)77 logger.errorPair("Could not read FITS PHU for id", "%d" % id) 67 78 raise 68 79 … … 72 83 self.tablesToExport = [] 73 84 74 if self. config.survey != "":75 self.surveyID = self.scratchDb.getSurveyID(self. config.survey)85 if self.skychunk.survey != "": 86 self.surveyID = self.scratchDb.getSurveyID(self.skychunk.survey) 76 87 else: 77 88 self.surveyID = -1; 78 89 79 90 # create datastore object 80 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)81 82 # get local storage location from config91 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 92 93 # get local storage location from skychunk 83 94 self.batchName = Batch.getNameFromID(self.batchID) 84 95 self.subDir = Batch.getSubDir( 85 self. config.basePath,96 self.skychunk.basePath, 86 97 self.batchType, 87 self. config.dvoLabel)98 self.skychunk.dvoLabel) 88 99 89 100 self.localOutPath = Batch.getOutputPath( 90 self. config.basePath,101 self.skychunk.basePath, 91 102 self.batchType, 92 self. config.dvoLabel,103 self.skychunk.dvoLabel, 93 104 self.batchID) 94 105 95 106 if not os.path.exists(self.localOutPath): os.makedirs(self.localOutPath) 107 108 # self.testprint() 96 109 97 110 # store today's date … … 112 125 self.logger.infoPair("Input FITS primary header", "%s cards found" % self.fits.getPrimaryHeaderCardCount()) 113 126 127 # self.testprint() 128 114 129 self.logger.infoPair("Output path", self.localOutPath) 115 130 116 131 132 def testprint(self): 133 print "here ", self.printline 134 self.printline += 1 135 117 136 ''' 118 137 Static method to generated batch name from batch ID … … 232 251 root.attrib['type'] = self.batchType 233 252 root.attrib['timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") 234 root.attrib['survey'] = self. config.pspsSurvey253 root.attrib['survey'] = self.skychunk.pspsSurvey 235 254 236 255 # min/max object IDs … … 273 292 # set up filenams and paths 274 293 tarFile = Batch.getTarFile(self.batchID) 275 tarPath = Batch.getTarPath(self. config.basePath, self.batchType, self.config.dvoLabel, self.batchID)294 tarPath = Batch.getTarPath(self.skychunk.basePath, self.batchType, self.skychunk.dvoLabel, self.batchID) 276 295 tarballFile = Batch.getTarballFile(self.batchID) 277 tarballPath = Batch.getTarballPath(self. config.basePath, self.batchType, self.config.dvoLabel, self.batchID)296 tarballPath = Batch.getTarballPath(self.skychunk.basePath, self.batchType, self.skychunk.dvoLabel, self.batchID) 278 297 279 298 # tar directory … … 376 395 self.logger.infoPair("Importing tables with filter", filter) 377 396 397 # print "trying to read ", self.fits.getPath() 398 378 399 try: 379 400 tables = stilts.treads(self.fits.getPath()) … … 385 406 for table in tables: 386 407 408 # print "import smf table ", table 387 409 match = re.match(filter, table.name) 388 410 if not match: continue 389 411 self.logger.debugPair("Reading IPP table", table.name) 390 412 table = stilts.tpipe(table, cmd='explodeall') 413 414 # print "read smf table ", table 391 415 392 416 # drop any previous tables before import … … 398 422 table = stilts.tpipe(table, cmd='replaceval -Infinity null *') 399 423 table = stilts.tpipe(table, cmd='replaceval Infinity null *') 424 # print "cleaned up values ", table 400 425 401 426 try: 402 427 table.write(self.scratchDb.url + '#' + table.name) 428 # print "wrote to mysql ", table 403 429 self.scratchDb.killLastConnectionID() 404 430 count = count + 1 … … 488 514 489 515 # TODO path to DVO prog hardcoded temporarily 490 cmd = "../src/dvograbber " + self.config.settingsPath + " " + self.scratchDb.dbName + " " + self. config.dvoLocation516 cmd = "../src/dvograbber " + self.config.settingsPath + " " + self.scratchDb.dbName + " " + self.skychunk.dvoLocation 491 517 self.logger.infoPair("Running DVO", cmd) 492 518 p = Popen(cmd, shell=True, stdout=PIPE) … … 504 530 ''' 505 531 Creates and publishes a batch 506 TODO all method s callbelow should throw exceptions on failure532 TODO all method calls below should throw exceptions on failure 507 533 ''' 508 534 def run(self): 509 535 536 # this is badly named : it creates the tables and then fills in 537 # the ImageMeta tables for each ota (alterPspsTables) 510 538 if not self.createEmptyPspsTables(): 511 539 self.logger.errorPair("Aborting this batch", "could not create empty PSPS tables") … … 513 541 raise 514 542 543 # for P2/ST, this reads the detection tables from the CMF/SMF file(s) 544 # for OB, this imports object data from DVO 515 545 if not self.importIppTables(): 516 546 self.logger.errorPair("Aborting this batch", "could not import IPP tables") … … 529 559 530 560 if self.writeBatchManifest(): 531 if self. config.datastorePublishing:561 if self.skychunk.datastorePublishing: 532 562 533 563 # tar and zip ready for publication to datastore
Note:
See TracChangeset
for help on using the changeset viewer.
