- Timestamp:
- Jan 27, 2012, 12:31:28 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/dvo.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/dvo.py
r33163 r33170 144 144 Gets a bunch of region files from DVO for this RA/Dec box 145 145 ''' 146 def getRegion Files(self, minRa=-1., maxRa=361., minDec=-91., maxDec=91):146 def getRegions(self, regionsToIngest, minRa=-1., maxRa=361., minDec=-91., maxDec=91): 147 147 148 148 if (maxRa - minRa <= 0) or (maxDec - minDec) <= 0: … … 154 154 "RA: %.2f -> %.2f, Dec: %.2f -> %.2f" % (minRa, maxRa, minDec, maxDec)) 155 155 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 = [] 161 159 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" 167 164 168 165 # check for existence of cpm and cpt files … … 170 167 if not os.path.isfile(cptPath): continue 171 168 172 total = total + 1169 allPopulatedRegions.append(region) 173 170 174 171 # if we have already imported up-to-date versions of both the cpm and cpt then we skip this region … … 177 174 continue 178 175 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 188 188 189 189 ''' … … 194 194 195 195 # format a string for the user -smaller than one MB 196 if byteSize < 1048576: return "%.1f K b" % (byteSize/1024.0)196 if byteSize < 1048576: return "%.1f K" % (byteSize/1024.0) 197 197 # smaller than one GB 198 elif byteSize < 1073741824: return "%.1f Mb" % (byteSize/1048576.0)198 elif byteSize < 1073741824: return "%.1fM" % (byteSize/1048576.0) 199 199 # more than a GB 200 else: return "%.1f Gb" % (byteSize/1073741824.0)201 202 ''' 203 Returns the disk size of th is region of data in DVO204 ''' 205 def get SizeOfDvoRegionFromFiles(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): 206 206 207 207 size = 0.0 208 for file in files:208 for region in regions: 209 209 210 210 # get combined size of cpm and cpt files 211 size = size + os.stat(self.dvoLocation + "/" + file+ ".cpm").st_size212 size = size + os.stat(self.dvoLocation + "/" + file+ ".cpt").st_size211 size = size + os.stat(self.dvoLocation + "/" + region + ".cpm").st_size 212 size = size + os.stat(self.dvoLocation + "/" + region + ".cpt").st_size 213 213 214 214 return size … … 232 232 if not self.correctDvo: return 233 233 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) 236 237 self.logger.infoPair("Total size of cpm/cpt files to ingest", self.getFileSizeStr(totalSize)) 237 238 count = 0 … … 239 240 self.logger.infoSeparator() 240 241 241 # now loop through all files242 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") 249 250 250 251 # if we have not already ingested the cpm table, then do it now … … 271 272 272 273 # 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) 274 278 275 279 # import cpt table and index … … 307 311 ,objID \ 308 312 ,flags \ 313 ,fileID \ 309 314 ) SELECT \ 310 315 SOURCE_ID \ … … 315 320 ,PSPS_OBJ_ID \ 316 321 ,DB_FLAGS \ 322 , " + str(fileId) + " \ 317 323 FROM " + cpmTableName 318 324 try: … … 328 334 self.scratchDb.dropTable(cptTableName) 329 335 330 self.scratchDb.setImportedThisDvoTable(cptPath )336 self.scratchDb.setImportedThisDvoTable(cptPath, region) 331 337 count = count + 1 332 338 333 339 self.logger.infoSeparator() 334 340 335 self.logger.infoPair("Ingested", "%d DVO region files" % count)341 self.logger.infoPair("Ingested", "%d DVO regions" % count) 336 342 337 343 return True
Note:
See TracChangeset
for help on using the changeset viewer.
