Changeset 31831 for trunk/ippToPsps/jython/gpc1db.py
- Timestamp:
- Jul 6, 2011, 4:22:01 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/gpc1db.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/gpc1db.py
r31806 r31831 8 8 9 9 from mysql import MySql 10 from fits import Fits 10 11 from java.sql import * 11 12 … … 54 55 rs.close() 55 56 56 self.logger. info("Found %d items in DVO database '" % (len(ids)))57 self.logger.debug("Found %d items in DVO database '" % (len(ids))) 57 58 58 59 return ids … … 61 62 Gets a list of ids in this DVO database for this stage, could be cam or staticsky (so far) 62 63 ''' 63 def getIDsInThisDVODbForThisStage(self, dvoDb, stage): 64 65 sql = "SELECT DISTINCT stage_id \ 66 FROM addRun \ 67 WHERE stage = '" + stage + "' \ 68 AND dvodb = '" + dvoDb + "'" 64 def getIDsInThisDVODbForThisStage(self, dvoDb, batchType): 65 66 if batchType == "P2": # TODO define these someplace 67 68 stage = "cam" 69 sql = "SELECT DISTINCT stage_id \ 70 FROM addRun \ 71 WHERE stage = '" + stage + "' \ 72 AND dvodb = '" + dvoDb + "'" 73 74 elif batchType == "ST": 75 76 stage = "staticsky" 77 sql = "SELECT DISTINCT stack_id \ 78 FROM gpc1.staticskyInput \ 79 JOIN gpc1.addRun ON(gpc1.staticskyInput.sky_id = gpc1.addRun.stage_id) \ 80 WHERE stage = '" + stage + "' \ 81 AND dvodb = '" + dvoDb + "'" 69 82 70 83 try: … … 79 92 rs.close() 80 93 81 self.logger. info("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage))94 self.logger.debug("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage)) 82 95 83 96 return ids … … 116 129 Gets some stack-stage meta data for this sky_id # TODO this SQL could surely be improved 117 130 ''' 118 def getStackStageMeta(self, s kyID, filter):131 def getStackStageMeta(self, stackID): 119 132 120 133 self.logger.debug("Querying GPC1 for stack meta data") … … 122 135 meta = [] 123 136 sql = "SELECT \ 124 stackRun.stack_id,\ 125 stackRun.skycell_id, \ 126 stackRun.software_ver \ 127 FROM \ 128 staticskyInput, staticskyRun, stackRun, staticskyResult \ 129 WHERE staticskyRun.sky_id = staticskyInput.sky_id \ 130 AND staticskyInput.stack_id = stackRun.stack_id \ 131 AND staticskyInput.sky_id = staticskyResult.sky_id \ 132 and staticskyInput.sky_id = %d \ 133 and filter = '%s'" % (skyID, filter) 134 135 136 try: 137 rs = self.executeQuery(sql) 138 rs.first() 139 meta.append(rs.getInt(1)) 137 filter,\ 138 skycell_id, \ 139 software_ver \ 140 FROM stackRun \ 141 WHERE stack_id = %d" % stackID 142 143 try: 144 rs = self.executeQuery(sql) 145 rs.first() 146 meta.append(rs.getString(1)) 140 147 meta.append(rs.getString(2)) 141 148 meta.append(rs.getString(3)) … … 212 219 213 220 ''' 214 Gets all cmf files for this sky_id. handles both absolute paths and neb paths 215 ''' 216 def getStackStageCmfs(self, skyID): 217 218 self.logger.debug("Querying GPC1 for stack cmf files") 219 220 sql = "SELECT path_base, num_inputs \ 221 FROM staticskyResult \ 222 WHERE sky_id = %d" % skyID 223 224 try: 225 rs = self.executeQuery(sql) 226 rs.first() 221 Gets the path to the cmf file for this stack_id 222 ''' 223 def getStackStageCmf(self, stackID): 224 225 sql = "SELECT staticskyResult.path_base \ 226 FROM staticskyRun \ 227 JOIN staticskyInput USING(sky_id) \ 228 JOIN staticskyResult USING(sky_id) \ 229 JOIN stackRun USING(stack_id) \ 230 JOIN stackSumSkyfile USING(stack_id) \ 231 WHERE stack_id = %s" % stackID 232 233 try: 234 rs = self.executeQuery(sql) 235 rs.first() 236 pathBase = rs.getString(1) 237 238 # now find ALL cmf files at this path_base as there can be more than one 239 f=os.popen("neb-ls -p " + pathBase + "%cmf") 240 for i in f.readlines(): 241 242 path = i.rstrip() 243 fits = Fits(self.logger, path) 244 245 # we need to check if this is the correct cmf file, and if so then break and return 246 if fits.getPrimaryHeaderValue("STK_ID") == str(stackID): 247 return path 248 227 249 except: 228 250 self.logger.exception("Can't query for stack cmfs") 229 251 230 # get path to base dir of cmf files 231 path = rs.getString(1) 232 #path = path[0:path.rfind("/")] 233 234 # list all cmf files if a neb path 235 files = [] 236 if path.startswith("neb"): 237 238 f=os.popen("neb-ls -p "+path+"%cmf") 239 for i in f.readlines(): 240 files.append(i.rstrip()) 241 242 # or not a neb path 243 else: 244 files = glob.glob(path + "*.cmf") 245 246 return files 247 252 self.logger.error("Could not find stack cmf") 253 return "NULL" 248 254 249 255 '''
Note:
See TracChangeset
for help on using the changeset viewer.
