Changeset 35097 for trunk/ippToPsps/jython/dvodetections.py
- Timestamp:
- Feb 6, 2013, 3:16:35 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
-
trunk/ippToPsps/jython
- Property svn:ignore
-
old new 1 1 *.class 2 Makefile 3 Makefile.in
-
- Property svn:ignore
-
trunk/ippToPsps/jython/dvodetections.py
r34630 r35097 20 20 Constructor 21 21 ''' 22 def __init__(self, logger, config, s cratchDbName):22 def __init__(self, logger, config, skychunk, ippToPspsDb, scratchDbName): 23 23 24 super(DvoDetections, self).__init__(logger, config, s cratchDbName)24 super(DvoDetections, self).__init__(logger, config, skychunk, ippToPspsDb, scratchDbName) 25 25 26 26 # declare DVO file types of interest … … 32 32 def ingestRegion(self, region): 33 33 34 cpmPath = self. config.dvoLocation + "/" + region + ".cpm"35 cptPath = self. config.dvoLocation + "/" + region + ".cpt"34 cpmPath = self.skychunk.dvoLocation + "/" + region + ".cpm" 35 cptPath = self.skychunk.dvoLocation + "/" + region + ".cpt" 36 36 37 37 cpmTableName = self.scratchDb.getDbFriendlyTableName(region + ".cpm") … … 83 83 # first try to add the new columns. catch failure and continue 84 84 try: 85 sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), (ZP REAL), (RA FLOAT), (DECFLOAT)"85 sql = "ALTER TABLE " + cpmTableName + " ADD COLUMN (PSPS_OBJ_ID BIGINT), ADD COLUMN (ZP REAL), ADD COLUMN (RA FLOAT), ADD COLUMN (DEC_ FLOAT)" 86 86 self.scratchDb.execute(sql) 87 87 except: 88 self.logger.infoPair("Already added PSPS_OBJ_ID column to", cpmTableName) 88 # failed, but may be due to mysql error 89 self.logger.infoPair("mysql error or already added PSPS_OBJ_ID column to", cpmTableName) 90 # self.logger.infoPair("sql command", sql) 89 91 90 92 # shove PSPS objIDs from cpt table and the calibrated zero point and coordinates which are formed 91 93 # 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) \ 98 WHERE a.CAT_ID = b.CAT_ID \ 99 AND a.OBJ_ID = b.OBJ_ID \ 100 AND b.PHOTCODE = c.CODE" 94 sql = "UPDATE " \ 95 + cpmTableName + " AS meas, " \ 96 + cptTableName + " AS ave, " \ 97 + self.scratchDb.dvoPhotcodesTable + " AS phot \ 98 SET \ 99 meas.PSPS_OBJ_ID = ave.EXT_ID, \ 100 meas.ZP = phot.C_LAM * 0.001 + phot.K * (meas.AIRMASS - 1) - meas.M_CAL, \ 101 meas.RA = ave.RA - (meas.D_RA / 3600.0), \ 102 meas.DEC_ = ave.DEC_ - (meas.D_DEC / 3600.0) \ 103 WHERE meas.CAT_ID = ave.CAT_ID \ 104 AND meas.OBJ_ID = ave.OBJ_ID \ 105 AND meas.PHOTCODE = phot.CODE" 101 106 107 # EAM : add some debug I/O 108 # self.logger.infoPair("sql command", sql) 102 109 self.scratchDb.execute(sql) 103 110 … … 136 143 ,POW(10.0, 0.4 * M_TIME) \ 137 144 ,RA \ 138 ,DEC \145 ,DEC_ \ 139 146 ,X_CCD_ERR*PLTSCALE \ 140 147 ,Y_CCD_ERR*PLTSCALE \ 141 148 , " + str(fileId) + " \ 142 149 FROM " + cpmTableName 150 151 # print "sql :", sql 152 # response = raw_input("prepare to insert dvoDetectionTable ") 143 153 144 154 try: … … 148 158 return False 149 159 finally: 160 # response = raw_input("insert dvoDetectionTable ") 150 161 self.logger.infoPair("Dropping tables", "%s and %s" % (cpmTableName, cptTableName)) 151 162 self.scratchDb.dropTable(cpmTableName) … … 155 166 156 167 return True 157 158
Note:
See TracChangeset
for help on using the changeset viewer.
