Changeset 37748 for trunk/ippToPsps/jython/gpc1db.py
- Timestamp:
- Dec 14, 2014, 5:30:49 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/gpc1db.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/gpc1db.py
r37551 r37748 108 108 AND mjd_obs <= (to_days('" + tend + "') - 678941) " 109 109 # self.logger.infoPair("sql",sql) 110 elif batchType == "DF": 110 elif batchType == "DF": # this is specifically only for WARPSTACK types of diffs - 111 # it only makes sense for the date to come from the warp1 112 # may need to be more clever if we do other types of diffs 111 113 112 114 stage = "diff" 113 sql = "SELECT stuff from stufftable" 115 sql = "SELECT DISTINCT stage_extra1, radeg,decdeg \ 116 FROM addRun \ 117 JOIN addProcessedExp using (add_id) \ 118 JOIN minidvodbRun using (minidvodb_name) \ 119 JOIN minidvodbProcessed using (minidvodb_id) \ 120 JOIN mergedvodbRun using (minidvodb_id) \ 121 JOIN mergedvodbProcessed using (merge_id) \ 122 JOIN diffInputSkyfile \ 123 ON (diff_id = stage_id AND diff_skyfile_id = stage_extra1 \ 124 AND stage = 'diff') \ 125 JOIN skycell using (skycell_id, tess_id) \ 126 JOIN warpRun on (warp1 = warp_id \ 127 AND diffInputSkyfile.skycell_id = skycell_id) \ 128 JOIN fakeRun using (fake_id) \ 129 JOIN camRun using (cam_id) \ 130 JOIN chipRun using (chip_id) \ 131 JOIN rawExp using (exp_id) \ 132 WHERE mergedvodbRun.mergedvodb = '" + dvoDb + "' \ 133 AND minidvodbRun.state = 'merged' \ 134 AND minidvodbProcessed.fault = 0 \ 135 AND mergedvodbRun.state = 'full' \ 136 AND mergedvodbProcessed.fault = 0 \ 137 AND addRun.stage = '" + stage + "' \ 138 AND addRun.state = 'full' \ 139 AND decdeg BETWEEN " + str(minDec) + " AND " + str(maxDec) + " \ 140 AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA) + " \ 141 AND dateobs >= '" + tstart + "'\ 142 AND dateobs <= '" + tend + "'" 143 114 144 115 145 elif batchType == "FW": … … 123 153 JOIN mergedvodbProcessed USING (merge_id) \ 124 154 JOIN fullForceRun USING(ff_id) \ 125 JOIN skycalRun using (skycal_id) 155 JOIN skycalRun using (skycal_id) \ 126 156 JOIN stackRun USING(stack_id) \ 127 157 JOIN stackSumSkyfile using (stack_id) \ … … 222 252 return meta 223 253 254 255 ''' 256 Gets some stack-stage meta data for this sky_id # TODO this SQL could surely be improved 257 ''' 258 def getDiffStageMeta(self, diffSkyfileID): 259 260 self.logger.debug("Querying GPC1 for stack meta data") 261 262 meta = [] 263 sql = "SELECT \ 264 filter,\ 265 diff_mode, \ 266 warp1, \ 267 stack2, \ 268 skycell_id, \ 269 diffRun.software_ver, \ 270 exp_time \ 271 FROM diffRun join diffInputSkyfile using (diff_id) \ 272 JOIN warpRun on (warp1=warp_id) \ 273 JOIN fakeRun using (fake_id) \ 274 JOIN camRun using (cam_id) \ 275 JOIN chipRun using (chip_id) \ 276 JOIN rawExp using (exp_id) \ 277 WHERE diff_skyfile_id = %d" % diffSkyfileID 278 279 try: 280 rs = self.executeQuery(sql) 281 rs.first() 282 except: 283 self.logger.infoPair ("this sql is broken:",sql) 284 self.logger.errorPair("Can't query for", "stack meta data") 285 286 try: 287 meta.append(rs.getString(1)) 288 meta.append(rs.getString(2)) 289 meta.append(rs.getString(3)) 290 meta.append(rs.getString(4)) 291 meta.append(rs.getString(5)) 292 meta.append(rs.getString(6)) 293 meta.append(rs.getString(7)) 294 295 except: 296 self.logger.errorPair("getDiffStageMeta()", "empty meta data") 297 298 return meta 299 300 ''' 301 get diff stage cmf name 302 ''' 303 def getDiffStageCmf(self, dvoDb, diffSkyfileID): 304 print "got here, diffstagecmf" 305 sql = "SELECT DISTINCT diffSkyfile.path_base \ 306 FROM mergedvodbRun join minidvodbRun using (minidvodb_id) \ 307 JOIN addRun using (minidvodb_name) \ 308 JOIN diffInputSkyfile on (diff_skyfile_id = stage_extra1 \ 309 AND diff_id = stage_id AND stage = 'diff') \ 310 JOIN diffSkyfile using (diff_id, skycell_id) \ 311 WHERE diff_skyfile_id = " + str(diffSkyfileID) + " \ 312 AND minidvodbRun.state = 'merged' \ 313 AND mergedvodbRun.state = 'full' \ 314 AND mergedvodbRun.mergedvodb = '" + dvoDb + "' \ 315 AND stage = 'diff'" 316 317 try: 318 rs = self.executeQuery(sql) 319 rs.first() 320 except: 321 self.logger.infoPair("failed sql", sql) 322 self.logger.errorPair("can't query for diff cmf", "dfif_skyfile_id = %d" %diff_skyfile_id) 323 return None 324 print "query worked" 325 try: 326 pathBase = rs.getString(1) 327 except: 328 self.logger.errorPair("no diff cms found for diff_skyfile_id = %d" %diff_skyfile_id) 329 return None 330 print pathBase 331 files = [] 332 if pathBase.startswith("neb"): 333 print "open" 334 f=os.popen("neb-ls -p " + pathBase + ".cmf") 335 for i in f.readlines(): 336 print "i",i 337 files.append(i.rstrip()) 338 print "append" 339 print i 340 if len(files) < 1: return None 341 fits = Fits(self.logger, self.config, files[0]) 342 return fits 343 224 344 ''' 225 345 Gets some camera-stage meta data for this cam_id … … 394 514 def getStackStageCmf(self, dvoDb, stackID): 395 515 396 '''397 sql = "SELECT DISTINCT staticskyResult.path_base \398 FROM staticskyRun \399 JOIN staticskyInput USING(sky_id) \400 JOIN staticskyResult USING(sky_id) \401 JOIN stackRun USING(stack_id) \402 JOIN stackSumSkyfile USING(stack_id) \403 JOIN addRun ON sky_id = stage_id \404 JOIN minidvodbRun USING (minidvodb_name) \405 WHERE stack_id = " + str(stackID) + " \406 AND minidvodbRun.minidvodb_group = '" + dvoDb + "' \407 AND minidvodbRun.state = 'merged' \408 AND stage = 'staticsky'"409 '''410 411 516 sql = "SELECT DISTINCT skycalResult.path_base \ 412 517 FROM skycalRun \ … … 458 563 fits = Fits(self.logger, self.config, files[0]) 459 564 return fits 460 461 # XXX validate the file?462 # if fits.getPrimaryHeaderValue("STK_ID") == str(stackID):463 464 # now find and loop through all cmf files at this path_base465 466 ## XXX the code below was needed when we ingested from staticsky (N files per run)467 ## XXX ingesting from skycal solves this problem (1 file per run)468 ## files=os.popen("neb-ls " + pathBase + "%cmf")469 ## for i in files.readlines():470 ## nebPath = i.rstrip()471 ##472 ## # now attempt to run 'neb-ls -p' to actually read this cmf file473 ## try:474 ## self.logger.debug("Trying to neb-ls -p on '" + nebPath + "'")475 ## paths=os.popen("neb-ls -p " + nebPath)476 ## path = paths.readline().rstrip()477 ## if len(path) < 1:478 ## self.logger.debug("zero length path - skipping")479 ## raise480 ##481 ## print "starint stack stage cmf 3"482 ##483 ## # if we get here, then the cmf is readable, now check the stack_id484 ## fits = Fits(self.logger, self.config, path)485 ## if fits.getPrimaryHeaderValue("STK_ID") == str(stackID):486 ## # we have the right file!487 ## self.logger.debug("SUCCESS!: %s == %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID)))488 ## return fits489 ## else:490 ## # this is not the correct file491 ## self.logger.debug("STACK ID: %s != %s"% (fits.getPrimaryHeaderValue("STK_ID"), str(stackID)))492 ##493 ## # an exception here means that nebulous could not read this file, so we just skip it494 ## except:495 ## self.logger.debug("NEB FAILED SKIPPING")496 ## pass497 565 498 566 '''
Note:
See TracChangeset
for help on using the changeset viewer.
