Changeset 38951
- Timestamp:
- Oct 23, 2015, 9:50:16 AM (11 years ago)
- Location:
- trunk/ippToPsps/jython
- Files:
-
- 6 edited
-
detectionbatch.py (modified) (7 diffs)
-
dvo.py (modified) (1 diff)
-
forcedwarpbatch.py (modified) (4 diffs)
-
mysql.py (modified) (2 diffs)
-
scratchdb.py (modified) (3 diffs)
-
stackbatch.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/detectionbatch.py
r38929 r38951 199 199 def populateImageMetaTable(self, ota, header): 200 200 201 # does this chip exist in the DVO image table? (if NOT, then skip it) 202 if not self.scratchDb.haveThisChip(self.imageIDs[ota], self.sourceIDs[ota]): 203 self.logger.info("| %5s | ------------- Chip not in DVO : rejecting ------------ |" % ota) 204 return False 205 201 206 # the supplied 'header' matches this chip 202 207 # self.header is the PHU header for this smf … … 231 236 zp = self.getKeyFloat(header, "%.8f", 'ZPT_OBS') 232 237 238 zpImage = self.scratchDb.getImageZeroPoint(self.imageIDs[ota]) 239 233 240 # XXX zp correction should come from DVO 234 detectionThreshold = detectionThreshold + zp - 2.5 * math.log10(expTime)241 detectionThreshold = detectionThreshold + zpImage - 2.5 * math.log10(expTime) 235 242 236 243 # insert image metadata into table … … 246 253 sqlLine.group("astroScat", astroscat) 247 254 sqlLine.group("photoScat", self.getKeyFloat(header, "%.8f", 'ZPT_ERR')) 248 sqlLine.group("photoZero", zp )255 sqlLine.group("photoZero", zpImage) 249 256 sqlLine.group("nAstroRef", self.getKeyValue(header, 'NASTRO')) 250 257 sqlLine.group("nPhotoRef", self.getKeyValue(header, 'NASTRO')) … … 629 636 630 637 # populate ImageMeta 631 self.populateImageMetaTable(chipname, header) 638 if not self.populateImageMetaTable(chipname, header): 639 self.logger.infoPair("skipping chip: ", chipname) 640 return False 641 632 642 self.updateImageID("ImageMeta_" + chipname, x, y) 633 643 … … 810 820 ota = x*10+y 811 821 812 813 822 self.logger.info("add psps unique p2 ids") 814 823 self.updatePspsUniqueIDs("Detection_" + chipname, ota) … … 901 910 if x==7 and y==7: continue 902 911 912 # skip chips which were not loaded 903 913 ota = "XY%d%d" % (x, y) 904 914 extension = ota + ".psf" 905 915 if extension not in self.tablesLoaded: continue 906 916 907 if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1 917 # skip chips which had a problem (e.g., not in DVO) 918 if not self.populatePspsTablesChip(ota, x, y, results, tables): 919 if self.skipBatch: 920 self.logger.error("fatal problem for exposure, skipping") 921 return False 922 continue 923 924 otaCount = otaCount + 1 925 self.populateImageDetEffMetaTablePart2(ota) 926 927 extension = "Chip.psf" 928 if extension in self.tablesLoaded: 929 if not self.populatePspsTablesChip("Chip", 0, 0, results, tables): 930 print "--- skipped Chip.psf" 908 931 if self.skipBatch: 909 932 self.logger.error("fatal problem for exposure, skipping") 910 933 return False 911 912 self.populateImageDetEffMetaTablePart2(ota) 913 914 915 extension = "Chip.psf" 916 if extension in self.tablesLoaded: 917 if self.populatePspsTablesChip("Chip", 0, 0, results, tables): otaCount = otaCount + 1 918 if self.skipBatch: 919 self.logger.error("fatal problem for exposure, skipping") 920 return False 934 else: 935 otaCount = otaCount + 1 936 937 print "--- tried Chip.psf" 921 938 922 939 # print totals … … 931 948 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+") 932 949 950 print "--- tried Chip.psf (2)" 951 933 952 # if we only have one table export, i.e. FrameMeta, then get out of here (skip batch, but do not abort) 934 953 if len(self.tablesToExport) == 1: -
trunk/ippToPsps/jython/dvo.py
r38889 r38951 146 146 self.importFits( 147 147 path, 148 "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM",148 "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS MCAL SECZ PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM", 149 149 self.scratchDb.dvoImagesTable) 150 150 self.logger.infoPair("Adding primary key to", self.scratchDb.dvoImagesTable) -
trunk/ippToPsps/jython/forcedwarpbatch.py
r38945 r38951 133 133 self.logger.infoPair("found exp_id", str(self.expID[num])) 134 134 self.logger.infoPair("found exp_time", str(self.expTime[num])) 135 self.logger.infoPair("found filter", str(self.filterNam [num]))135 self.logger.infoPair("found filter", str(self.filterName[num])) 136 136 self.logger.infoPair("found skycell_id", self.skycellName[num]) 137 137 self.logger.infoPair("found tess_id", self.tessName[num]) … … 216 216 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) 217 217 218 219 220 218 # dump stuff to log 221 219 self.logger.infoPair("add ID", "%d" % self.id) 222 223 # self.logger.infoPair("Exp ID", self.expID)224 225 226 227 228 229 220 230 221 ''' … … 243 234 self.logger.infoPair("found header","ok") 244 235 245 # photoCalID = str(self.scratchDb.getPhotoCalID(header['IMAGEID'])) 246 247 # XXX fix this: 248 photoCalID = GPC1.filtername.ForcedWarp 236 photoCalID = str(self.scratchDb.getPhotoCalID(header['IMAGEID'])) 237 238 # PHOTCODE and FILTER are not in the header; reconstruct here 239 # photoCalID = "GPC1.%s.ForcedWarp" % self.filterName[num][0] 240 241 zpImage = self.scratchDb.getImageZeroPoint(header['IMAGEID']) 249 242 250 243 # XXX hard-wired platescale : 0.25 … … 285 278 # sqlLine.group("psfFwhm_max", self.getKeyFloat(header, "%.8f", 'FW_MJ_UQ')) 286 279 287 # XXX: should psfTheta include the angle of the source chip in some way?288 280 sqlLine.group("psfTheta", self.getKeyFloat(header, "%.8f", 'ANGLE')) 289 sqlLine.group("photoZero", self.getKeyFloat(header, "%.8f", 'FPA.ZP')) 281 282 # sqlLine.group("photoZero", self.getKeyFloat(header, "%.8f", 'FPA.ZP')) 283 sqlLine.group("photoZero", zpImage) 284 290 285 # photoColor -- how do I set this? it's also not set in stack meta 291 286 sqlLine.group("ctype1", self.getKeyValue(header, 'CTYPE1')); -
trunk/ippToPsps/jython/mysql.py
r38853 r38951 8 8 from java.lang import * 9 9 from java.sql import * 10 from xml.etree.ElementTree import ElementTree10 # from xml.etree.ElementTree import ElementTree 11 11 12 12 ''' … … 355 355 print "--- " + str(e) 356 356 os._exit(2) 357 358 # stmt.close()359 357 return rs 360 358 -
trunk/ippToPsps/jython/scratchdb.py
r38879 r38951 214 214 215 215 ''' 216 Gets photcode (aka photoCalID from dvo table) 217 ''' 218 def getImageZeroPoint(self, externID): 219 220 zeroPoint = -999 221 222 sql = "SELECT MCAL, SECZ, C_LAM, K FROM %s AS a JOIN %s as b WHERE EXTERN_ID = %s AND a.PHOTCODE = b.CODE" % (self.dvoImagesTable, self.dvoPhotcodesTable, (externID)) 223 rs = self.executeQuery(sql) 224 if not rs: 225 print "missing result set for imageID query" 226 os._exit(2) 227 228 if not rs.first(): 229 self.logger.infoPair("no zero point; image is missing, imageID: ", imageID) 230 return zeroPoint 231 232 Mcal = rs.getFloat(1) 233 airmass = rs.getFloat(2) 234 Clam = rs.getFloat(3) 235 Klam = rs.getFloat(4) 236 237 zeroPoint = 0.001*Clam + Klam*(airmass - 1.0) - Mcal 238 return zeroPoint 239 240 ''' 216 241 Updates a table with filterID grabbed from Filter init table 217 242 ''' … … 449 474 " AND SOURCE_ID = " + str(sourceID) 450 475 451 try: 452 rs = self.executeQuery(sql) 453 454 if not rs: 455 print "missing result set for imageID query" 456 raise 457 458 # if no returned rows, return an error 459 if not rs.next(): 460 self.logger.infoPair("DVO lacks imageID ", imageID) 461 return False 462 463 if rs.getInt(1) == int(imageID): 464 # print "DVO has imageID ", imageID 465 return True 466 467 else: 468 self.logger.error("DVO has wrong imageID? ") 469 self.logger.error("imageID: ", imageID) 470 self.logger.error("EXTERN_ID: ", rs.getInt(1)) 471 self.logger.infoPair("sql: ", sql) 472 raise 473 474 except: 475 print "DVO imageID query failed ", imageID 476 print "sql: ", sql 476 rs = self.executeQuery(sql) 477 if not rs: 478 print "missing result set for imageID query" 477 479 raise 478 480 479 # how can I reach this? 481 # if no returned rows, return an error 482 if not rs.next(): 483 self.logger.infoPair("DVO lacks imageID ", imageID) 484 return False 485 486 if rs.getInt(1) != int(imageID): 487 self.logger.error("DVO has wrong imageID? ") 488 self.logger.error("imageID: ", imageID) 489 self.logger.error("EXTERN_ID: ", rs.getInt(1)) 490 self.logger.infoPair("sql: ", sql) 491 os._exit(2) 492 493 # print "DVO has imageID ", imageID 480 494 return True 481 495 … … 497 511 EXTERN_ID INT, \ 498 512 FLAGS INT, \ 513 MCAL FLOAT, \ 514 SECZ FLOAT, \ 499 515 PHOTCODE SMALLINT, \ 500 516 XPIX_SYS_ERR FLOAT, \ -
trunk/ippToPsps/jython/stackbatch.py
r38939 r38951 261 261 zpErr = self.getKeyFloat(header, "%.8f", 'ZPT_ERR') 262 262 263 zpImage = self.scratchDb.getImageZeroPoint(stackID) 264 263 265 # XXX zp correction should come from DVO 264 detectionThreshold = detectionThreshold + zp - 2.5 * math.log10(expTime)266 detectionThreshold = detectionThreshold + zpImage - 2.5 * math.log10(expTime) 265 267 266 268 # insert stack metadata into table … … 287 289 # sqlLine.group("psfFwhm_max", fwhm_maj_uq) 288 290 sqlLine.group("astroScat", astroscat) 289 sqlLine.group("photoZero", zp )291 sqlLine.group("photoZero", zpImage) 290 292 sqlLine.group("photoScat", zpErr) 291 293 sqlLine.group("nAstroRef", header['NASTRO'])
Note:
See TracChangeset
for help on using the changeset viewer.
