- Timestamp:
- Sep 6, 2011, 11:00:22 AM (15 years ago)
- Location:
- branches/eam_branches/ipp-20110710/ippToPsps/jython
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/ippToPsps/jython
-
Property svn:ignore
set to
*.class
-
Property svn:ignore
set to
-
branches/eam_branches/ipp-20110710/ippToPsps/jython/fits.py
r31849 r32337 17 17 def __init__(self, logger, doc, originalPath): 18 18 19 # set class variables 19 20 self.originalPath = originalPath 20 21 self.logger = logger 21 22 self.doc = doc 23 self.header = None 22 24 self.localDir = self.doc.find("localOutPath").text 23 25 24 # does itexist?26 # does this file even exist? 25 27 if not os.path.isfile(self.originalPath): 26 self.logger.error ("Cannot read file at '" + self.originalPath + "'")28 self.logger.errorPair("Cannot read file", self.originalPath) 27 29 return 28 30 29 self.logger.infoPair("FITS file", self.originalPath) 31 # ok, we have a file, now copy it locally to save on NFS overhead 32 self.logger.debugPair("FITS file", self.originalPath) 30 33 self.localCopyPath = self.localDir + "/temp.fits" 31 34 shutil.copy2(self.originalPath, self.localCopyPath) 32 35 36 # open the local copy and parse the ridiculou plain-text header 33 37 self.file = open(self.localCopyPath) 34 38 self.header = self.parseHeader() 35 self.logger.infoPair("FITS local copy", self.localCopyPath) 36 self.logger.infoPair("FITS primary header", "%d cards found" % len(self.header)) 39 self.logger.debugPair("FITS local copy", self.localCopyPath) 40 self.logger.debugPair("FITS primary header", "%d cards found" % len(self.header)) 41 42 # move file pointer back to the start of the file 37 43 self.rewindToStart() 38 44 39 45 ''' 40 Returns the path to this FITS file 46 Returns count of 'cards' found in primary header 47 ''' 48 def getPrimaryHeaderCardCount(self): 49 return len(self.header) 50 51 ''' 52 Returns the path to the LOCAL COPY of this FITS file 41 53 ''' 42 54 def getPath(self): 43 55 return self.localCopyPath 56 57 ''' 58 Returns the path to the LOCAL COPY of this FITS file 59 ''' 60 def getOriginalPath(self): 61 return self.originalPath 44 62 45 63 ''' … … 57 75 else: return "NULL" 58 76 59 77 ''' 78 Moves the file pointer back to the start of this file 79 ''' 60 80 def rewindToStart(self): 61 81 self.file.seek(0, 0) … … 63 83 64 84 ''' 65 Finds and reads a header extension 85 Finds and reads a header extension. 86 87 2880 is the magic number that the FITS format uses to break up data: extensions always begin on multiples of 2880 bytes 66 88 ''' 67 89 def findAndReadHeader(self, name): … … 91 113 92 114 self.file.seek(origIndex, 0) 93 self.logger.error ("...could not read header in extension '" + name + "'")115 self.logger.errorPair("Could not read header", name) 94 116 return 95 #else: self.logger.info("...read header at '" + name + "' and found " + str(len(header)) + " header cards") 117 else: 118 self.logger.debug("...read header at '" + name + "' and found " + str(len(header)) + " header cards") 96 119 97 120 return header
Note:
See TracChangeset
for help on using the changeset viewer.
