- Timestamp:
- Dec 12, 2017, 1:11:39 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/dvo.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/dvo.py
r40011 r40275 101 101 102 102 if not self.loadImages(): 103 self.logger.debugPair("FAILED to load images", "exiting") 103 104 os._exit(1) 104 105 106 print "DONE load images (resetAllTables)" 105 107 106 108 ''' … … 145 147 self.logger.infoPair("DVO Images.dat file", "NOT up-to-date") 146 148 149 # check on the format: 150 try: 151 imagesHeaderPHU = self.readFitsHeader("PHU", path) 152 except Exception,e: 153 # print the error, wait a few secs then try again 154 print str(e) 155 self.logger.infoPair("Failed to find PHU for Images.dat", path) 156 raise 157 158 if "FORMAT" in imagesHeaderPHU: 159 fileFormat = imagesHeaderPHU["FORMAT"] 160 else: 161 self.logger.infoPair("Missing FORMAT for Images.dat", path) 162 raise 163 164 self.logger.infoPair("got FORMAT for Images.dat", fileFormat) 165 166 if not (fileFormat == "PS1_V6"): 167 self.logger.infoPair("Invalid FORMAT for Images.dat (PS1_V6)", fileFormat) 168 return False 169 147 170 self.importFits( 148 171 path, 149 "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",172 "SOURCE_ID IMAGE_ID EXTERN_ID FLAGS MCAL_PSF MCAL_APER SECZ PHOTCODE XPIX_SYS_ERR YPIX_SYS_ERR N_FIT_ASTROM MAG_SYS_ERR N_FIT_PHOTOM", 150 173 self.scratchDb.dvoImagesTable) 151 174 self.logger.infoPair("Adding primary key to", self.scratchDb.dvoImagesTable) … … 559 582 self.logger.debugPair("Reading IPP table", table.name) 560 583 table = stilts.tpipe(table, cmd='explodeall') 561 #adds an index to all the tables 562 # table = stilts.tpipe(table, cmd='addcol table_index $0') 584 585 # adds an index to all the tables 586 # table = stilts.tpipe(table, cmd='addcol table_index $0') 563 587 564 588 # IPP FITS files are littered with infinity values. Remove them … … 566 590 table = stilts.tpipe(table, cmd='replaceval -Infinity null *') 567 591 table = stilts.tpipe(table, cmd='replaceval Infinity null *') 592 593 # verify that all columns in 'columns' exist in the tabl 594 ## myColumns = table.columns() 595 ## for wcol in columns: 596 ## foundCol = False 597 ## for tcol in myColumns: 598 ## if (wcol == tcol.name): 599 ## print "found wcol " + wcol 600 ## foundCol = True; 601 ## break 602 ## if not foundCol: 568 603 569 604 attempts = 0 … … 575 610 table.cmd_keepcols(columns).write(self.scratchDb.url + '#' + tableName) 576 611 break 577 except: 578 # wait a few secs then try again 612 except Exception,e: 613 # print the error, wait a few secs then try again 614 print str(e) 579 615 time.sleep(2) 580 616 attempts = attempts + 1 … … 663 699 664 700 ''' 701 Find and read a header extension. 702 ''' 703 def readFitsHeader(self, extname, filename): 704 705 cmd = "fhead -n %s %s" % (extname, filename) 706 p = Popen(cmd, shell=True, stdout=PIPE) 707 output = p.communicate()[0] 708 709 header = {} 710 711 # split the output header bytes into key/value pairs for each 80-byte line 712 for i in range(0, len(output), 80): 713 # print "line %d : %s" % (i, output[i:i+80]) 714 record = output[i:i+80] 715 716 match = re.match('^(HIERARCH )*([a-zA-Z0-9-_\.]+)\s*=\s+\'*([a-zA-Z0-9-+_\.:\s@#\(\)\,]+)\'*\\/*', record) 717 718 if match: 719 param = match.group(2) 720 value = match.group(3).strip() 721 if value == "NaN": value = "NULL" 722 header[param] = value 723 724 return header 725 726 ''' 665 727 ingest skyregion into MySQL database using the native DVO program dvopsps 666 728 Populates dvoDetections and dvoDone with FITS tables from DVO for the defined sky area, this … … 688 750 689 751 # make sure we have an up-to-date Images table 690 self.loadImages() # this is in nativeIngestDetections (remove?) 752 if not self.loadImages(): # this is in nativeIngestDetections (remove?) 753 self.logger.debugPair("FAILED to load images", "exiting") 754 os._exit(1) 755 756 print "DONE load images (nativeIngestDetections)" 691 757 692 758 # the box dimensions are the area used to select the items of
Note:
See TracChangeset
for help on using the changeset viewer.
