IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 23, 2015, 9:50:16 AM (11 years ago)
Author:
eugene
Message:

get image zero point information from DVO Image table

File:
1 edited

Legend:

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

    r38879 r38951  
    214214
    215215    '''
     216    Gets photcode (aka photoCalID from dvo table)
     217    '''
     218    def getImageZeroPoint(self, externID):
     219
     220        zeroPoint = -999
     221
     222        sql = "SELECT MCAL, SECZ, C_LAM, K FROM %s AS a JOIN %s as b WHERE EXTERN_ID = %s AND a.PHOTCODE = b.CODE" % (self.dvoImagesTable, self.dvoPhotcodesTable, (externID))
     223        rs = self.executeQuery(sql) 
     224        if not rs:
     225            print "missing result set for imageID query"
     226            os._exit(2)
     227
     228        if not rs.first():
     229            self.logger.infoPair("no zero point; image is missing, imageID: ", imageID)
     230            return zeroPoint
     231           
     232        Mcal     = rs.getFloat(1)
     233        airmass  = rs.getFloat(2)
     234        Clam     = rs.getFloat(3)
     235        Klam     = rs.getFloat(4)
     236
     237        zeroPoint = 0.001*Clam + Klam*(airmass - 1.0) - Mcal
     238        return zeroPoint
     239
     240    '''
    216241    Updates a table with filterID grabbed from Filter init table
    217242    '''
     
    449474            " AND SOURCE_ID = " + str(sourceID)
    450475
    451         try:
    452             rs = self.executeQuery(sql)
    453            
    454             if not rs:
    455                 print "missing result set for imageID query"
    456                 raise
    457 
    458             # if no returned rows, return an error
    459             if not rs.next():
    460                 self.logger.infoPair("DVO lacks imageID ", imageID)
    461                 return False
    462 
    463             if rs.getInt(1) == int(imageID):
    464                 # print "DVO has imageID ", imageID
    465                 return True
    466 
    467             else:
    468                 self.logger.error("DVO has wrong imageID? ")
    469                 self.logger.error("imageID: ", imageID)
    470                 self.logger.error("EXTERN_ID: ", rs.getInt(1))
    471                 self.logger.infoPair("sql: ", sql)
    472                 raise
    473 
    474         except:
    475             print "DVO imageID query failed ", imageID
    476             print "sql: ", sql
     476        rs = self.executeQuery(sql)
     477        if not rs:
     478            print "missing result set for imageID query"
    477479            raise
    478480
    479         # how can I reach this?
     481        # if no returned rows, return an error
     482        if not rs.next():
     483            self.logger.infoPair("DVO lacks imageID ", imageID)
     484            return False
     485
     486        if rs.getInt(1) != int(imageID):
     487            self.logger.error("DVO has wrong imageID? ")
     488            self.logger.error("imageID: ", imageID)
     489            self.logger.error("EXTERN_ID: ", rs.getInt(1))
     490            self.logger.infoPair("sql: ", sql)
     491            os._exit(2)
     492
     493        # print "DVO has imageID ", imageID
    480494        return True
    481495
     
    497511               EXTERN_ID INT, \
    498512               FLAGS INT, \
     513               MCAL FLOAT, \
     514               SECZ FLOAT, \
    499515               PHOTCODE SMALLINT, \
    500516               XPIX_SYS_ERR FLOAT, \
Note: See TracChangeset for help on using the changeset viewer.