IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2011, 11:00:22 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

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
  • branches/eam_branches/ipp-20110710/ippToPsps/jython/fits.py

    r31849 r32337  
    1717    def __init__(self, logger, doc, originalPath):
    1818
     19       # set class variables
    1920       self.originalPath = originalPath
    2021       self.logger = logger
    2122       self.doc = doc
     23       self.header = None
    2224       self.localDir = self.doc.find("localOutPath").text
    2325
    24        # does it exist?
     26       # does this file even exist?
    2527       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)
    2729           return
    2830
    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)
    3033       self.localCopyPath = self.localDir + "/temp.fits"
    3134       shutil.copy2(self.originalPath, self.localCopyPath)
    3235
     36       # open the local copy and parse the ridiculou plain-text header
    3337       self.file = open(self.localCopyPath)
    3438       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
    3743       self.rewindToStart()
    3844
    3945    '''
    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
    4153    '''
    4254    def getPath(self):
    4355        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
    4462
    4563    '''
     
    5775        else: return "NULL"
    5876
    59 
     77    '''
     78    Moves the file pointer back to the start of this file
     79    '''
    6080    def rewindToStart(self):
    6181        self.file.seek(0, 0)
     
    6383
    6484    '''
    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
    6688    '''
    6789    def findAndReadHeader(self, name):
     
    91113
    92114            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)
    94116            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")
    96119
    97120        return header
Note: See TracChangeset for help on using the changeset viewer.