- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/stackbatch.py (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/ippToPsps/jython/stackbatch.py
r32061 r33415 19 19 ''' 20 20 StackBatch class 21 22 This class, a sub-class of Batch, processes single stack skycells in the form of IPP cmf files 23 21 24 ''' 22 25 class StackBatch(Batch): … … 27 30 def __init__(self, 28 31 logger, 29 configPath, 30 configDoc, 32 config, 31 33 gpc1Db, 32 34 ippToPspsDb, 33 stackID): 35 scratchDb, 36 stackID, 37 batchID, 38 useFullTables): 34 39 35 40 super(StackBatch, self).__init__( 36 41 logger, 37 configPath, 38 configDoc, 42 config, 39 43 gpc1Db, 40 44 ippToPspsDb, 45 scratchDb, 41 46 stackID, 47 batchID, 42 48 "ST", 43 gpc1Db.getStackStageCmf(stackID)) 49 gpc1Db.getStackStageCmf(config.dvoLabel, stackID), 50 useFullTables) 44 51 45 52 if not self.everythingOK: return … … 49 56 # get stack meta data 50 57 meta = self.gpc1Db.getStackStageMeta(self.id) 58 if not meta: 59 self.everythingOK = False 60 return 61 51 62 self.filter = meta[0]; 52 63 self.filter = self.filter[0:1] 64 self.filterID = self.scratchDb.getFilterID(self.filter) 53 65 self.skycell = meta[1]; 54 # TODO HACK fix this 66 67 # skycell is, eg "skycell.1133.081" 68 # we need 1133.081 for skycell, but store as an int, so instead store 1133081 69 # projection cell is just the 1133 bit 70 # this is how it should be done 71 #self.projectioncell = self.skycell[8:12] 72 #self.skycell = self.skycell[8:] 73 #self.skycell = self.skycell.replace(".", "") 74 #self.projectioncell = self.skycell[8:12] 75 76 # TODO this is the wrong way, but is consistent with SkyCell table in IN data 55 77 self.skycell = self.skycell[8:12] 56 # mangling e.g. 0683.043 into 0683043 for now until we have a schema change57 #self.skycell = self.skycell.replace(".", "") 78 self.projectioncell = self.skycell 79 58 80 self.analysisVer = meta[2]; 59 81 … … 77 99 self.scratchDb.dropTable("SkyChip_xsrc") 78 100 79 # create an output filename, which is { filterID}{skycellID}.FITS101 # create an output filename, which is {stackID}.FITS 80 102 self.outputFitsFile = "%08d.FITS" % self.id 81 103 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) … … 90 112 if not self.useFullTables: 91 113 self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID']) 92 93 114 94 115 # dump stuff to log … … 96 117 self.logger.infoPair("Stack type", "%s" % self.stackType) 97 118 self.logger.infoPair("Skycell", "%s" % self.skycell) 119 self.logger.infoPair("Projectioncell", "%s" % self.projectioncell) 98 120 self.logger.infoPair("Filter", "%s" % self.filter) 99 100 101 121 102 122 ''' … … 247 267 ,expTime \ 248 268 ,psfModelID \ 269 ,psfFwhm_mean \ 270 ,psfFwhm_max \ 249 271 ,ctype1 \ 250 272 ,ctype2 \ … … 266 288 ," + str(self.expTime) + " \ 267 289 ,'" + self.safeDictionaryAccess(self.header, 'PSFMODEL') + "' \ 290 ,'" + self.safeDictionaryAccess(self.header, 'FWHM_MAJ') + "' \ 291 ,'" + self.safeDictionaryAccess(self.header, 'FW_MJ_UQ') + "' \ 268 292 ,'" + self.header['CTYPE1'] + "' \ 269 293 ,'" + self.header['CTYPE2'] + "' \ … … 283 307 self.scratchDb.updateAllRows("StackMeta", "surveyID", str(self.surveyID)) 284 308 self.scratchDb.updateFilterID("StackMeta", self.filter) 285 self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self. dataRelease))309 self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self.config.dataRelease)) 286 310 self.updateStackTypeID("StackMeta") 287 311 … … 297 321 ippDetectID \ 298 322 ,skyCellID \ 323 ,projectionCellID \ 299 324 ,obsTime \ 300 325 ,xPos \ … … 311 336 ,psfWidMinor \ 312 337 ,psfTheta \ 338 ,psfLikelihood \ 313 339 ,infoFlag \ 314 340 ,psfCf \ … … 335 361 IPP_IDET \ 336 362 ," + self.skycell + " \ 363 ," + self.projectioncell + " \ 337 364 ," + self.header['MJD-OBS'] + " \ 338 365 ,X_PSF \ … … 349 376 ,PSF_MINOR \ 350 377 ,PSF_THETA \ 378 ,psfLikelihood(EXT_NSIGMA) \ 351 379 ,FLAGS << 32 | FLAGS2 \ 352 380 ,PSF_QF \ … … 375 403 self.scratchDb.updateAllRows("StackDetection", "surveyID", str(self.surveyID)) 376 404 self.scratchDb.updateFilterID("StackDetection", self.filter) 377 self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self. dataRelease))405 self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.config.dataRelease)) 378 406 self.scratchDb.updateAllRows("StackDetection", "primaryF", "0") 379 407 self.scratchDb.updateAllRows("StackDetection", "activeFlag", "0") … … 381 409 self.updateStackTypeID("StackDetection") 382 410 self.updateDvoIDs("StackDetection") 383 sql = "ALTER TABLE StackDetection ADD PRIMARY KEY (objID, stackDetectID)"384 self.scratchDb.execute(sql) 385 411 sql = "ALTER IGNORE TABLE StackDetection ADD PRIMARY KEY (objID)" 412 self.scratchDb.execute(sql) 413 386 414 if self.stackType == "DEEP_STACK": 387 415 … … 390 418 SET instFlux = 2*b.PSF_INST_FLUX_SIG \ 391 419 WHERE instFlux IS NULL \ 420 AND a.ippDetectID = b.IPP_IDET \ 392 421 AND b.PSF_INST_FLUX_SIG IS NOT NULL" 393 422 self.scratchDb.execute(sql) 394 # instFlux = 2*PSF_INST_FLUX_SIG395 423 396 424 self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "instFlux") … … 417 445 # TODO temporarily loading 1st convolved fluxes into unconvolved fields 418 446 self.logger.infoPair("Adding fluxes", "un-convolved") 419 self.updateApFlxs("", " < 7.0")447 self.updateApFlxs("", "IS NULL") 420 448 self.logger.infoPair("Adding fluxes", "1st convolved") 421 449 self.updateApFlxs("c1", "< 7.0") … … 433 461 ,petR90=b.PETRO_RADIUS_90 \ 434 462 ,petR90Err=b.PETRO_RADIUS_90_ERR \ 463 ,petCf=b.PETRO_FILL \ 435 464 WHERE a.ippDetectID=b.IPP_IDET" 436 465 self.scratchDb.execute(sql) … … 438 467 self.scratchDb.updateAllRows("StackApFlx", "surveyID", str(self.surveyID)) 439 468 self.scratchDb.updateFilterID("StackApFlx", self.filter) 440 self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self. dataRelease))469 self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self.config.dataRelease)) 441 470 self.scratchDb.updateAllRows("StackApFlx", "primaryF", "0") 442 471 self.scratchDb.updateAllRows("StackApFlx", "activeFlag", "0") … … 490 519 rs.first() 491 520 nMissing = rs.getInt(1) 492 self.logger.infoPair("Detections deleted from %s that are not in StackDetection" + table, "%5d" % nMissing)493 521 494 522 if nMissing < 1: return … … 496 524 sql = "DELETE FROM " + table + " WHERE ippDetectID NOT IN (SELECT ippDetectID FROM StackDetection)" 497 525 self.scratchDb.execute(sql) 526 self.logger.infoPair("Detections not in StackDetection", "%d deleted from %s" % (nMissing, table)) 498 527 499 528 … … 527 556 objID \ 528 557 ,ippObjID \ 558 ,projectionCellID \ 529 559 ) \ 530 560 SELECT \ 531 561 DISTINCT objID \ 532 562 ,ippObjID \ 563 ,projectionCellID \ 533 564 FROM StackDetection" 534 565 self.scratchDb.execute(sql) … … 569 600 self.scratchDb.createIndex("StackModelFit", "ippDetectID") 570 601 602 return True 603 571 604 ''' 572 605 Applies indexes to the IPP tables … … 580 613 self.scratchDb.createIndex("SkyChip_xsrc", "IPP_IDET") 581 614 615 return True 616 582 617 ''' 583 618 Updates provided table with DVO IDs from DVO table … … 587 622 imageID = self.scratchDb.getImageIDFromExternID(self.header['SOURCEID'], self.header['IMAGEID']) 588 623 self.logger.debug("Updating table '" + table + "' with DVO IDs...") 589 sql = "UPDATE IGNORE" + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \624 sql = "UPDATE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \ 590 625 a.ippObjID = b.ippObjID, \ 591 a.stackDetectID = b.detectID, \626 a.stackDetectID = 10 * b.detectID + " + str(self.filterID) + ", \ 592 627 a.objID = b.objID \ 593 628 WHERE a.ippDetectID = b.ippDetectID \
Note:
See TracChangeset
for help on using the changeset viewer.
