- Timestamp:
- Mar 5, 2013, 2:23:09 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130207/ippToPsps
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
jython/dvo.py (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130207/ippToPsps
- Property svn:mergeinfo changed
/trunk/ippToPsps (added) merged: 35170-35171,35173-35175,35177-35179,35181-35188,35190-35191,35203-35204,35216-35218,35222-35226,35232-35233
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130207/ippToPsps/jython/dvo.py
r35097 r35235 6 6 import sys 7 7 import os 8 import math 8 9 import logging 9 10 import glob … … 33 34 34 35 ''' 35 def __init__(self, logger, config, skychunk, ippToPspsDb, scratchDb Name=None):36 def __init__(self, logger, config, skychunk, ippToPspsDb, scratchDb): 36 37 37 38 # set up logging … … 40 41 self.skychunk = skychunk 41 42 self.ippToPspsDb = ippToPspsDb 43 self.scratchDb = scratchDb 42 44 43 45 # set up empty lists … … 48 50 self.regionsIngestedButOutOfDate = [] 49 51 50 # connect to the specified scratch database, if a name is given, otherwise use the first version51 try:52 self.scratchDb = ScratchDb(self.logger, self.config, '1', scratchDbName)53 except: raise54 55 52 # we have (still) 3 modes of ingest from dvo cpt/cps/cpm files 56 53 # 1) dvograbber (useFullTables == FALSE), … … 211 208 def setSkyAreaAsStripe(self, ra=0., width=4.): 212 209 210 print "this function should not reached now, error" 211 raise 212 213 213 self.setSkyArea(ra, ra+width, -91., 91.) 214 214 … … 217 217 ''' 218 218 def setSkyAreaAsBox(self, ra=180., dec=0., side=181.0): 219 220 print "this function should not reached now, error" 221 raise 219 222 220 223 halfSide = side/2.0 … … 223 226 ''' 224 227 Determines what DVO files need to be ingested to the defines region 228 XXX EAM : this function has been substantially reduced / stripped down to work with the parallel dvo 229 XXX EAM : some additional review of the goals would be useful 225 230 ''' 226 231 def setSkyArea(self, minRa=-1., maxRa=361., minDec=-91., maxDec=91): … … 263 268 264 269 # get paths for this region for the file types we are interested in 265 paths = [] 266 for fileType in self.ingestFileTypes: 267 paths.append(self.skychunk.dvoLocation + "/" + regionPath + "." + fileType) 270 # XXX ipptopsps cannot check files -- it does not know where they are 271 ## paths = [] 272 ## for fileType in self.ingestFileTypes: 273 ## paths.append(self.skychunk.dvoLocation + "/" + regionPath + "." + fileType) 268 274 269 275 # check for the existence of all interested file types 270 skipThisRegion = False 271 for path in paths: 272 if not os.path.isfile(path): 273 skipThisRegion = True 274 break 275 276 if skipThisRegion: continue 276 # XXX ipptopsps cannot check files -- it does not know where they are 277 ## skipThisRegion = False 278 ## for path in paths: 279 ## if not os.path.isfile(path): 280 ## skipThisRegion = True 281 ## break 282 283 ## if skipThisRegion: continue 277 284 278 285 # ok, have real, populated files so add this region to the list … … 281 288 282 289 # if we have already imported up-to-date versions of all interested files, then we skip this region 283 alreadyIngested = True 284 for path in paths: 285 if not self.scratchDb.alreadyImportedThisDvoTable(path): 286 alreadyIngested = False 287 break 288 290 ## alreadyIngested = True 291 ## for path in paths: 292 ## if not self.scratchDb.alreadyImportedThisDvoTable(path): 293 ## alreadyIngested = False 294 ## break 295 296 alreadyIngested = False 289 297 if alreadyIngested: 290 298 self.regionsAlreadyIngested.append(regionPath) … … 299 307 300 308 # check if we have out-of-date versions of any interested files, if so, add region to the purge list 301 outOfDate = False 302 for path in paths: 303 if self.scratchDb.haveOutOfDateVersionOfThisDvoTable(path): 304 outOfDate = True 305 break 306 307 if outOfDate: self.regionsIngestedButOutOfDate.append(regionPath) 309 ## outOfDate = False 310 ## for path in paths: 311 ## if self.scratchDb.haveOutOfDateVersionOfThisDvoTable(path): 312 ## outOfDate = True 313 ## break 314 ## 315 ## if outOfDate: self.regionsIngestedButOutOfDate.append(regionPath) 316 317 print "using region: ", regionPath 308 318 309 319 self.regionsToIngest.append(regionPath) … … 389 399 self.logger.infoPair("Purging", "%d regions" % len(regions)) 390 400 391 detectionDeleteCount = self.scratchDb.purgeTheseDvoRegions(regions, self.ingestFileTypes) 392 if detectionDeleteCount > 0: self.logger.infoPair("Deleted", "%d detections" % detectionDeleteCount) 401 self.scratchDb.purgeTheseDvoRegions(regions, self.ingestFileTypes) 402 403 ## detectionDeleteCount = self.scratchDb.purgeTheseDvoRegions(regions, self.ingestFileTypes) 404 ## if detectionDeleteCount > 0: self.logger.infoPair("Deleted", "%d detections" % detectionDeleteCount) 393 405 394 406 return True … … 420 432 421 433 size = 0.0 434 return size 435 422 436 for region in regions: 423 437 self.logger.infoPair("sizes for region", region) 424 438 # get combined size of all interested files 425 439 for fileType in self.ingestFileTypes: 440 print "trying ", fileType 426 441 size = size + self.getDiskSize(self.skychunk.dvoLocation + "/" + region + "." + fileType) 427 442 # EAM TEST I/O … … 574 589 includes purging detections outside sky area 575 590 ''' 576 def nativeIngestDetections(self, boxId, raCenter, decCenter, boxSize):591 def nativeIngestDetections(self, boxId, boxDim): 577 592 578 593 # XXX put the chunk below in a separate method 579 594 # blow away existing dvoDetection table 580 595 581 # clear the 'ingested' field for all boxes 582 self.ippToPspsDb.clearIngestedBoxes( )596 # clear the 'ingested' field for all boxes owned by this host 597 self.ippToPspsDb.clearIngestedBoxes(self.scratchDb.dbHost) 583 598 599 ## print "*******************************************************************************" 600 ## self.logger.warning("about to delete detection table and re-ingest; is this correct?") 601 ## response = raw_input("(y/n) ") 602 ## if response != "y": 603 ## raise 604 ## self.logger.warning("Are you ABSOLUTELY sure you want to do this?") 605 ## response = raw_input("(y/n) ") 606 ## if response != "y": 607 ## raise 608 584 609 # drop detections table 585 610 self.logger.infoPair("Dropping table", self.scratchDb.dvoDetectionTable) … … 608 633 self.loadImages() 609 634 610 # dvopsps -D catdir CATDIR -region .... -dbhost xx -dbname xx -dbuser xx -dbpass xx 611 halfSize = boxSize / 2.0 612 # -region raCenter-halfSize raCenter+halfSize decCenter-halfSize decCenter+halfSize 635 # the box dimensions are the area used to select the items of 636 # interest from the gpc1 database (camera smfs / skycal cmfs). 637 # for dvopsps, we need to include a border region large enough 638 # to grab all detections / objects which are contributed by an 639 # item with the center in the given box 640 dR_border = self.skychunk.BORDER / math.cos(math.radians(boxDim['DEC'])) 641 dD_border = self.skychunk.BORDER 642 643 minRA = boxDim['minRA'] - dR_border 644 maxRA = boxDim['maxRA'] + dR_border 645 minDEC = boxDim['minDEC'] - dD_border 646 maxDEC = boxDim['maxDEC'] + dD_border 613 647 614 648 # TODO path to DVO prog hardcoded temporarily … … 620 654 cmd += " -D CATDIR " + self.skychunk.dvoLocation 621 655 cmd += " -region " 622 cmd += " " + str( raCenter-halfSize)623 cmd += " " + str( raCenter+halfSize)624 cmd += " " + str( decCenter-halfSize)625 cmd += " " + str( decCenter+halfSize)656 cmd += " " + str(minRA) 657 cmd += " " + str(maxRA) 658 cmd += " " + str(minDEC) 659 cmd += " " + str(maxDEC) 626 660 627 661 if self.skychunk.parallel: … … 632 666 p.wait() 633 667 634 self.ippToPspsDb.setIngestedBox(boxId) 668 ## dvopsps can take a very long time. try 2 or 3 times to re-establish communication with the db before proceeding? 669 670 self.ippToPspsDb.setIngestedBox(boxId, self.scratchDb.dbHost) 635 671 636 672 # add fileID column
Note:
See TracChangeset
for help on using the changeset viewer.
