コード例 #1
0
ファイル: clfits.py プロジェクト: ppmim/AFOSN
def checkDataProperties( file_list, c_type=True, c_filter=True, c_texp=True, 
                         c_ncoadds=True, c_readmode=True):
    """
    This function will check all the files in the file_list have the same 
    properties required as True in the parameters.
    Note that that properties should be available in the main header(0) in case 
    of MEF files.
    """
    
    m_type = ''
    m_filter = ''
    m_texp = ''
    m_ncoadds = ''
    m_readmode = ''
    
    # First file as reference
    if len(file_list)>0 and file_list[0]:
            f = ClFits( file_list[0] )
            m_type = f.getType()
            m_filter = f.getFilter()
            m_texp = f.expTime()
            m_ncoadds = f.getNcoadds()
            m_readmode = f.getReadMode()
    
    # Check all files        
    for file in file_list:
            f = ClFits ( file )
            debug = 0
            if debug:
                print 'FILE=',file
                print '------------------------'
                print 'TYPE=', f.getType()
                print 'FILTER=', f.getFilter()
                print 'TEXP=', f.expTime()
                print 'NCOADDS=', f.getNcoadds()
                print 'READMODE=', f.getReadMode()
            
            if (  (c_type and m_type!=f.getType()) or 
                  (c_filter and m_filter!=f.getFilter()) or 
                  (c_texp and m_texp!=f.expTime()) or 
                  (c_ncoadds and m_ncoadds!=f.getNcoadds()) or 
                  (c_readmode and m_readmode!=f.getReadMode())):
                
                log.debug("Missmath on some property (FILTER, EXPTIME, NCOADDS or  READMODE)")
                return False
        
    log.debug("Successful properties checking")
    
    return True      
コード例 #2
0
ファイル: clfits.py プロジェクト: ppmim/AFOSN
                                 ignore_missing_end=True) # since some problems with O2k files                               
            
            #if len(myfits)==0 or 'SIMPLE' not in myfits[0].header or myfits[0].header['SIMPLE']!=True:
            #    raise ValueError('Found a not compliant FITS file.')

            #myfits = pyfits.open(self.pathname, 'update')
            #myfits[0].verify()
        except Exception,e:
            log.error("Could not open frame %s. Error in file : %s"%(self.pathname, str(e)))
            raise e
        
        #Check if is a MEF file 
        if len(myfits)>1:
            self.mef = True
            self.next = len(myfits)-1
            log.debug("Found a MEF file with %d extensions", self.next)
        else:
            self.mef = False
            self.next = 1
            ###log.debug("Found a simple FITS file")
        
        # If file is a MEF, some values will be read from the header extensions      
        if self.mef:
            # we suppose all extension have the same dimensions
            self.naxis1 = myfits[1].header['NAXIS1']
            self.naxis2 = myfits[1].header['NAXIS2']
            #self._shape = myfits[1].data.shape # (naxis3, naxis2, naxis1)
            #Because the pyfits.data.shape makes extremealy slow read
            #of the FITS-file (mainly because shape need to read the whole image),
            #we build a shape tuple from the header values (NAXIS1, NAXIS2, and NAXIS3 )
            if 'NAXIS3' in myfits[1].header: