IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 27, 2012, 12:31:28 PM (14 years ago)
Author:
rhenders
Message:

using more meaningful name of 'region' as opposed to 'file' to refer to DVO regions

File:
1 edited

Legend:

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

    r33163 r33170  
    144144    Gets a bunch of region files from DVO for this RA/Dec box
    145145    '''
    146     def getRegionFiles(self, minRa=-1., maxRa=361., minDec=-91., maxDec=91):
     146    def getRegions(self, regionsToIngest, minRa=-1., maxRa=361., minDec=-91., maxDec=91):
    147147   
    148148        if (maxRa - minRa <= 0) or (maxDec - minDec) <= 0:
     
    154154                "RA: %.2f -> %.2f, Dec: %.2f -> %.2f" % (minRa, maxRa, minDec, maxDec))
    155155
    156         allFiles = self.scratchDb.getDvoFilesCoveringThisRegion(minRa, maxRa, minDec, maxDec)
    157 
    158         files = []
    159 
    160         total = 0
     156        allRegions = self.scratchDb.getDvoRegionsForThisBox(minRa, maxRa, minDec, maxDec)
     157
     158        allPopulatedRegions = []
    161159        alreadyIngested = 0
    162         toIngest = 0
    163         for file in allFiles:
    164 
    165            cpmPath = self.dvoLocation + "/" + file + ".cpm"
    166            cptPath = self.dvoLocation + "/" + file + ".cpt"
     160        for region in allRegions:
     161
     162           cpmPath = self.dvoLocation + "/" + region + ".cpm"
     163           cptPath = self.dvoLocation + "/" + region + ".cpt"
    167164
    168165           # check for existence of cpm and cpt files
     
    170167           if not os.path.isfile(cptPath): continue
    171168
    172            total = total + 1
     169           allPopulatedRegions.append(region)
    173170
    174171           # if we have already imported up-to-date versions of both the cpm and cpt then we skip this region
     
    177174               continue
    178175
    179            files.append(file)
    180 
    181            toIngest = toIngest + 1
    182 
    183         self.logger.infoPair("Total DVO regions to ingest", "%d" % total)
    184         self.logger.infoPair("DVO regions already ingested", "%d" % alreadyIngested)
    185         self.logger.infoPair("DVO regions to ingest", "%d" % toIngest)
    186 
    187         return files
     176           regionsToIngest.append(region)
     177
     178
     179
     180
     181        #regionsToDelete = list(set(allIDs) - set(processedIDs))
     182
     183
     184        self.logger.infoPair("Total DVO regions", "%d" % len(allPopulatedRegions))
     185        self.logger.infoPair("Total DVO regions already ingested", "%d" % alreadyIngested)
     186        self.logger.infoPair("Total DVO regions to ingest", "%d" % len(regionsToIngest))
     187
    188188
    189189    '''
     
    194194
    195195        # format a string for the user -smaller than one MB
    196         if byteSize < 1048576: return "%.1f Kb" % (byteSize/1024.0)
     196        if byteSize < 1048576: return "%.1f K" % (byteSize/1024.0)
    197197        # smaller than one GB
    198         elif byteSize < 1073741824: return "%.1f Mb" % (byteSize/1048576.0)
     198        elif byteSize < 1073741824: return "%.1fM" % (byteSize/1048576.0)
    199199        # more than a GB
    200         else: return "%.1f Gb" % (byteSize/1073741824.0)
    201 
    202     '''
    203     Returns the disk size of this region of data in DVO
    204     '''
    205     def getSizeOfDvoRegionFromFiles(self, files):
     200        else: return "%.1fG" % (byteSize/1073741824.0)
     201
     202    '''
     203    Returns the disk size of these DVO regions, i.e. the size on disk of all cpm and cpt files
     204    '''
     205    def getDiskSizeOfDvoRegions(self, regions):
    206206
    207207        size = 0.0
    208         for file in files:
     208        for region in regions:
    209209
    210210            # get combined size of cpm and cpt files
    211             size = size + os.stat(self.dvoLocation + "/" + file + ".cpm").st_size
    212             size = size + os.stat(self.dvoLocation + "/" + file + ".cpt").st_size
     211            size = size + os.stat(self.dvoLocation + "/" + region + ".cpm").st_size
     212            size = size + os.stat(self.dvoLocation + "/" + region + ".cpt").st_size
    213213
    214214        return size
     
    232232        if not self.correctDvo: return
    233233
    234         files = self.getRegionFiles(minRa, maxRa, minDec, maxDec)
    235         totalSize = self.getSizeOfDvoRegionFromFiles(files)
     234        regionsToIngest = []
     235        self.getRegions(regionsToIngest, minRa, maxRa, minDec, maxDec)
     236        totalSize = self.getDiskSizeOfDvoRegions(regionsToIngest)
    236237        self.logger.infoPair("Total size of cpm/cpt files to ingest", self.getFileSizeStr(totalSize))
    237238        count = 0
     
    239240        self.logger.infoSeparator()
    240241
    241         # now loop through all files
    242         for file in files:
    243 
    244            cpmPath = self.dvoLocation + "/" + file + ".cpm"
    245            cptPath = self.dvoLocation + "/" + file + ".cpt"
    246 
    247            cpmTableName = self.getDatabaseFriendlyTableName(file + ".cpm")
    248            cptTableName = self.getDatabaseFriendlyTableName(file + ".cpt")
     242        # now loop through all regions and ingest to MySQL
     243        for region in regionsToIngest:
     244
     245           cpmPath = self.dvoLocation + "/" + region + ".cpm"
     246           cptPath = self.dvoLocation + "/" + region + ".cpt"
     247
     248           cpmTableName = self.getDatabaseFriendlyTableName(region + ".cpm")
     249           cptTableName = self.getDatabaseFriendlyTableName(region + ".cpt")
    249250
    250251           # if we have not already ingested the cpm table, then do it now
     
    271272
    272273               # we can report that we have imported this table
    273                self.scratchDb.setImportedThisDvoTable(cpmPath)
     274               self.scratchDb.setImportedThisDvoTable(cpmPath, region)
     275
     276           # get the id for this cpm file so we can insert it in the dvoDetection table
     277           fileId = self.scratchDb.getDvoFileId(cpmPath)
    274278
    275279           # import cpt table and index
     
    307311                  ,objID \
    308312                  ,flags \
     313                  ,fileID \
    309314                  ) SELECT \
    310315                  SOURCE_ID \
     
    315320                  ,PSPS_OBJ_ID \
    316321                  ,DB_FLAGS \
     322                  , " + str(fileId) + " \
    317323                  FROM " + cpmTableName
    318324           try:
     
    328334           self.scratchDb.dropTable(cptTableName)
    329335
    330            self.scratchDb.setImportedThisDvoTable(cptPath)
     336           self.scratchDb.setImportedThisDvoTable(cptPath, region)
    331337           count = count + 1
    332338
    333339        self.logger.infoSeparator()
    334340
    335         self.logger.infoPair("Ingested", "%d DVO region files" % count)
     341        self.logger.infoPair("Ingested", "%d DVO regions" % count)
    336342
    337343        return True
Note: See TracChangeset for help on using the changeset viewer.