IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37749


Ignore:
Timestamp:
Dec 16, 2014, 3:35:38 PM (12 years ago)
Author:
heather
Message:

diff batch: diffdetection difftoimage

Location:
trunk/ippToPsps/jython
Files:
2 edited

Legend:

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

    r37748 r37749  
    297297
    298298
     299    '''
     300    Populates the DiffToImage table
     301    '''
     302    def populateDiffToImage(self):
     303
     304        self.logger.infoPair("Procesing table", "DiffToImage")
     305
     306        imageIDs = self.gpc1Db.getImageIDsForThisDiffID(diffkmetaID)
     307
     308        for imageID in imageIDs:
     309
     310            sql = "INSERT INTO DiffToImage (diffMetaID, imageID) \
     311            VALUES (\
     312            " + str(diffmetaID) + ", " + imageID + ")"
     313            self.scratchDb.execute(sql)
     314
     315            # now update StackMeta with correct number of inputs
     316            #sql = "UPDATE "+filter+"StackMeta SET nP2Images = (SELECT COUNT(distinct(floor(imageID/100))) FROM StackToImage where stackMetaID = "+str(stackmetaID)+")"
     317            #self.scratchDb.execute(sql)
     318
     319        self.tablesToExport.append("DiffToImage")
     320
     321
     322
     323
     324
     325
    299326
    300327    '''
     
    461488    '''
    462489    def populatePspsTables(self):
    463 
     490        self.logger.infoPair("starting","populatePspsTables for diffBatch")
    464491        # loop through all OTAs again to update with DVO IDs
    465492        self.skipBatch = False
    466         self.validChips = []   
    467493        self.tablesToExport = []   
    468494        self.tablesToExport.append("DiffMeta")
    469         tables = []   
    470         otaCount = 0
    471         results = {}
    472         self.totalOriginal = self.totalSatDet = self.totalNulIInstFlux = self.totalNullPeakFlux = self.totalNullObjID = self.totalDetections = 0
    473         self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+")
    474         self.logger.info("|  OTA  | Initial total |   Sat Det     | NULL instFlux | NULL obj ID   |  Remainder    |")
    475         self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+")
    476         for x in range(self.startX, self.endX):
    477             for y in range(self.startY, self.endY):
    478                
    479                 # dodge the corners
    480                 if x==0 and y==0: continue
    481                 if x==0 and y==7: continue
    482                 if x==7 and y==0: continue
    483                 if x==7 and y==7: continue
    484 
    485                 ota = "XY%d%d" % (x, y)
    486                 if ota not in self.imageIDs: continue
    487 
    488                 if False and self.config.test and not ((x == 0) and (y == 1)):
    489                     print "skipping ota " + ota
    490                     continue
    491 
    492                 if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1
    493                 if self.skipBatch:
    494                     self.logger.error("fatal problem for exposure, skipping")
    495                     return False
    496 
    497         if "Chip" in self.imageIDs:
    498             if self.populatePspsTablesChip("Chip", 0, 0, results, tables): otaCount = otaCount + 1
    499             if self.skipBatch:
    500                 self.logger.error("fatal problem for exposure, skipping")
    501                 return False
    502 
    503         # print totals
    504         self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+")
    505         self.logger.info("| Total | %13d | %13d | %13d | %13d | %13d | %13d |",
    506                 self.totalOriginal,
    507                 self.totalSatDet,
    508                 self.totalNulIInstFlux,
    509                 self.totalNullPeakFlux,
    510                 self.totalNullObjID,
    511                 self.totalDetections)
    512         self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+")
    513 
    514         # if we only have one table export, i.e. FrameMeta, then get out of here (skip batch, but do not abort)
    515         if len(self.tablesToExport) == 1:
    516             self.skipBatch = True
    517             self.logger.error("No tables to export")
    518             return False
    519 
    520         # XXX EAM : turn this on (and fix up the code) if we need it
    521         # self.removeDuplicateObjects()
    522 
    523         self.setMinMaxObjID(tables)
     495        self.populateDiffMeta()
     496        self.tablesToExport.append("DiffToImage")
     497        self.populateDiffToImage()
     498        self.tablesToExport.append("DiffDetection")
     499        self.populateDiffDetection()
     500       
     501
     502
     503
     504       
     505        self.setMinMaxObjID("DiffDetection")
    524506
    525507        # update FrameMeta with count OTAs in this file and total number of photometric reference sources
  • trunk/ippToPsps/jython/gpc1db.py

    r37748 r37749  
    343343
    344344    '''
     345    Gets a list of PSPS image IDs for this diff ID
     346    '''
     347    def getImageIDsForThisDiffID(self, diffID):
     348
     349        self.logger.debug("Querying GPC1 for image IDs for diff ID: " + str(diffID))
     350
     351        # JOIN stackInputSkyfile shoule use stack_id as well as warp_id, right? (maybe not -- the join to warp is first)
     352        sql = "SELECT DISTINCT CONCAT(exp_id, SUBSTR(class_id, 3, 4)) FROM ( \
     353               SELECT DISTINCT exp_id,class_id \
     354               FROM warpSkyCellMap \
     355               JOIN warpRun USING(warp_id) \
     356               JOIN diffInputSkyfile on warp1 = warp_id \
     357               WHERE diffInputSkyfile.diff_skyfile_id = " + str(diffID) + " AS a"
     358
     359        try:
     360            rs = self.executeQuery(sql)
     361        except:
     362            self.logger.exception("Can't query for imageIDs")
     363
     364        imageIDs = []
     365        while (rs.next()):
     366            imageIDs.append(rs.getString(1))
     367        rs.close()
     368
     369        return imageIDs
     370
     371   
     372
     373
     374   
     375    '''
    345376    Gets some camera-stage meta data for this cam_id
    346377    '''
Note: See TracChangeset for help on using the changeset viewer.