IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 10, 2011, 8:49:04 AM (15 years ago)
Author:
rhenders
Message:

using base-class methods for query execution; new method to get exposure time from GPC1 since info in cmf headers is incorrect, or missing

File:
1 edited

Legend:

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

    r31400 r31501  
    2929        self.logger.debug("Gpc1Db destructor")
    3030
     31
     32    '''
     33    TODO
     34    '''
     35    def getIDsInThisDVODbForThisStageFudge(self):
     36
     37        sql = "SELECT staticskyRun.sky_id \
     38               FROM staticskyInput, staticskyRun, stackRun, staticskyResult \
     39               WHERE staticskyRun.sky_id = staticskyInput.sky_id \
     40               AND staticskyInput.stack_id = stackRun.stack_id \
     41               AND staticskyInput.sky_id = staticskyResult.sky_id \
     42               AND staticskyRun.label like 'MD04.staticsky' \
     43               AND stackRun.filter like 'i%'"
     44
     45        try:
     46            rs = self.executeQuery(sql)
     47        except:
     48            self.logger.exception("Can't query for ids in DVO")
     49
     50        ids = []
     51        while (rs.next()):
     52            ids.append(rs.getInt(1))
     53
     54        rs.close()
     55
     56        self.logger.info("Found %d items in DVO database '" % (len(ids)))
     57
     58        return ids
     59
    3160    '''
    3261    Gets a list of ids in this DVO database for this stage, could be cam or staticsky (so far)
     
    4069
    4170        try:
    42             rs = self.stmt.executeQuery(sql)
     71            rs = self.executeQuery(sql)
    4372        except:
    4473            self.logger.exception("Can't query for ids in DVO")
     
    5079        rs.close()
    5180
    52         self.logger.debug("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage))
     81        self.logger.info("Found %d items in DVO database '%s' for stage='%s'" % (len(ids), dvoDb, stage))
    5382
    5483        return ids
     
    73102
    74103        try:
    75             rs = self.stmt.executeQuery(sql)
     104            rs = self.executeQuery(sql)
    76105        except:
    77106            self.logger.exception("Can't query for imageIDs")
     
    105134
    106135        try:
    107             rs = self.stmt.executeQuery(sql)
     136            rs = self.executeQuery(sql)
    108137            rs.first()
    109138            meta.append(rs.getInt(1))
     
    113142
    114143        return meta
     144
    115145    '''
    116146    Gets some camera-stage meta data for this cam_id
     
    127157
    128158        try:
    129             rs = self.stmt.executeQuery(sql)
     159            rs = self.executeQuery(sql)
    130160            rs.first()
    131161            meta.append(rs.getInt(1))
     
    150180
    151181        try:
    152             rs = self.stmt.executeQuery(sql)
     182            rs = self.executeQuery(sql)
    153183            rs.first()
    154184        except:
     
    171201            files = glob.glob(path + "/*.cmf")
    172202
     203        if len(files) < 1: return "NULL"
     204
    173205        return files[0] # TODO just returning first file - check
    174206
     
    186218
    187219        try:
    188             rs = self.stmt.executeQuery(sql)
     220            rs = self.executeQuery(sql)
    189221            rs.first()
    190222        except:
     
    200232
    201233            f=os.popen("neb-ls -p "+path+"%cmf")
    202             print "neb-ls -p "+path+"%cmf"
    203234            for i in f.readlines():
    204235                files.append(i.rstrip())
    205                 print i.rstrip()
    206236
    207237        # or not a neb path
     
    211241        return files
    212242
     243
     244    '''
     245    TODO hack to get exposure time for a stack
     246    '''
     247    def getStackExpTime(self, stackID):
     248
     249        self.logger.debug("Querying GPC1 for stack exposure time")
     250
     251        sql = "SELECT SUM(exp_time) * (COUNT(warp_id) - reject_images) / COUNT(warp_id) as EXPTIME \
     252               FROM staticskyRun JOIN staticskyInput using(sky_id) \
     253               JOIN stackRun using(stack_id) \
     254               JOIN stackSumSkyfile using(stack_id) \
     255               JOIN stackInputSkyfile using(stack_id) \
     256               JOIN warpRun using(warp_id) \
     257               JOIN fakeRun using(fake_id) \
     258               JOIN camRun using(cam_id) \
     259               JOIN chipRun using(chip_id) \
     260               JOIN rawExp using(exp_id) \
     261               WHERE stack_id = %d" % stackID
     262
     263        try:
     264            rs = self.executeQuery(sql)
     265            rs.first()
     266            return rs.getInt(1)
     267        except:
     268            self.logger.exception("Can't query for exposure time")
     269
     270        return 0.0
     271
     272
Note: See TracChangeset for help on using the changeset viewer.