IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38951


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

get image zero point information from DVO Image table

Location:
trunk/ippToPsps/jython
Files:
6 edited

Legend:

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

    r38929 r38951  
    199199    def populateImageMetaTable(self, ota, header):
    200200
     201        # does this chip exist in the DVO image table? (if NOT, then skip it)
     202        if not self.scratchDb.haveThisChip(self.imageIDs[ota], self.sourceIDs[ota]):
     203            self.logger.info("| %5s |            ------------- Chip not in DVO : rejecting ------------                    |" % ota)
     204            return False
     205
    201206        # the supplied 'header' matches this chip
    202207        # self.header is the PHU header for this smf
     
    231236        zp      = self.getKeyFloat(header, "%.8f", 'ZPT_OBS')
    232237
     238        zpImage = self.scratchDb.getImageZeroPoint(self.imageIDs[ota])
     239
    233240        # XXX zp correction should come from DVO
    234         detectionThreshold = detectionThreshold + zp - 2.5 * math.log10(expTime)
     241        detectionThreshold = detectionThreshold + zpImage - 2.5 * math.log10(expTime)
    235242       
    236243        # insert image metadata into table
     
    246253        sqlLine.group("astroScat",          astroscat)
    247254        sqlLine.group("photoScat",          self.getKeyFloat(header, "%.8f", 'ZPT_ERR'))
    248         sqlLine.group("photoZero",          zp)
     255        sqlLine.group("photoZero",          zpImage)
    249256        sqlLine.group("nAstroRef",          self.getKeyValue(header, 'NASTRO'))
    250257        sqlLine.group("nPhotoRef",          self.getKeyValue(header, 'NASTRO'))
     
    629636           
    630637        # populate ImageMeta
    631         self.populateImageMetaTable(chipname, header)
     638        if not self.populateImageMetaTable(chipname, header):
     639            self.logger.infoPair("skipping chip: ", chipname)
     640            return False
     641
    632642        self.updateImageID("ImageMeta_" + chipname, x, y)
    633643
     
    810820        ota = x*10+y
    811821
    812 
    813822        self.logger.info("add psps unique p2 ids")
    814823        self.updatePspsUniqueIDs("Detection_" + chipname, ota)
     
    901910                if x==7 and y==7: continue
    902911
     912                # skip chips which were not loaded
    903913                ota = "XY%d%d" % (x, y)
    904914                extension = ota + ".psf"
    905915                if extension not in self.tablesLoaded: continue
    906916
    907                 if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1
     917                # skip chips which had a problem (e.g., not in DVO)
     918                if not self.populatePspsTablesChip(ota, x, y, results, tables):
     919                    if self.skipBatch:
     920                        self.logger.error("fatal problem for exposure, skipping")
     921                        return False
     922                    continue
     923                               
     924                otaCount = otaCount + 1
     925                self.populateImageDetEffMetaTablePart2(ota)
     926
     927        extension = "Chip.psf"
     928        if extension in self.tablesLoaded:
     929            if not self.populatePspsTablesChip("Chip", 0, 0, results, tables):
     930                print "--- skipped Chip.psf"
    908931                if self.skipBatch:
    909932                    self.logger.error("fatal problem for exposure, skipping")
    910933                    return False
    911                                
    912                 self.populateImageDetEffMetaTablePart2(ota)
    913 
    914 
    915         extension = "Chip.psf"
    916         if extension in self.tablesLoaded:
    917             if self.populatePspsTablesChip("Chip", 0, 0, results, tables): otaCount = otaCount + 1
    918             if self.skipBatch:
    919                 self.logger.error("fatal problem for exposure, skipping")
    920                 return False
     934            else:
     935                otaCount = otaCount + 1
     936
     937            print "--- tried Chip.psf"
    921938
    922939        # print totals
     
    931948        self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+")
    932949
     950        print "--- tried Chip.psf (2)"
     951
    933952        # if we only have one table export, i.e. FrameMeta, then get out of here (skip batch, but do not abort)
    934953        if len(self.tablesToExport) == 1:
  • trunk/ippToPsps/jython/dvo.py

    r38889 r38951  
    146146        self.importFits(
    147147                path,
    148                 "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM",
     148                "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS MCAL SECZ PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM",
    149149                self.scratchDb.dvoImagesTable)
    150150        self.logger.infoPair("Adding primary key to", self.scratchDb.dvoImagesTable)
  • trunk/ippToPsps/jython/forcedwarpbatch.py

    r38945 r38951  
    133133           self.logger.infoPair("found exp_id",     str(self.expID[num]))
    134134           self.logger.infoPair("found exp_time",   str(self.expTime[num]))
    135            self.logger.infoPair("found filter",     str(self.filterNam[num]))
     135           self.logger.infoPair("found filter",     str(self.filterName[num]))
    136136           self.logger.infoPair("found skycell_id", self.skycellName[num])
    137137           self.logger.infoPair("found tess_id",    self.tessName[num])
     
    216216       self.outputFitsPath = "%s/%s" % (self.localOutPath, self.outputFitsFile)
    217217
    218 
    219 
    220218       # dump stuff to log
    221219       self.logger.infoPair("add ID", "%d" % self.id)
    222 
    223 #       self.logger.infoPair("Exp ID", self.expID)
    224 
    225 
    226 
    227 
    228 
    229220
    230221    '''
     
    243234        self.logger.infoPair("found header","ok")
    244235
    245         # photoCalID = str(self.scratchDb.getPhotoCalID(header['IMAGEID']))       
    246 
    247         # XXX fix this:
    248         photoCalID = GPC1.filtername.ForcedWarp
     236        photoCalID = str(self.scratchDb.getPhotoCalID(header['IMAGEID']))       
     237
     238        # PHOTCODE and FILTER are not in the header; reconstruct here
     239        # photoCalID = "GPC1.%s.ForcedWarp" % self.filterName[num][0]
     240
     241        zpImage = self.scratchDb.getImageZeroPoint(header['IMAGEID'])
    249242
    250243        # XXX hard-wired platescale : 0.25
     
    285278        # sqlLine.group("psfFwhm_max",    self.getKeyFloat(header, "%.8f", 'FW_MJ_UQ'))
    286279
    287         # XXX: should psfTheta include the angle of the source chip in some way?
    288280        sqlLine.group("psfTheta",       self.getKeyFloat(header, "%.8f", 'ANGLE'))
    289         sqlLine.group("photoZero",      self.getKeyFloat(header, "%.8f", 'FPA.ZP'))
     281
     282        # sqlLine.group("photoZero",      self.getKeyFloat(header, "%.8f", 'FPA.ZP'))
     283        sqlLine.group("photoZero",      zpImage)
     284
    290285        # photoColor -- how do I set this? it's also not set in stack meta
    291286        sqlLine.group("ctype1",         self.getKeyValue(header, 'CTYPE1'));
  • trunk/ippToPsps/jython/mysql.py

    r38853 r38951  
    88from java.lang import *
    99from java.sql import *
    10 from xml.etree.ElementTree import ElementTree
     10# from xml.etree.ElementTree import ElementTree
    1111
    1212'''
     
    355355            print "--- " + str(e)
    356356            os._exit(2)
    357 
    358 #       stmt.close()
    359357        return rs
    360358
  • 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, \
  • trunk/ippToPsps/jython/stackbatch.py

    r38939 r38951  
    261261        zpErr   = self.getKeyFloat(header, "%.8f", 'ZPT_ERR')
    262262
     263        zpImage = self.scratchDb.getImageZeroPoint(stackID)
     264
    263265        # XXX zp correction should come from DVO
    264         detectionThreshold = detectionThreshold + zp - 2.5 * math.log10(expTime)
     266        detectionThreshold = detectionThreshold + zpImage - 2.5 * math.log10(expTime)
    265267       
    266268        # insert stack metadata into table
     
    287289#       sqlLine.group("psfFwhm_max",        fwhm_maj_uq)
    288290        sqlLine.group("astroScat",          astroscat)
    289         sqlLine.group("photoZero",          zp)
     291        sqlLine.group("photoZero",          zpImage)
    290292        sqlLine.group("photoScat",          zpErr)
    291293        sqlLine.group("nAstroRef",          header['NASTRO'])
Note: See TracChangeset for help on using the changeset viewer.