Changeset 34630 for trunk/ippToPsps/jython/dvodetections.py
- Timestamp:
- Oct 31, 2012, 11:54:39 AM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/dvodetections.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.
