- Timestamp:
- Jan 11, 2012, 11:19:21 PM (15 years ago)
- Location:
- branches/meh_branches/ppsub_test
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippToPsps/jython/stackbatch.py (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppsub_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppsub_test/ippToPsps/jython/stackbatch.py
r32061 r33098 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): … … 31 34 gpc1Db, 32 35 ippToPspsDb, 33 stackID): 36 stackID, 37 batchID): 34 38 35 39 super(StackBatch, self).__init__( … … 40 44 ippToPspsDb, 41 45 stackID, 46 batchID, 42 47 "ST", 43 48 gpc1Db.getStackStageCmf(stackID)) … … 49 54 # get stack meta data 50 55 meta = self.gpc1Db.getStackStageMeta(self.id) 56 if not meta: 57 self.everythingOK = False 58 return 59 51 60 self.filter = meta[0]; 52 61 self.filter = self.filter[0:1] 53 62 self.skycell = meta[1]; 54 # TODO HACK fix this 63 64 # skycell is, eg "skycell.1133.081" 65 # we need 1133.081 for skycell, but store as an int, so instead store 1133081 66 # projection cell is just the 1133 bit 67 # this is how it should be done 68 #self.projectioncell = self.skycell[8:12] 69 #self.skycell = self.skycell[8:] 70 #self.skycell = self.skycell.replace(".", "") 71 #self.projectioncell = self.skycell[8:12] 72 73 # TODO this is the wrong way, but is consistent with SkyCell table in IN data 55 74 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(".", "") 75 self.projectioncell = self.skycell 76 58 77 self.analysisVer = meta[2]; 59 78 … … 77 96 self.scratchDb.dropTable("SkyChip_xsrc") 78 97 79 # create an output filename, which is { filterID}{skycellID}.FITS98 # create an output filename, which is {stackID}.FITS 80 99 self.outputFitsFile = "%08d.FITS" % self.id 81 100 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) … … 90 109 if not self.useFullTables: 91 110 self.scratchDb.insertNewDvoExternID(self.header['SOURCEID'], self.header['IMAGEID']) 92 93 111 94 112 # dump stuff to log … … 96 114 self.logger.infoPair("Stack type", "%s" % self.stackType) 97 115 self.logger.infoPair("Skycell", "%s" % self.skycell) 116 self.logger.infoPair("Projectioncell", "%s" % self.projectioncell) 98 117 self.logger.infoPair("Filter", "%s" % self.filter) 99 100 101 118 102 119 ''' … … 247 264 ,expTime \ 248 265 ,psfModelID \ 266 ,psfFwhm_mean \ 267 ,psfFwhm_max \ 249 268 ,ctype1 \ 250 269 ,ctype2 \ … … 266 285 ," + str(self.expTime) + " \ 267 286 ,'" + self.safeDictionaryAccess(self.header, 'PSFMODEL') + "' \ 287 ,'" + self.safeDictionaryAccess(self.header, 'FWHM_MAJ') + "' \ 288 ,'" + self.safeDictionaryAccess(self.header, 'FW_MJ_UQ') + "' \ 268 289 ,'" + self.header['CTYPE1'] + "' \ 269 290 ,'" + self.header['CTYPE2'] + "' \ … … 297 318 ippDetectID \ 298 319 ,skyCellID \ 320 ,projectionCellID \ 299 321 ,obsTime \ 300 322 ,xPos \ … … 311 333 ,psfWidMinor \ 312 334 ,psfTheta \ 335 ,psfLikelihood \ 313 336 ,infoFlag \ 314 337 ,psfCf \ … … 335 358 IPP_IDET \ 336 359 ," + self.skycell + " \ 360 ," + self.projectioncell + " \ 337 361 ," + self.header['MJD-OBS'] + " \ 338 362 ,X_PSF \ … … 349 373 ,PSF_MINOR \ 350 374 ,PSF_THETA \ 375 ,psfLikelihood(EXT_NSIGMA) \ 351 376 ,FLAGS << 32 | FLAGS2 \ 352 377 ,PSF_QF \ … … 381 406 self.updateStackTypeID("StackDetection") 382 407 self.updateDvoIDs("StackDetection") 383 sql = "ALTER TABLE StackDetection ADD PRIMARY KEY (objID, stackDetectID)"384 self.scratchDb.execute(sql) 385 408 sql = "ALTER IGNORE TABLE StackDetection ADD PRIMARY KEY (objID)" 409 self.scratchDb.execute(sql) 410 386 411 if self.stackType == "DEEP_STACK": 387 412 … … 390 415 SET instFlux = 2*b.PSF_INST_FLUX_SIG \ 391 416 WHERE instFlux IS NULL \ 417 AND a.ippDetectID = b.IPP_IDET \ 392 418 AND b.PSF_INST_FLUX_SIG IS NOT NULL" 393 419 self.scratchDb.execute(sql) 394 # instFlux = 2*PSF_INST_FLUX_SIG395 420 396 421 self.scratchDb.reportAndDeleteRowsWithNULLS("StackDetection", "instFlux") … … 527 552 objID \ 528 553 ,ippObjID \ 554 ,projectionCellID \ 529 555 ) \ 530 556 SELECT \ 531 557 DISTINCT objID \ 532 558 ,ippObjID \ 559 ,projectionCellID \ 533 560 FROM StackDetection" 534 561 self.scratchDb.execute(sql) … … 569 596 self.scratchDb.createIndex("StackModelFit", "ippDetectID") 570 597 598 return True 599 571 600 ''' 572 601 Applies indexes to the IPP tables … … 580 609 self.scratchDb.createIndex("SkyChip_xsrc", "IPP_IDET") 581 610 611 return True 612 582 613 ''' 583 614 Updates provided table with DVO IDs from DVO table … … 587 618 imageID = self.scratchDb.getImageIDFromExternID(self.header['SOURCEID'], self.header['IMAGEID']) 588 619 self.logger.debug("Updating table '" + table + "' with DVO IDs...") 589 sql = "UPDATE IGNORE" + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \620 sql = "UPDATE " + table + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b SET \ 590 621 a.ippObjID = b.ippObjID, \ 591 622 a.stackDetectID = b.detectID, \
Note:
See TracChangeset
for help on using the changeset viewer.
