IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31949


Ignore:
Timestamp:
Jul 29, 2011, 9:53:42 AM (15 years ago)
Author:
rhenders
Message:

added comments and improved some logging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/fits.py

    r31849 r31949  
    2222       self.localDir = self.doc.find("localOutPath").text
    2323
    24        # does it exist?
     24       # does this file even exist?
    2525       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)
    2727           return
    2828
     29       # ok, we have a file, now copy it locally to save on NFS overhead
    2930       self.logger.infoPair("FITS file", self.originalPath)
    3031       self.localCopyPath = self.localDir + "/temp.fits"
    3132       shutil.copy2(self.originalPath, self.localCopyPath)
    3233
     34       # open the local copy and parse the ridiculou plain-text header
    3335       self.file = open(self.localCopyPath)
    3436       self.header = self.parseHeader()
    3537       self.logger.infoPair("FITS local copy", self.localCopyPath)
    3638       self.logger.infoPair("FITS primary header", "%d cards found" % len(self.header))
     39
     40       # move file pointer back to the start of the file
    3741       self.rewindToStart()
    3842
    3943    '''
    40     Returns the path to this FITS file
     44    Returns the path to the LOCAL COPY of this FITS file
    4145    '''
    4246    def getPath(self):
     
    5862
    5963
     64    '''
     65    Moves the file pointer back to the start of this file
     66    '''
    6067    def rewindToStart(self):
    6168        self.file.seek(0, 0)
     
    6370
    6471    '''
    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
    6675    '''
    6776    def findAndReadHeader(self, name):
     
    91100
    92101            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)
    94103            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")
    96106
    97107        return header
Note: See TracChangeset for help on using the changeset viewer.