Changeset 37935 for trunk/ippToPsps/jython/forcedwarpbatch.py
- Timestamp:
- Feb 25, 2015, 1:59:43 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/forcedwarpbatch.py (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/forcedwarpbatch.py
r37917 r37935 6 6 import time 7 7 import stilts 8 import re 8 9 9 10 from java.lang import * … … 54 55 forcedWarpID, 55 56 batchID, 56 "P2", 57 gpc1Db.getForcedWarpStageSmf(forcedWarpID) 58 57 "FW", 58 None) 59 # gpc1Db.getForcedWarpStageSmf(forcedWarpID) 60 # there is a funny problem with order here: we need to open the file first to read the header to get 61 # to skycell ID 62 #forcedWarpID = self.forcedWarpID 63 self.logger.infoPair("getting the fits file for add_id",forcedWarpID) 64 self.fits = gpc1Db.getForcedWarpStageCmf(skychunk.dvoLabel, forcedWarpID) 65 self.forcedWarpID = forcedWarpID 66 self.header = self.fits.getPrimaryHeader() 67 self.warpSkyFileID = self.getKeyValue(self.header,"IMAGEID") 68 self.filterName = self.getKeyValue(self.header,"FPA.FILTERID") 69 self.logger.infoPair("found filterName",self.filterName) 70 self.logger.infoPair("found warp_skyfile_id",self.warpSkyFileID) 59 71 # get camera meta data 60 meta = self.gpc1Db.getForcedWarpStageMeta(self.id) 72 73 meta = self.gpc1Db.getForcedWarpStageMeta(forcedWarpID, self.warpSkyFileID) 74 61 75 if not meta: 62 76 self.logger.errorPair("Could not get", "forced warp metadata") 63 77 raise 64 78 65 self.expID = meta[0]; 66 self.expName = meta[1]; 67 self.distGroup = meta[2]; 68 self.analysisVer = meta[3]; 69 self.bias = meta[4]; 70 self.biasScat = meta[5]; 79 self.expID = meta[0] 80 self.expTime = meta[1] 81 self.analysisVer = meta[2] 82 self.skycellName = meta[3] 83 self.tessName = meta[4] 84 85 self.logger.infoPair("found exp_id",str(self.expID)) 86 self.logger.infoPair("found exp_time",str(self.expTime)) 87 self.logger.infoPair("found skycell_id",self.skycellName) 88 self.logger.infoPair("found tess_id",self.tessName) 89 90 91 #tessName = self.getKeyValue(self.header, 'TESS_ID') 92 #self.tessID = self.scratchDb.getTessID(tessName) 71 93 72 94 if not self.analysisVer: self.analysisVer = -999 95 if self.analysisVer is None: self.analysisVer = "-999" 96 self.logger.infoPair("found analysisVer",self.analysisVer) 97 98 if self.tessName == 'RINGS.V3': 99 100 # skycell is, eg "skycell.1133.081" 101 # 0123456789012345 102 self.projectionID = self.skycellName[8:12] 103 #self.skycellID = self.skycellName[13:] 104 self.skycellID = self.skycellName[8:] 105 else: 106 # skycell is, eg "skycell.081" 107 # 01234567890 108 self.projectionID = 0 109 self.skycellID = self.skycellName[8:11] 110 self.skycellID=self.skycellName[8:] 111 if self.skycellID == "": 112 self.skycellID = -1 113 114 self.logger.infoPair("projection cell found ",self.projectionID) 115 self.logger.infoPair("skycell found", self.skycellID) 116 117 73 118 74 119 # create an output filename, which is {expID}.FITS 75 self.outputFitsFile = "%08d.FITS" % self.expID120 self.outputFitsFile = "%08d.FITS" % forcedWarpID 76 121 self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile) 77 122 self.dropTableVerbose("ForcedWarpMeasurement") … … 79 124 self.dropTableVerbose("ForcedWarpMeta") 80 125 self.dropTableVerbose("ForcedWarpToImage") 126 self.dropTableVerbose("ForcedWarpLensing") 81 127 if not self.config.retry: 82 self.scratchDb.dropTable("ForcedWarpMeasurement") 83 self.scratchDb.dropTable("ForcedWarpExtended") 84 self.scratchDb.dropTable("ForcedWarpMeta") 85 self.scratchDb.dropTable("ForcedWarpToImage") 128 self.scratchDb.dropTable("ForcedWarpMeasurement") 129 self.scratchDb.dropTable("ForcedWarpExtended") 130 self.scratchDb.dropTable("ForcedWarpMeta") 131 self.scratchDb.dropTable("ForcedWarpToImage") 132 self.scratchDb.dropTable("ForcedWarpLensing") 86 133 self.historyModNum = "0" 87 134 88 135 # get a few primary header values. if in test mode, then use defaults 89 if self.safeDictionaryAccessWithDefault(self.header, 'MJD-OBS', "1") == "NULL": 90 self.logger.errorPair("Could not get", "MJD-OBS") 91 raise 92 93 94 if self.safeDictionaryAccessWithDefault(self.header, 'EXPTIME', "1") == "NULL": 95 self.logger.errorPair("Could not get", "EXPTIME") 96 raise 97 98 if self.safeDictionaryAccessWithDefault(self.header, 'FILTERID', "g.0000") == "NULL": 99 self.logger.errorPair("Could not get", "FILTERID") 100 raise 101 136 self.logger.infoPair("calculating ObsTime","ok") 102 137 # MJD-OBS is the exposure start, EXTIME / 172800 = (EXPTIME sec / 84600 sec/day) / 2 103 self.obsTime = float(self.header['MJD-OBS']) + (float(self. header['EXPTIME']) / 172800.0)104 138 self.obsTime = float(self.header['MJD-OBS']) + (float(self.expTime) / 172800.0) 139 self.logger.infoPair("obstime",self.obsTime) 105 140 # set up some defauts 106 141 self.calibModNum = 0 107 142 self.totalNumPhotoRef = 0 108 143 109 110 self.filter = self.header['FILTERID'][0:1] 111 self.filterID = self.scratchDb.getFilterID(self.filter) 144 self.filterID = self.scratchDb.getFilterID(self.filterName[0]) 145 self.logger.infoPair("filterID is ",self.filterID) 112 146 113 147 # insert what we know about this stack batch into the stack table 114 self.ippToPspsDb.insertDetectionMeta(self.batchID, self.expID, self.filter) 148 self.logger.infoPair("inserting basics into ","ForcedWarpMeta") 149 150 self.ippToPspsDb.insertForcedWarpMeta(int(self.batchID), int(self.expID), self.filterName[0]) 115 151 116 152 # dump stuff to log 117 self.logger.infoPair(" CamID", "%d" % self.id)118 self.logger.infoPair("Exp ID", "%d" %self.expID)119 self.logger.infoPair("Exp name", "%s" % self.expName) 120 self.logger.infoPair("Distribution group", "%s" % self.distGroup) 153 self.logger.infoPair("add ID", "%d" % self.id) 154 self.logger.infoPair("Exp ID", self.expID) 155 156 121 157 122 158 … … 129 165 self.logger.infoPair("Processing table", "ForcedWarpMeta") 130 166 131 photoCalID = str(self.scratchDb.getPhotoCalID(forcedWarpID))132 167 header = self.header 168 # photoCalID = str(self.scratchDb.getPhotoCalID(forcedWarpID)) 133 169 134 170 sqlLine = sqlUtility("INSERT INTO ForcedWarpMeta (") … … 136 172 #surveyID (below) 137 173 #filterdID (below) 174 sqlLine.group("forcedWarpID", str(self.forcedWarpID)) 138 175 sqlLine.group("skyCellID", str(self.skycellID)) 139 sqlLine.group("photoCalID", photoCalID)176 # sqlLine.group("photoCalID", photoCalID) 140 177 sqlLine.group("magSat", self.getKeyFloat(header, "%.8f", 'FSATUR')) 141 sqlLine.group("analVer", s elf.analysisVer);142 sqlLine.group("expTime", self.getKeyFloat(self.header, "%.8f", 'EXPREQ'));178 sqlLine.group("analVer", str(self.analysisVer)) 179 sqlLine.group("expTime",self.expTime) 143 180 sqlLine.group("completMag", self.getKeyFloat(header, "%.8f", 'FLIMIT')) 144 sqlLine.group("astroScat", self.getKeyFloat(header, "%.8f", 'CERROR')) 145 sqlLine.group("photoScat", self.getKeyFloat(self.header, "%.8f", 'ZPT_ERR')); 146 sqlLine.group("nAstroRef", self.getKeyValue(header, 'NASTRO')) 147 sqlLine.group("nPhotoRef", self.getKeyValue(header, 'NASTRO')) 181 # sqlLine.group("astroScat", self.getKeyFloat(header, "%.8f", 'CERROR')) 182 # sqlLine.group("photoScat", self.getKeyFloat(self.header, "%.8f", 'ZPT_ERR')); 183 #no nastro 184 # sqlLine.group("nAstroRef", self.getKeyValue(header, 'NASTRO')) 185 # sqlLine.group("nPhotoRef", self.getKeyValue(header, 'NASTRO')) 148 186 sqlLine.group("psfModelID", self.getKeyValue(header, 'PSFMODEL')) 149 187 sqlLine.group("psfFwhm_mean", self.getKeyFloat(header, "%.8f", 'FWHM_MAJ')) 150 188 sqlLine.group("psfFwhm_max", self.getKeyFloat(header, "%.8f", 'FW_MJ_UQ')) 151 sqlLine.group("photoZero", self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS'))189 # sqlLine.group("photoZero", self.getKeyFloat(self.header, "%.8f", 'ZPT_OBS')) 152 190 #photoColor -- how do I set this? it's also not set in stack meta 153 191 sqlLine.group("ctype1", self.getKeyValue(self.header, 'CTYPE1')); … … 174 212 self.scratchDb.updateAllRows("ForcedWarpMeta", "batchID", str(self.batchID)) 175 213 self.scratchDb.updateAllRows("ForcedWarpMeta", "surveyID", str(self.surveyID)) 176 self.scratchDb.updateFilterID("ForcedWarpMeta", self.filter) 214 # self.scratchDb.updateFilterID("ForcedWarpMeta", self.filterID) 215 self.scratchDb.updateFilterID("ForcedWarpMeta",self.filterName[0]) 177 216 self.scratchDb.updateAllRows("ForcedWarpMeta", "calibModNum", str(self.calibModNum)) 178 217 self.scratchDb.updateAllRows("ForcedWarpMeta", "dataRelease", str(self.skychunk.dataRelease)) 179 self.tablesToExport.append("ForcedWarpMeta")218 #self.tablesToExport.append("ForcedWarpMeta") 180 219 181 220 ''' … … 186 225 self.logger.infoPair("Procesing table", "ForcedWarpToImage") 187 226 188 for filter in self.filters: 189 190 forcedwarpID = self.forcedwarpID 191 if forcedwarpID > 0: 227 forcedwarpID = self.forcedWarpID 228 if forcedwarpID > 0: 192 229 193 230 imageIDs = self.gpc1Db.getImageIDsForThisForcedWarpID(forcedwarpID) … … 198 235 VALUES (\ 199 236 " + str(forcedwarpID) + ", " + imageID + ")" 200 self.scratchDb.execute(sql) 201 237 try: self.scratchDb.execute(sql) 238 except: 239 self.logger.infoPair("can't execute sql",sql) 240 raise 202 241 # now update StackMeta with correct number of inputs 203 242 204 self.tablesToExport.append("ForcedWarpToImage")243 #self.tablesToExport.append("ForcedWarpToImage") 205 244 206 245 … … 211 250 Populates the ForcedWarpMeasurement table 212 251 ''' 213 def populateForcedWarpMeasurement Table(self, results):252 def populateForcedWarpMeasurement(self): 214 253 215 254 pspsTableName = "ForcedWarpMeasurement" 216 ippTableName = " ForcedWarpMeasurement_psf"255 ippTableName = "SkyChip_psf" 217 256 218 257 219 258 self.logger.infoPair("Procesing table", "ForcedWarpMeasurement") 220 259 260 BEFORE = self.scratchDb.getRowCount(ippTableName) 261 extTimeString = str(self.expTime) 262 263 #missing are zp, telluricExt, airmass (not easy to get ?) 264 265 sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (") 266 sqlLine.group("ippDetectID", "IPP_IDET") 267 sqlLine.group("forcedWarpID", str(self.forcedWarpID)); 268 sqlLine.group("randomWarpID", "FLOOR(RAND("+str(self.batchID)+")*9223372036854775807)") 269 sqlLine.group("filterID", str(self.filterID)) 270 sqlLine.group("surveyID", str(self.surveyID)) 271 sqlLine.group("skycellID", str(self.skycellID)) 272 sqlLine.group("expTime", str(self.expTime)) 273 sqlLine.group("obsTime", str(self.obsTime)) 274 sqlLine.group("psfFlux", "PSF_INST_FLUX / "+extTimeString) 275 sqlLine.group("psfFluxErr", "PSF_INST_FLUX_SIG / "+extTimeString) 276 sqlLine.group("psfMajorFWHM", "PSF_FWHM_MAJ") 277 sqlLine.group("psfMinorFWHM", "PSF_FWHM_MIN") 278 sqlLine.group("psfTheta", "PSF_THETA") 279 sqlLine.group("psfCore", "PSF_CORE") 280 sqlLine.group("psfQf", "PSF_QF") 281 sqlLine.group("psfQfPerfect", "PSF_QF_PERFECT") 282 sqlLine.group("psfChiSq", "PSF_CHISQ") 283 sqlLine.group("psfLikelihood", "psfLikelihood(EXT_NSIGMA)") 284 sqlLine.group("momentXX", "MOMENTS_XX") 285 sqlLine.group("momentXY", "MOMENTS_XY") 286 sqlLine.group("momentYY", "MOMENTS_YY") 287 sqlLine.group("momentR1", "MOMENTS_R1") 288 sqlLine.group("momentRH", "MOMENTS_RH") 289 sqlLine.group("momentM3C", "MOMENTS_M3C") 290 sqlLine.group("momentM3S", "MOMENTS_M3S") 291 sqlLine.group("momentM4C", "MOMENTS_M4C") 292 sqlLine.group("momentM4S", "MOMENTS_M4S") 293 sqlLine.group("apFlux","AP_FLUX / " + extTimeString) 294 sqlLine.group("apFluxErr","AP_FLUX_SIG / " + extTimeString) 295 sqlLine.group("apFillF","AP_NPIX / (3.14159265359 * POW(AP_MAG_RADIUS - 0.5, 2))") 296 sqlLine.group("kronFlux","KRON_FLUX / " + extTimeString) 297 sqlLine.group("kronFluxErr","KRON_FLUX_ERR / " + extTimeString ) 298 sqlLine.group("kronRad","MOMENTS_R1 * 2.5") 299 sqlLine.group("sky","SKY /" +extTimeString) 300 sqlLine.group("skyErr","SKY_SIGMA / "+extTimeString) 301 sqlLine.group("infoFlag","FLAGS") 302 sqlLine.group("infoFlag2","FLAGS2") 303 sqlLine.group("dataRelease",str(self.skychunk.dataRelease)) 304 305 sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName) 306 307 try: self.scratchDb.execute(sql) 308 except: 309 self.logger.errorPair("failed sql: ", sql) 310 raise 311 312 313 314 221 315 # insert the per-object data (IDs, random stack ID, dataRelease, etc) 222 self.selectDvoObjIDs() 223 224 self.generateRandomIDs() 316 #self.selectDvoObjIDs() 317 self.logger.infoPair("inserting dvo info: find imageID","from externID") 318 imageID = self.scratchDb.getImageIDFromExternID(self.warpSkyFileID) 319 self.logger.infoPair("updating","forcedWarpMeasurement") 320 sqlLine = sqlUtility("UPDATE ForcedWarpMeasurement as a, " + self.scratchDb.dvoDetectionTable + " as b SET ") 321 sqlLine.group("a.objID","b.objID") 322 sqlLine.group("a.detectID","b.detectID") 323 sqlLine.group("a.ippObjID","b.ippObjID") 324 sqlLine.group("a.dvoRegionID","b.catID") 325 sqlLine.group("a.zp","b.zp") 326 sqlLine.group("a.telluricExt","b.telluricExt") 327 sqlLine.group("a.airmass","b.airmass") 328 sql = sqlLine.makeEquals("WHERE a.ippDetectID = b.ippDetectID AND b.imageID = " +str( imageID)) 329 try: self.scratchDb.execute(sql) 330 except: 331 self.logger.errorPair("failed sql:",sql) 332 raise 333 self.logger.infoPair("need to cull"," nulls objid") 334 results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpMeasurement", "objID") 335 336 337 338 # self.generateRandomIDs() 225 339 226 340 self.logger.infoPair("Adding 'row' columns to", "ForcedWarpMeasurement") … … 233 347 # add indexes ForcedWarpMeasurement 234 348 self.scratchDb.createIndex("ForcedWarpMeasurement", "objID") 235 349 self.scratchDb.createIndex("ForcedWarpMeasurement", "ippDetectID") 350 ''' 351 Populates the ForcedWarpExtended table 352 ''' 353 def populateForcedWarpExtended(self): 354 355 pspsTableName = "ForcedWarpExtended" 356 ippTableName = "SkyChip_xrad" 357 358 #self.tablesToExport.append("ForcedWarpExtended") 359 360 #isert stuff from SkyChip_psf 361 sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (") 362 sqlLine.group("ippDetectID", "IPP_IDET") 363 sqlLine.group("flxR5", "APER_FLUX_5") 364 sqlLine.group("flxR5Err", "APER_FLUX_ERR_5" ) 365 sqlLine.group("flxR5Std", "APER_FLUX_STDEV_5") 366 sqlLine.group("flxR5Fill", "APER_FILL_5") 367 sqlLine.group("flxR6", "APER_FLUX_6") 368 sqlLine.group("flxR6Err", "APER_FLUX_ERR_6" ) 369 sqlLine.group("flxR6Std", "APER_FLUX_STDEV_6") 370 sqlLine.group("flxR6Fill", "APER_FILL_6") 371 372 sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName) 373 374 try: self.scratchDb.execute(sql) 375 except: 376 self.logger.errorPair("failed sql: ", sql) 377 raise 378 379 #insert the things from FOrcedWarpMeasurement 380 self.logger.infoPair("inserting objID,etc from","ForcedWarpMeasurement") 381 sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, ForcedWarpMeasurement as b SET ") 382 sqlLine.group("a.objID","b.objID") 383 sqlLine.group("a.uniquePspsFWid","b.uniquePspsFWid") 384 sqlLine.group("a.detectID","b.detectID") 385 sqlLine.group("a.ippObjID","b.ippObjID") 386 sqlLine.group("a.filterID","b.filterID") 387 sqlLine.group("a.surveyID","b.surveyID") 388 sqlLine.group("a.forcedWarpID","b.forcedWarpID") 389 sqlLine.group("a.randomWarpID","b.randomWarpID") 390 sqlLine.group("a.skycellID","b.skycellID") 391 sqlLine.group("a.dvoRegionID","b.dvoRegionID") 392 sqlLine.group("a.obsTime","b.obsTime") 393 sql = sqlLine.makeEquals("Where a.ippDetectID = b.ippDetectID") 394 try: self.scratchDb.execute(sql) 395 except: 396 self.logger.errorPair("failed sql: ", sql) 397 raise 398 399 # add in the psps unique ids from stuff 400 self.logger.infoPair("adding information from Skychip_xrad into","ForcedWarpExtended") 401 402 # cull bad d 403 self.logger.infoPair("need to cull"," nulls objid") 404 results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpExtended", "objID") 405 406 self.scratchDb.createIndex("ForcedWarpExtended", "objID") 236 407 237 408 238 409 239 240 241 242 243 244 self.tablesToExport.append("ForcedWarpMeasurement") 245 246 247 ''' 248 Populates the ForcedWarpExtended table 249 ''' 250 def populateForcedWarpExtendedTable(self, results): 251 252 pspsTableName = "ForcedWarpExtended" 253 ippTableName = "ForcedWarpExtended_psf" 254 255 256 self.tablesToExport.append("ForcedWarpExtended") 257 258 # get dvo ids, 259 # add in the psps unique ids from stuff 410 ''' 411 Populates the ForcedWarpExtended table 412 ''' 413 def populateForcedWarpLensing(self): 414 415 pspsTableName = "ForcedWarpLensing" 416 ippTableName = "SkyChip_psf" 417 418 #self.tablesToExport.append("ForcedWarpExtended") 419 420 #isert stuff from SkyChip_psf 421 sqlLine = sqlUtility("INSERT INTO " + pspsTableName + " (") 422 sqlLine.group("ippDetectID", "IPP_IDET") 423 sqlLine.group("lensObjSmearX11", "LENS_X11_SM_OBJ") 424 sqlLine.group("lensObjSmearX12", "LENS_X12_SM_OBJ") 425 sqlLine.group("lensObjSmearX22", "LENS_X22_SM_OBJ") 426 sqlLine.group("lensObjSmearE1", "LENS_E1_SM_OBJ") 427 sqlLine.group("lensObjSmearE2", "LENS_E2_SM_OBJ") 428 sqlLine.group("lensObjShearX11", "LENS_X11_SH_OBJ") 429 sqlLine.group("lensObjShearX12", "LENS_X12_SH_OBJ") 430 sqlLine.group("lensObjShearX22", "LENS_X22_SH_OBJ") 431 sqlLine.group("lensObjShearE1", "LENS_E1_SH_OBJ") 432 sqlLine.group("lensObjShearE2", "LENS_E2_SH_OBJ") 433 sqlLine.group("lensPSFSmearX11", "LENS_X11_SM_PSF") 434 sqlLine.group("lensPSFSmearX12", "LENS_X12_SM_PSF") 435 sqlLine.group("lensPSFSmearX22", "LENS_X22_SM_PSF") 436 sqlLine.group("lensPSFSmearE1", "LENS_E1_SM_PSF") 437 sqlLine.group("lensPSFSmearE2", "LENS_E2_SM_PSF") 438 sqlLine.group("lensPSFShearX11", "LENS_X11_SH_PSF") 439 sqlLine.group("lensPSFShearX12", "LENS_X12_SH_PSF") 440 sqlLine.group("lensPSFShearX22", "LENS_X22_SH_PSF") 441 sqlLine.group("lensPSFShearE1", "LENS_E1_SH_PSF") 442 sqlLine.group("lensPSFShearE2", "LENS_E2_SH_PSF") 443 sql = sqlLine.makeRaw(") SELECT ", " FROM " + ippTableName) 444 445 try: self.scratchDb.execute(sql) 446 except: 447 self.logger.errorPair("failed sql: ", sql) 448 raise 449 450 #insert the things from FOrcedWarpMeasurement 451 self.logger.infoPair("inserting objID,etc from","ForcedWarpMeasurement") 452 sqlLine = sqlUtility("UPDATE " + pspsTableName + " as a, ForcedWarpMeasurement as b SET ") 453 sqlLine.group("a.objID","b.objID") 454 sqlLine.group("a.uniquePspsFWid","b.uniquePspsFWid") 455 sqlLine.group("a.detectID","b.detectID") 456 sqlLine.group("a.ippObjID","b.ippObjID") 457 sqlLine.group("a.filterID","b.filterID") 458 sqlLine.group("a.surveyID","b.surveyID") 459 sqlLine.group("a.forcedWarpID","b.forcedWarpID") 460 sqlLine.group("a.randomWarpID","b.randomWarpID") 461 sqlLine.group("a.skycellID","b.skycellID") 462 sqlLine.group("a.dvoRegionID","b.dvoRegionID") 463 sqlLine.group("a.obsTime","b.obsTime") 464 sql = sqlLine.makeEquals("Where a.ippDetectID = b.ippDetectID") 465 try: self.scratchDb.execute(sql) 466 except: 467 self.logger.errorPair("failed sql: ", sql) 468 raise 469 470 # add in the psps unique ids from stuff 471 self.logger.infoPair("adding information from Skychip_psf into","ForcedWarpLensing") 472 473 # cull bad d 474 self.logger.infoPair("need to cull"," nulls objid") 475 results= self.scratchDb.reportAndDeleteRowsWithNULLS("ForcedWarpLensing", "objID") 476 477 self.scratchDb.createIndex("ForcedWarpLensing", "objID") 478 479 260 480 261 481 ''' … … 269 489 270 490 #this should be done 491 self.logger.infoPair("Populating","ForcedWarpMeta") 271 492 self.populateForcedWarpMeta() 272 273 self.populateForcedWarpMeasurement() 493 self.tablesToExport.append("ForcedWarpMeta") 494 495 self.logger.infoPair("Populating","ForcedWarpMeasurement") 496 self.populateForcedWarpMeasurement() 497 self.tablesToExport.append("ForcedWarpMeasurement") 498 499 self.logger.infoPair("Populating","ForcedWarpExtended") 274 500 self.populateForcedWarpExtended() 501 self.tablesToExport.append("ForcedWarpExtended") 502 503 self.logger.infoPair("Populating","ForcedWarpLensing") 504 self.populateForcedWarpLensing() 505 self.tablesToExport.append("ForcedWarpLensing") 506 507 508 self.logger.infoPair("Populating","ForcedWarpToImage") 275 509 self.populateForcedWarpToImage() 276 510 self.tablesToExport.append("ForcedWarpToImage") 511 512 513 self.logger.infoPair("setting min/max objid from","ForcedWarpMeasurement") 277 514 self.setMinMaxObjID(["ForcedWarpMeasurement"]) 278 515 … … 286 523 ''' 287 524 def importIppTables(self, columns="*", tableRE=""): 288 525 count = 0 289 526 if self.config.retry: return True 290 527 self.logger.infoPair("Importing FW tables with table match expression: ", tableRE) … … 307 544 308 545 # drop any previous tables before import 546 309 547 self.scratchDb.dropTable(table.name) 310 548 … … 323 561 self.logger.infoPair("Done. Imported", "%d tables" % count) 324 562 self.indexIppTables() 325 326 563 return True 327 564 328 565 329 330 331 332 333 334 335 336 566 def generateRandomIDs(self): 337 sql = "UPDATE ForcedWarpMeasurement set randomWarpID = FLOOR(RAND("+str(self.batchID)+")*9223372036854775807)" 338 try: self.scratchDb.execute(sql) 567 sql = "UPDATE ForcedWarpMeasurement set randomWarpID = FLOOR(RAND("+str(self.batchID)+")*9223372036854775807)" 568 try: 569 self.scratchDb.execute(sql) 339 570 except: 340 571 self.logger.errorPair('failed sql',sql) 341 r eturn572 raise 342 573 343 574 … … 346 577 ''' 347 578 348 def generatePspsUniqueIDs(self): 349 # sql = "UPDATE ForcedWarpMeasurement join (select @r:=@r+1 rownum, objID from \ 350 # (select @r:=0) r, ForcedWarpMeasurement t) as foo using (objID) set \ 351 # uniquePspsFWid = ((" +str(self.batchID)+ "*1000000000 ) + rownum)" 579 def generateUniquePspsIDs(self): 352 580 sql = "UPDATE ForcedWarpMeasurement set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + row)" 353 354 581 try: self.scratchDb.execute(sql) 355 582 except: 356 583 self.logger.errorPair('failed sql',sql) 357 return 358 359 360 361 362 363 584 raise 585 586 ''' 587 Defines the tables to be exported to psps 588 ''' 364 589 365 590 def exportPspsTablesToFits(self, regex="(.*)"): 366 return super(DetectionBatch, self).exportPspsTablesToFits("(ForcedWarp.*)") 591 return super(ForcedWarpBatch, self).exportPspsTablesToFits("(ForcedWarp.*)") 592 593 594 ''' 595 Drop a table and report the drop 596 ''' 597 def dropTableVerbose(self, table): 598 self.logger.infoPair("dropping table:",table) 599 self.scratchDb.dropTable(table) 600 601 602 ''' 603 Applies indexes to the PSPS tables 604 ''' 605 def alterPspsTables(self): 606 607 self.logger.debug("Altering PSPS tables (currently does nothing in stackbatch)") 608 609 return True 610 611 ''' 612 Applies indexes to the IPP tables 613 ''' 614 def indexIppTables(self): 615 616 self.logger.infoPair("Creating indexes on", "IPP tables") 617 self.scratchDb.createIndex("SkyChip_psf", "IPP_IDET") 618 self.scratchDb.createIndex("SkyChip_xfit", "IPP_IDET") 619 self.scratchDb.createIndex("SkyChip_xrad", "IPP_IDET") 620 self.scratchDb.createIndex("SkyChip_xsrc", "IPP_IDET") 621 self.scratchDb.createIndex("SkyChip_xgal", "IPP_IDET") 622 623 return True 624 625 ''' 626 Updates table and generates pspsuniqueids 627 ''' 628 629 def updatePspsUniqueIDs(self,table): 630 sql = "UPDATE ForcedWarpMeasurement set uniquePspsFWid = (("+str(self.batchID)+"*1000000000 ) + row)" 631 try: self.scratchDb.execute(sql) 632 except: 633 self.logger.errorPair('failed sql',sql) 634 raise
Note:
See TracChangeset
for help on using the changeset viewer.
