- Timestamp:
- Apr 21, 2014, 5:42:34 AM (12 years ago)
- Location:
- branches/eam_branches/ps2-tc3-20130727
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ps2-tc3-20130727
- Property svn:mergeinfo changed
-
branches/eam_branches/ps2-tc3-20130727/ippToPsps
- Property svn:mergeinfo deleted
-
branches/eam_branches/ps2-tc3-20130727/ippToPsps/jython/gpc1db.py
r35417 r36680 49 49 NB this uses Bill's potentially temporary 'skycells' database when finding RA/Dec for stacks. 50 50 ''' 51 def getItemsInThisDVODbForThisStage(self, dvoDb, batchType, minRA=-999, maxRA=999, minDec=-999, maxDec=999 ):51 def getItemsInThisDVODbForThisStage(self, dvoDb, batchType, minRA=-999, maxRA=999, minDec=-999, maxDec=999, tstart="0000-00-00 00:00:00", tend = "0000-00-00 00:00:00"): 52 52 53 53 self.logger.debugPair("GPC1 RA range", "%.2f -> %.2f" % (minRA, maxRA)) 54 54 self.logger.debugPair("GPC1 Dec range", "%.2f -> %.2f" % (minDec, maxDec)) 55 55 56 56 rows = [] 57 57 … … 80 80 AND addRun.state = 'full' \ 81 81 AND decl BETWEEN RADIANS(" + str(minDec) + ") AND RADIANS(" + str(maxDec) + ") \ 82 AND ra BETWEEN RADIANS(" + str(minRA) + ") AND RADIANS(" + str(maxRA) + ")" 82 AND ra BETWEEN RADIANS(" + str(minRA) + ") AND RADIANS(" + str(maxRA) + ") \ 83 AND dateobs >= '" + tstart + "'\ 84 AND dateobs <= '" + tend + "'" 83 85 84 86 elif batchType == "ST": … … 91 93 JOIN mergedvodbRun USING(minidvodb_id) \ 92 94 JOIN mergedvodbProcessed USING (merge_id) \ 93 JOIN stackRun USING(stack_id) JOIN skycell USING(skycell_id) \ 95 JOIN stackRun USING(stack_id) \ 96 JOIN stackSumSkyfile using (stack_id) \ 97 JOIN skycell USING(skycell_id) \ 94 98 WHERE mergedvodbRun.mergedvodb = '" + dvoDb + "' \ 95 99 AND minidvodbRun.state = 'merged' \ … … 100 104 AND addRun.state = 'full' \ 101 105 AND decdeg BETWEEN " + str(minDec) + " AND " + str(maxDec) + " \ 102 AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA) 103 106 AND radeg BETWEEN " + str(minRA) + " AND " + str(maxRA) + " \ 107 AND mjd_obs >= (to_days('" + tstart + "')-678941) \ 108 AND mjd_obs <= (to_days('" + tend + "') - 678941) " 109 self.logger.infoPair("sql",sql) 104 110 try: 105 111 # XXX EAM : test output … … 212 218 Gets a camera-stage smf for this cam_id 213 219 ''' 214 def getCameraStageSmf(self, camID ):215 220 def getCameraStageSmf(self, camID, smfversion): 221 self.logger.infoPair("using", smfversion) 216 222 self.logger.debug("Querying GPC1 for camera smf files with cam_id = " + str(camID)) 217 223 … … 237 243 # list all smf files if a neb path 238 244 files = [] 239 if path.startswith("neb"): 240 241 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 242 f=os.popen("neb-ls -p "+path+"%smf") 243 for i in f.readlines(): 244 files.append(i.rstrip()) 245 246 # or not a neb path 247 else: 248 files = glob.glob(path + ".smf") 245 246 247 #there are a couple of states for smfversion 248 249 # "use_new" => we have reprocessed the data, use the .smf file 250 251 # "not_reproc" => this has not been reprocessed, use the .smf file 252 253 # "use_original" => we *may* have reprocessed the data, 254 # use (file).smf.original if camRun.state = 'full' and if there is a .smf and .orig 255 # use (file).smf if camRun.state = 'full' and if there is only a .smf 256 # fault out if camRun.state != 'full' -- that is a race condition we don't want. 257 258 259 if (smfversion == "not_reproc") or (smfversion == "use_new"): 260 if path.startswith("neb"): 261 262 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 263 f=os.popen("neb-ls -p "+path+"%smf") 264 for i in f.readlines(): 265 files.append(i.rstrip()) 266 267 # or not a neb path 268 else: 269 files = glob.glob(path + ".smf") 270 271 if (smfversion == "use_original"): 272 # get state of camRun 273 sql = "SELECT state \ 274 FROM camProcessedExp \ 275 JOIN camRun USING(cam_id) \ 276 WHERE camRun.cam_id = %d" % camID 277 try: 278 rs = self.executeQuery(sql) 279 rs.first() 280 except: 281 self.logger.errorPair("Can't query for camRun.state for cam_id", str(camID)) 282 return None 283 284 try: 285 # get state of camRun.cam_id 286 camrunstate = rs.getString(1) 287 except: 288 self.logger.errorPair("No state found for cam_id", str(camID) ) 289 return None 290 291 if (camrunstate == "full"): 292 self.logger.infoPair("camRun.state is ",camrunstate) 293 # if full find smf files 294 if path.startswith("neb"): 295 296 # XXX EAM : this should just use the name (path.smf) instead of a wildcard, right? 297 fsmf=os.popen("neb-ls -p "+path+"%smf") 298 fsmfs = fsmf.readlines() 299 fsmforig=os.popen("neb-ls -p "+path+"%smf.original") 300 fsmforigs = fsmforig.readlines() 301 smfCount = len(fsmfs) 302 smfOrigCount = len (fsmforigs) 303 304 if (smfCount > 0 and smfOrigCount > 0): 305 #smf and original so use original 306 self.logger.infoPair("using:", path+"%smf.original") 307 for i in fsmforigs: 308 files.append(i.rstrip()) 309 310 if (smfCount > 0 and smfOrigCount == 0): 311 self.logger.infoPair("using:", path+"%smf") 312 #smf file and no smf.original use .smf 313 for i in fsmfs: 314 files.append(i.rstrip()) 315 316 #if not smf dont' find files ??) 317 # or not a neb path 318 319 else: 320 # this is broken for non neb - on the other hand we probably won't do .original if so 321 files = glob.glob(path + ".smf") 322 323 324 325 # if .smf and .original use .original 326 else: 327 self.logger.infoPair("camRun.state not full, can't ingest", str(camID) ) 328 return None 329 249 330 250 331 # XXX EAM : test output
Note:
See TracChangeset
for help on using the changeset viewer.
