示例#1
0
    def organized(self,spav="fast",non_ill=1):
        """ Sort all raw data in a 11 x npos array
            structure of all_mean = AH then ZZZ or NN or NZ for instance 
            mirror positions : ["N","Z","A","H"] """
            
        if spav == "fast":
            npix = 2
            
        else:
            npix = 4800
          
        all_mean = zeros([11,self.npos,npix])   # all mean frames from raw files are stored in all_mean (11 filter wheel positions, npos pointing mirror positions)
        all_std = zeros([11,self.npos,npix])    # all std from raw files are stored in all_std (11 filter wheel positions, npos pointing mirror positions
        all_tms = zeros([11,self.npos])         # relative timestamp of each raw file (average through all frames)
        real_tms = []                           # absolute timestamp of each mirror position (when filter wheel in position 5)        
        counter_filters = zeros([11])           # number of scene positions already accoiunted for for each filter
        
        for fichier in self.files:              
            raw_data = FirrRaw(fichier) 
            nf = min(raw_data.nframes,self.nframes)
            raw_data.analyze(nf,spav=spav,illuminated=self.illuminated,non_illuminated=self.non_illuminated,non_ill=non_ill)
#            print fichier,raw_data.good
#            if raw_data.good: # do not read ill files    
            correct_pixels = raw_data.correct_pixels
      
            if raw_data.mpos == 2 and all_mean[raw_data.fpos-1,0,:].all() == 0:               # keep only first calibration                 
                all_mean[raw_data.fpos-1,0,correct_pixels] = raw_data.mean[correct_pixels]
                all_std[raw_data.fpos-1,0,correct_pixels] = raw_data.std[correct_pixels]
                all_tms[raw_data.fpos-1,0] = raw_data.tms 
                
            elif raw_data.mpos == 3 and all_mean[raw_data.fpos-1,1,:].all() == 0:               # keep only first calibration
                all_mean[raw_data.fpos-1,1,correct_pixels] = raw_data.mean[correct_pixels]
                all_std[raw_data.fpos-1,1,correct_pixels] = raw_data.std[correct_pixels]
                all_tms[raw_data.fpos-1,1] = raw_data.tms  
                
            elif raw_data.mpos == 0 or raw_data.mpos == 1:  # nadir or zenith view
                scene = counter_filters[raw_data.fpos-1] + 2                                          
                all_mean[raw_data.fpos-1,scene,correct_pixels] = raw_data.mean[correct_pixels]
                all_std[raw_data.fpos-1,scene,correct_pixels] = raw_data.std[correct_pixels]
                all_tms[raw_data.fpos-1,scene] = raw_data.tms    
                counter_filters[raw_data.fpos-1]+=1 

                
        for np in range(self.npos):
            real_tms+=[self.date0+timedelta(seconds=1e-3*all_tms[5,np])]                       
          
        self.all_mean = ma.masked_equal(all_mean,0)
        self.all_std = all_std
        self.all_tms = all_tms
        self.real_timestamp = real_tms
示例#2
0
    def organized(self,spav="all"):
        """ Sort all raw data in a 11 x npos array
            structure of all_mean = AH then ZZZ or NN or NZ for instance 
            mirror positions : ["N","Z","A","H"] """
            
        if spav == "all":
            npix = 2
            
        else:
            npix = 4800
          
        all_mean = zeros([11,self.npos,npix])   # all mean frames from raw files are stored in all_mean (11 filter wheel positions, npos pointing mirror positions)
        all_std = zeros([11,self.npos,npix])    # all std from raw files are stored in all_std (11 filter wheel positions, npos pointing mirror positions
        all_tms = zeros([11,self.npos])         # relative timestamp of each raw file (average through all frames)
        real_tms = []                           # absolute timestamp of each mirror position (when filter wheel in position 5)        
                
        for fichier in self.files:              
            raw_data = FirrRaw(fichier)            
            raw_data.analyze(raw_data.nframes,spav=spav) 
            
            correct_pixels = raw_data.correct_pixels
      
            if raw_data.mpos == 2 and all_mean[raw_data.fpos-1,0,:].all() == 0:               # keep only first calibration                 
                all_mean[raw_data.fpos-1,0,correct_pixels] = raw_data.mean[correct_pixels]
                all_std[raw_data.fpos-1,0,correct_pixels] = raw_data.std[correct_pixels]
                all_tms[raw_data.fpos-1,0] = raw_data.tms 
                
            elif raw_data.mpos == 3 and all_mean[raw_data.fpos-1,1,:].all() == 0:               # keep only first calibration
                all_mean[raw_data.fpos-1,1,correct_pixels] = raw_data.mean[correct_pixels]
                all_std[raw_data.fpos-1,1,correct_pixels] = raw_data.std[correct_pixels]
                all_tms[raw_data.fpos-1,1] = raw_data.tms  
                
            elif raw_data.mpos == 0 or raw_data.mpos == 1:  # nadir or zenith view
                scene = 0
                while all_mean[raw_data.fpos-1,scene+2,:].any()!=0: 
                    scene+=1                     

                all_mean[raw_data.fpos-1,scene+2,correct_pixels] = raw_data.mean[correct_pixels]
                all_std[raw_data.fpos-1,scene+2,correct_pixels] = raw_data.std[correct_pixels]
                all_tms[raw_data.fpos-1,scene+2] = raw_data.tms    
        
        for np in range(self.npos):
            real_tms+=[self.date0+timedelta(seconds=1e-3*all_tms[5,np])]                       
          
        self.all_mean = all_mean
        self.all_std = all_std
        self.all_tms = all_tms
        self.real_timestamp = real_tms
示例#3
0
from FirrRaw import FirrRaw

#-------------Latex Style--------------
rc('font',**{'family':'serif','serif':['Computer Modern'],'size':'17'})
rc('text', usetex=True)
##--------------------------------------
#
rc('xtick',labelsize=22) 
rc('ytick',labelsize=22)

""" Read a sample raw file and return the correspondin mirror position, filter position, number of frames, \
number of pixels per frame, average frame and standard deviation of all frames"""

rawfile = "Data/test.raw"

raw_data_nospav = FirrRaw(rawfile) # create a FirrRaw object
raw_data_spav = FirrRaw(rawfile) 

raw_data_nospav.analyze() # Analyze the file to extract all necessary information
raw_data_spav.analyze(spav=2) 

print "mirror position",raw_data_nospav.mpos
print "filter position",raw_data_nospav.fpos
print "number of frames",raw_data_nospav.nframes
print "number of pixels per frame",raw_data_nospav.npixels
print "number of bad pixels",raw_data_nospav.npixels-shape(raw_data_nospav.correct_pixels)[1]

mean_image_nospav = raw_data_nospav.mean
std_image_nospav = raw_data_nospav.std

mean_image_spav = raw_data_spav.mean