Changeset 31949 for trunk/ippToPsps/jython/fits.py
- Timestamp:
- Jul 29, 2011, 9:53:42 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/fits.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/fits.py
r31849 r31949 22 22 self.localDir = self.doc.find("localOutPath").text 23 23 24 # does itexist?24 # does this file even exist? 25 25 if not os.path.isfile(self.originalPath): 26 self.logger.error ("Cannot read file at '" + self.originalPath + "'")26 self.logger.errorPair("Cannot read file", self.originalPath) 27 27 return 28 28 29 # ok, we have a file, now copy it locally to save on NFS overhead 29 30 self.logger.infoPair("FITS file", self.originalPath) 30 31 self.localCopyPath = self.localDir + "/temp.fits" 31 32 shutil.copy2(self.originalPath, self.localCopyPath) 32 33 34 # open the local copy and parse the ridiculou plain-text header 33 35 self.file = open(self.localCopyPath) 34 36 self.header = self.parseHeader() 35 37 self.logger.infoPair("FITS local copy", self.localCopyPath) 36 38 self.logger.infoPair("FITS primary header", "%d cards found" % len(self.header)) 39 40 # move file pointer back to the start of the file 37 41 self.rewindToStart() 38 42 39 43 ''' 40 Returns the path to th is FITS file44 Returns the path to the LOCAL COPY of this FITS file 41 45 ''' 42 46 def getPath(self): … … 58 62 59 63 64 ''' 65 Moves the file pointer back to the start of this file 66 ''' 60 67 def rewindToStart(self): 61 68 self.file.seek(0, 0) … … 63 70 64 71 ''' 65 Finds and reads a header extension 72 Finds and reads a header extension. 73 74 2880 is the magic number that the FITS format uses to break up data: extensions always begin on multiples of 2880 bytes 66 75 ''' 67 76 def findAndReadHeader(self, name): … … 91 100 92 101 self.file.seek(origIndex, 0) 93 self.logger.error ("...could not read header in extension '" + name + "'")102 self.logger.errorPair("Could not read header", name) 94 103 return 95 #else: self.logger.info("...read header at '" + name + "' and found " + str(len(header)) + " header cards") 104 else: 105 self.logger.debug("...read header at '" + name + "' and found " + str(len(header)) + " header cards") 96 106 97 107 return header
Note:
See TracChangeset
for help on using the changeset viewer.
