Changeset 34630
- Timestamp:
- Oct 31, 2012, 11:54:39 AM (14 years ago)
- Location:
- trunk/ippToPsps/jython
- Files:
-
- 5 edited
-
detectionbatch.py (modified) (4 diffs)
-
dvodetections.py (modified) (7 diffs)
-
objectbatch.py (modified) (2 diffs)
-
scratchdb.py (modified) (3 diffs)
-
stackbatch.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/detectionbatch.py
r34615 r34630 452 452 ,MOMENTS_XY \ 453 453 ,MOMENTS_YY \ 454 , AP_MAG\454 ,POW(10.0, -0.4 *AP_MAG) / " + self.header['EXPTIME'] + " \ 455 455 ,KRON_FLUX / " + self.header['EXPTIME'] + " \ 456 456 ,KRON_FLUX_ERR / " + self.header['EXPTIME'] + " \ … … 458 458 ,PSF_CHISQ \ 459 459 ,FLAGS2 << 32 | FLAGS\ 460 ,SKY \461 ,SKY_SIGMA \460 ,SKY / " + self.header['EXPTIME'] + " \ 461 ,SKY_SIGMA / " + self.header['EXPTIME'] + " \ 462 462 ,EXT_NSIGMA \ 463 463 , 0 \ … … 466 466 , " + str(self.config.dataRelease) + "\ 467 467 FROM " + ippTableName 468 # SA10 todo469 # need to correct formulas for psfFlux/psfFluxErr470 # need to correct apMag apFlux471 # need to correct unites kronFlux/Err to correct units472 # need to change psfqfperfect -> psfqfperfect PSF_QF_PERFECT?473 # need to change psfchisq PSF_CHI_SQ?474 # need to change unites of sky/skyErr to adu/s/pixel475 # need formula for sgsep/psflikelhood476 468 # self.logger.info(sql) 477 469 self.scratchDb.execute(sql) … … 557 549 FROM Detection_" + ota 558 550 self.scratchDb.execute(sql) 559 #SA10 TODO 560 # insert ra/dec/calstuff into Table 561 # heather discovered dec is called 'dec_' 562 sql = "UPDATE " + tableName + " SET ra = -999, dec_ =-999, raErr = -999, decErr = -999, zp = -999, zpErr = -999, expTime = -999, airMass = -999" 551 552 # insert calibration information from dvoDetections into the Table 553 sql = "UPDATE " + tableName + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b \ 554 SET a.ra = b.ra, \ 555 a.dec_ = b.dec_, \ 556 a.raErr = b.raErr, \ 557 a.decErr = b.decErr, \ 558 a.zp = b.zp, \ 559 a.zpErr = b.zpErr, \ 560 a.expTime = b.expTime, \ 561 a.airMass = b.airMass \ 562 WHERE a.objID = b.objID AND a.detectID = b.detectID" 563 563 self.scratchDb.execute(sql) 564 564 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease)) -
trunk/ippToPsps/jython/dvodetections.py
r33686 r34630 44 44 self.importFits( 45 45 cpmPath, 46 "IMAGE_ID DET_ID OBJ_ID CAT_ID EXT_ID DB_FLAGS ",46 "IMAGE_ID DET_ID OBJ_ID CAT_ID EXT_ID DB_FLAGS PHOTCODE AIRMASS M_TIME M_CAL MAG_CAL_ERR D_RA D_DEC PLTSCALE X_CCD_ERR Y_CCD_ERR", 47 47 cpmTableName) 48 48 … … 50 50 self.scratchDb.createIndex(cpmTableName, "CAT_ID") 51 51 self.scratchDb.createIndex(cpmTableName, "OBJ_ID") 52 53 # XXX: Should we create index on PHOTCODE? 52 54 53 55 # we can now report that we have imported this table … … 60 62 self.importFits( 61 63 cptPath, 62 "OBJ_ID CAT_ID EXT_ID ",64 "OBJ_ID CAT_ID EXT_ID RA DEC", 63 65 cptTableName) 64 66 … … 67 69 self.scratchDb.createIndex(cptTableName, "OBJ_ID") 68 70 71 # SA10 72 # Columns needed for DetectionCalib and StackDetectionCalib 73 # zp = photcode.K * (AIRMASS - 1) + photcode.C_LAM * 0.001 - cpm.M_CAL 74 # zpErr = cpm.MAG_CAL_ERR 75 # airMass = cpm.AIRMASS 76 # expTime = POW(10.0, 0.4 * cpm.M_TIME) 77 # ra = cpt.RA - (cpm.D_RA / 3600.0) 78 # dec = cpt.DEC - (cpm.D_DEC / 3600.0) 79 # raErr = cpm.X_CCD_ERR * cpm.PLTSCALE 80 # decErr = cpm.Y_CCD_ERR * cpm.PLTSCALE 81 69 82 self.logger.infoPair("Adding","PSPS objIDs") 70 # first try to add a column for PSPS_OBJ_ID. catch failure and continue83 # first try to add the new columns. catch failure and continue 71 84 try: 72 sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT) "85 sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), (ZP REAL), (RA FLOAT), (DEC FLOAT)" 73 86 self.scratchDb.execute(sql) 74 87 except: 75 88 self.logger.infoPair("Already added PSPS_OBJ_ID column to", cpmTableName) 76 89 77 # shove PSPS objIDs from cpt table into measurement table 78 sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b \ 79 SET a.PSPS_OBJ_ID = b.EXT_ID \ 90 # shove PSPS objIDs from cpt table and the calibrated zero point and coordinates which are formed 91 # by combining values from multiple tables into cpt table 92 sql = "UPDATE " + cpmTableName + " AS a, " + cptTableName + " AS b, " \ 93 + self.scratchDb.dvoPhotcodesTable + " AS c \ 94 SET a.PSPS_OBJ_ID = b.EXT_ID, \ 95 b.ZP = c.C_LAM * 0.001 + c.K * (b.AIRMASS - 1) - b.M_CAL, \ 96 b.RA = a.RA - (b.D_RA / 3600.0), \ 97 b.DEC = a.DEC - (b.D_DEC / 3600.0) \ 80 98 WHERE a.CAT_ID = b.CAT_ID \ 81 AND a.OBJ_ID = b.OBJ_ID" 99 AND a.OBJ_ID = b.OBJ_ID \ 100 AND b.PHOTCODE = c.CODE" 101 82 102 self.scratchDb.execute(sql) 83 103 … … 86 106 # PSPS object IDs assigned in the corresponding cpt file. This is believed to be a chip-boundary 87 107 # issue within DVO. So, for now, we take the first IMAGE_ID/DET_ID detection we find, and ignore the rest 108 # XXX: Bills 2012-10031 Does this problem still exist? 88 109 self.logger.infoPair("Merging into", self.scratchDb.dvoDetectionTable) 89 110 sql = "INSERT IGNORE INTO " + self.scratchDb.dvoDetectionTable + " (\ … … 94 115 ,objID \ 95 116 ,flags \ 117 ,zp \ 118 ,zpErr \ 119 ,airMass \ 120 ,expTime \ 121 ,ra \ 122 ,dec_ \ 123 ,raErr \ 124 ,decErr \ 96 125 ,fileID \ 97 126 ) SELECT \ … … 102 131 ,PSPS_OBJ_ID \ 103 132 ,DB_FLAGS \ 133 ,ZP \ 134 ,MAG_CAL_ERR \ 135 ,AIRMASS \ 136 ,POW(10.0, 0.4 * M_TIME) \ 137 ,RA \ 138 ,DEC \ 139 ,X_CCD_ERR*PLTSCALE \ 140 ,Y_CCD_ERR*PLTSCALE \ 104 141 , " + str(fileId) + " \ 105 142 FROM " + cpmTableName 143 106 144 try: 107 145 self.scratchDb.execute(sql) -
trunk/ippToPsps/jython/objectbatch.py
r34615 r34630 113 113 self.logger.infoPair("Adding magnitudes from", "cps table") 114 114 for filter in filters: 115 116 filterID = self.scratchDb.getFilterID(filter[1]) 115 117 116 118 sql = "UPDATE Object JOIN \ … … 129 131 ," + filter[1] + "80pct = MAG_80/1000 \ 130 132 ," + filter[1] + "Flags = FLAGS \ 131 ," + filter[1] + "StackDetectID = STACK_ID" 132 133 #stackDetectID needs to be filled still for SA10 - currently at STACK_ID for test purposes 134 # everthing should be correctly calculated as mags for SA10 133 ," + filter[1] + "StackDetectID = (10 * STACK_DETECT_ID) + " + str(filterID) 134 135 135 #self.logger.info(sql) 136 136 self.scratchDb.execute(sql) -
trunk/ippToPsps/jython/scratchdb.py
r34441 r34630 68 68 DECLARE t REAL; \ 69 69 DECLARE z REAL; \ 70 DECLARE s INT; \ 71 SET s= SIGN(x); \ 70 72 SET x = ABS(x) / 1.4142135623731; \ 71 73 SET z=ABS(x); \ … … 75 77 SET ans = 2.0 - ans; \ 76 78 END IF; \ 79 SET ans = ans * s; \ 77 80 RETURN ans; \ 78 81 END" … … 385 388 objID BIGINT, \ 386 389 flags INT, \ 390 zp REAL, 391 zpErr REAL, 392 airMass REAL, 393 expTime REAL, 394 ra FLOAT, 395 dec_ FLOAT, 396 raErr REAL 397 decErr REAL, 387 398 PRIMARY KEY (imageID, ippDetectID) \ 388 399 )" -
trunk/ippToPsps/jython/stackbatch.py
r34615 r34630 197 197 sql = "UPDATE StackModelFit AS a, SkyChip_xfit AS b SET \ 198 198 "+model+"Radius=b.EXT_WIDTH_MAJ, \ 199 "+model+"Flux= b.EXT_INST_MAG, \200 "+model+"FluxErr= b.EXT_INST_MAG_SIG,\199 "+model+"Flux=POW(10, -0.4 * b.EXT_INST_MAG) " + str(self.expTime) " , \ 200 "+model+"FluxErr=ABS(b.EXT_INST_MAG_SIG) * POW(10, -0.4 * b.EXT_INST_MAG) " + str(self.expTime) " / 1.085736, \ 201 201 "+model+"Ab=b.EXT_WIDTH_MAJ/b.EXT_WIDTH_MIN, \ 202 202 "+model+"Phi=b.EXT_THETA, \ … … 230 230 "+modelLong+"Covar77=b.EXT_COVAR_06_06 \ 231 231 WHERE a.ippDetectID=b.IPP_IDET AND b.MODEL_TYPE = '"+ippModelType+"'" 232 233 #SA10 convert mag to flux in calculation above234 232 235 233 self.scratchDb.execute(sql) … … 369 367 ,ABS((PSF_INST_MAG_SIG*(POW(10.0, (-0.4*PSF_INST_MAG)) / " + str(self.expTime) + ")) / 1.085736) \ 370 368 ,POW(10.0, (-0.4*PEAK_FLUX_AS_MAG)) / " + str(self.expTime) + " \ 371 ,SKY \372 ,SKY_SIGMA \369 ,SKY / " + str(self.expTime) + " \ 370 ,SKY_SIGMA / " + str(self.expTime) + " \ 373 371 ,EXT_NSIGMA \ 374 372 ,PSF_MAJOR \ … … 388 386 ,MOMENTS_R1 \ 389 387 ,MOMENTS_RH \ 390 , AP_MAG\388 ,POW(10.0, (-0.4*AP_MAG) / " + str(self.expTime) + " \ 391 389 , NULL \ 392 390 ,KRON_FLUX / " + str(self.expTime) + " \ … … 398 396 ," + self.historyModNum + " \ 399 397 FROM SkyChip_psf" 400 401 #SA10 to do402 # put in correct formula for apFlux, psfFlux, psfLikelihood, sgsep403 # need correct units of anything in Flux404 398 self.scratchDb.execute(sql) 405 399 … … 481 475 petRadius=b.PETRO_RADIUS \ 482 476 ,petRadiusErr=b.PETRO_RADIUS_ERR \ 483 ,petFlux= b.PETRO_MAG\484 ,petFluxErr= b.PETRO_MAG_ERR\477 ,petFlux=POW(10.0, -0.4 * b.PETRO_MAG) /" + str(self.expTime) + " \ 478 ,petFluxErr=ABS((b.PETRO_MAG_ERR * POW(10.0, (-0.4*b.petroMag))) / " + str(self.expTime) + " / 1.085736 \ 485 479 ,petR50=b.PETRO_RADIUS_50 \ 486 480 ,petR50Err=b.PETRO_RADIUS_50_ERR \ … … 489 483 ,petCf=b.PETRO_FILL \ 490 484 WHERE a.ippDetectID=b.IPP_IDET" 491 #SA10 Put correct calculation for PetFlux492 485 self.scratchDb.execute(sql) 493 486 … … 620 613 self.logger.info(sql) 621 614 self.scratchDb.execute(sql) 622 #SA10 TODO 623 # insert ra/dec/calstuff into Table 624 # heather discovered dec is called 'dec_' 625 sql = "UPDATE " + tableName + " SET ra = -999, dec_ =-999, raErr = -999, decErr = -999, zp = -999, zpErr = -999, expTime = -999, airMass = -999" 615 # insert calibration information from dvoDetections into the Table 616 sql = "UPDATE " + tableName + " AS a, " + self.scratchDb.dvoDetectionTable + " AS b \ 617 SET a.ra = b.ra, \ 618 a.dec_ = b.dec_, \ 619 a.raErr = b.raErr, \ 620 a.decErr = b.decErr, \ 621 a.zp = b.zp, \ 622 a.zpErr = b.zpErr, \ 623 a.expTime = b.expTime, \ 624 a.airMass = b.airMass \ 625 WHERE a.objID = b.objID AND a.detectID = b.detectID" 626 626 self.logger.info(sql) 627 627 self.scratchDb.execute(sql)
Note:
See TracChangeset
for help on using the changeset viewer.
