IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31400


Ignore:
Timestamp:
Apr 28, 2011, 3:49:05 PM (15 years ago)
Author:
rhenders
Message:

changes to stack-cmf-getting function - was getting them wrong; added method to get stack-stage meta data since it's missing from certain stack cmf files; changes to log messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/gpc1db.py

    r31345 r31400  
    3434    def getIDsInThisDVODbForThisStage(self, dvoDb, stage):
    3535
    36         self.logger.debug("Querying GPC1 for sky_ids in this DVO database: " + dvoDb)
    37 
    3836        sql = "SELECT DISTINCT stage_id \
    3937               FROM addRun \
     
    4442            rs = self.stmt.executeQuery(sql)
    4543        except:
    46             self.logger.exception("Can't query for sky_ids")
     44            self.logger.exception("Can't query for ids in DVO")
    4745
    4846        ids = []
     
    5250        rs.close()
    5351
     52        self.logger.debug("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage))
     53
    5454        return ids
    5555
     
    5959    def getImageIDsForThisStackID(self, stackID):
    6060
    61         self.logger.debug("Querying GPC1 for image IDs for stack ID: " + stackID)
     61        self.logger.debug("Querying GPC1 for image IDs for stack ID: " + str(stackID))
    6262
    6363        sql = "SELECT DISTINCT CONCAT(exp_id, SUBSTR(class_id, 3, 4)) FROM ( \
     
    7070               JOIN camRun USING(cam_id)  \
    7171               JOIN chipRun USING(chip_id) \
    72                WHERE stackRun.stack_id = " + stackID + ") AS a"
     72               WHERE stackRun.stack_id = " + str(stackID) + ") AS a"
    7373
    7474        try:
     
    8484        return imageIDs
    8585
     86    '''
     87    Gets some stack-stage meta data for this sky_id # TODO this SQL could surely be improved
     88    '''
     89    def getStackStageMeta(self, skyID, filter):
     90
     91        self.logger.debug("Querying GPC1 for stack meta data")
     92
     93        meta = []
     94        sql = "SELECT \
     95               stackRun.stack_id,\
     96               stackRun.skycell_id \
     97               FROM \
     98               staticskyInput, staticskyRun, stackRun, staticskyResult \
     99               WHERE staticskyRun.sky_id = staticskyInput.sky_id \
     100               AND staticskyInput.stack_id = stackRun.stack_id \
     101               AND staticskyInput.sky_id = staticskyResult.sky_id \
     102               and staticskyInput.sky_id = %d \
     103               and filter = '%s'" % (skyID, filter)
     104
     105
     106        try:
     107            rs = self.stmt.executeQuery(sql)
     108            rs.first()
     109            meta.append(rs.getInt(1))
     110            meta.append(rs.getString(2))
     111        except:
     112            self.logger.exception("Can't query for stack meta")
     113
     114        return meta
    86115    '''
    87116    Gets some camera-stage meta data for this cam_id
     
    100129            rs = self.stmt.executeQuery(sql)
    101130            rs.first()
    102         except:
    103             self.logger.exception("Can't query for camera meta")
    104         finally:
    105131            meta.append(rs.getInt(1))
    106132            meta.append(rs.getString(2))
    107133            meta.append(rs.getString(3))
     134        except:
     135            self.logger.exception("Can't query for camera meta")
    108136
    109137        return meta
     
    114142    def getCameraStageSmf(self, camID):
    115143
    116         self.logger.debug("Querying GPC1 for camera smf files")
     144        self.logger.debug("Querying GPC1 for camera smf files with cam_id = " + str(camID))
    117145
    118146        sql = "SELECT path_base \
     
    136164
    137165            f=os.popen("neb-ls -p "+path+"/%smf")
    138             print "neb-ls -p "+path+"/%smf"
    139166            for i in f.readlines():
    140167                files.append(i.rstrip())
     
    157184               FROM staticskyResult \
    158185               WHERE sky_id = %d" % skyID
     186
    159187        try:
    160188            rs = self.stmt.executeQuery(sql)
     
    165193        # get path to base dir of cmf files
    166194        path = rs.getString(1)
    167         path = path[0:path.rfind("/")]
     195        #path = path[0:path.rfind("/")]
    168196       
    169197        # list all cmf files if a neb path
     
    171199        if path.startswith("neb"):
    172200
    173             f=os.popen("neb-ls -p "+path+"/%cmf")
     201            f=os.popen("neb-ls -p "+path+"%cmf")
     202            print "neb-ls -p "+path+"%cmf"
    174203            for i in f.readlines():
    175204                files.append(i.rstrip())
     205                print i.rstrip()
    176206
    177207        # or not a neb path
    178208        else:
    179             files = glob.glob(path + "/*.cmf")
     209            files = glob.glob(path + "*.cmf")
    180210
    181211        return files
Note: See TracChangeset for help on using the changeset viewer.