Changeset 31286 for trunk/ippToPsps/jython/batch.py
- Timestamp:
- Apr 14, 2011, 3:17:49 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/batch.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/batch.py
r31222 r31286 60 60 self.gpc1Db = Gpc1Db(self.logger) 61 61 62 if self.survey != "": 63 62 64 # get survey ID from init table 63 sql = "SELECT surveyID from Survey WHERE name = '" + survey+ "'"64 try:65 rs = self.localStmt.executeQuery(sql)66 rs.first()67 self.surveyID = rs.getInt(1)68 except:69 self.logger.exception("No survey ID found for this survey: '" + survey+ "'")70 self.surveyID = -1;65 sql = "SELECT surveyID from Survey WHERE name = '" + self.getPspsSurveyType() + "'" 66 try: 67 rs = self.localStmt.executeQuery(sql) 68 rs.first() 69 self.surveyID = rs.getInt(1) 70 except: 71 self.logger.exception("No survey ID found for this survey: '" + self.getPspsSurveyType() + "'") 72 self.surveyID = -1; 71 73 72 74 # get dvo info from config 73 if survey != "":74 75 dvoName = doc.find(survey+"dvo/name").text 75 dvoLocation = doc.find(survey+"dvo/location").text76 self.dvoLocation = doc.find(survey+"dvo/location").text 76 77 else: 77 78 dvoName = "" 78 dvoLocation = "" 79 self.dvoLocation = "" 80 self.surveyID = -1; 79 81 80 82 # get datastore info from config … … 127 129 root.attrib['name'] = self.batchName 128 130 root.attrib['type'] = self.getPspsBatchType() 129 root.attrib['survey'] = self.getPspsSurveyType()130 131 root.attrib['timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") 131 root.attrib['minObjId'] = str(self.minObjID) 132 root.attrib['maxObjId'] = str(self.maxObjID) 132 if self.survey != "": 133 root.attrib['survey'] = self.getPspsSurveyType() 134 try: self.minObjID 135 except: pass 136 else: root.attrib['minObjId'] = str(self.minObjID) 137 try: self.maxObjID 138 except: pass 139 else: root.attrib['maxObjId'] = str(self.maxObjID) 133 140 134 141 # get md5sum … … 198 205 def getPspsSurveyType(self): 199 206 207 try: 208 self.survey 209 except: 210 return "NA" 211 200 212 if self.survey == "ThreePi": return "3PI" 201 elif self.survey == "MD04": return "MD04" 202 else: self.logger.error("Don't know this survey: " + self.survey) 213 elif self.survey == "MD04": return "MD4" 214 else: 215 self.logger.error("Don't know this survey: '" + self.survey + "'") 216 return "NA" 203 217 204 218 ''' … … 232 246 self.maxObjID = rs.getLong(2) 233 247 234 print "MIN mAX = %d %d" % (self.minObjID, self.maxObjID)235 236 248 ''' 237 249 Updates a table with surveyID … … 332 344 Imports IPP tables from FITS file 333 345 334 Accepts a regular expression filter so not all tabl s need to be imported346 Accepts a regular expression filter so not all tables need to be imported 335 347 ''' 336 348 def importIppTables(self, filter): 337 349 338 350 tables = stilts.treads(self.inputFitsPath) 351 self.logger.info("Attempting to import tables from input FITS file") 339 352 340 353 count = 0 … … 343 356 match = re.match(filter, table.name) 344 357 if not match: continue 345 self.logger.info(" Creating IPP table " + table.name)358 self.logger.info(" Reading IPP table " + table.name + " from FITS file") 346 359 table = stilts.tpipe(table, cmd='explodeall') 360 361 # IPP FITS files are littered with infinities, so remove these 362 self.logger.info(" Removing Infinity values from all columns") 363 table = stilts.tpipe(table, cmd='replaceval -Infinity null *') 364 table = stilts.tpipe(table, cmd='replaceval Infinity null *') 365 347 366 try: 348 367 table.write(self.localUrl + '#' + table.name) 349 368 except: 350 self.logger.exception(" Problem writing table '" + table.name + "' to the database")369 self.logger.exception(" Problem writing table '" + table.name + "' to the database") 351 370 352 371 count = count + 1 353 372 354 self.logger.info(" Imported %d tables from '%s' " % (count, self.inputFitsPath))373 self.logger.info("Done. Imported %d tables" % count) 355 374 356 375 self.indexIppTables() … … 367 386 for table in self.pspsTables: 368 387 _table = stilts.tread(self.localUrl + '#SELECT * FROM ' + table.name) 388 # if table.name == "StackDetection": _table.cmd_keepcols('stackDetectID projectionCellID').cmd_head(4).write() 389 390 self.logger.info(" Replacing NULLs with weird PSPS -999 constant for " + table.name) 391 _table = stilts.tpipe(_table, cmd='replaceval "" -999 *') # TODO doesn't work 392 #if table.name == "StackDetection": _table.cmd_keepcols('stackDetectID projectionCellID').cmd_head(4).write() 369 393 _table = stilts.tpipe(_table, cmd='tablename ' + table.name) 370 394 _tables.append(_table) … … 480 504 sql = "DROP TABLE dvo" 481 505 self.localStmt.execute(sql) 482 sql = "CREATE TABLE dvo (ippDetectID BIGINT PRIMARY KEY, ippObjID BIGINT, objID BIGINT)"506 sql = "CREATE TABLE dvo (ippDetectID BIGINT PRIMARY KEY, detectID BIGINT, ippObjID BIGINT, objID BIGINT)" 483 507 self.localStmt.execute(sql) 484 508 509 510 ''' 511 Calls DVO program to 'query' DVO database and populate results to local MySQL Db table 512 ''' 513 def getIDsFromDVO(self, sourceID, imageID): 514 515 # TODO path to DVO prog hardcoded temporarily 516 cmd = "../src/dvo %s %s %s" % (self.dvoLocation, sourceID, imageID) 517 self.logger.info("Running: '" + cmd + "'...") 518 p = Popen(cmd, shell=True, stdout=PIPE) 519 p.wait() 520 # out = p.stdout.read() 521 self.logger.info("...done") 522
Note:
See TracChangeset
for help on using the changeset viewer.
