Ignore:
Timestamp:
03/20/12 09:27:24 (13 years ago)
Author:
neise
Message:
new interface of next(), and hence a new option in the __init__() methon ... old interface is considered depricated
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/pyfact/pyfact.py

    r13155 r13156  
    2929    def __init__(self, data_file_name, calib_file_name,
    3030                user_action_calib=lambda acal_data, data, blm, tom, gm, scells, nroi: None,
    31                 baseline_file_name=''):
     31                baseline_file_name='',
     32                return_dict = None):
    3233        """ initialize object
    33 
     34       
    3435        open data file and calibration data file
    3536        get basic information about the data in data_file_name
     
    3940        calib_file_name : fits or fits.gz file containing DRS calibration data
    4041        baseline_file_name : npy file containing the baseline values
    41        
    42         """
    43 
     42        """
     43        # manual implementation of default value, but I need to find out
     44        # if the user of this class is aware of the new option
     45        if return_dict == None:
     46            print 'Warning: Rawdata.__init__() has a new option "return_dict"'
     47            print 'the default value of this option is False, so nothing changes for you at the moment.'
     48            print
     49            print 'you probably want, to get a dictionary out of the next() method anyway'
     50            print ' so please change your scripts and set this option to True, for the moment'
     51            print 'e.g. like this: run = RawData(data_filename, calib_filename, return_dict = True)'
     52            print "after a while, the default value, will turn to True .. so you don't have to give the option anymore"
     53            print 'and some time later, the option will not be supported anymore'
     54            return_dict = False
     55
     56        self.return_dict = return_dict
     57       
    4458        self.data_file_name = data_file_name
    4559        self.calib_file_name = calib_file_name
     
    115129
    116130        self.v_bsl = np.zeros(self.npix)  # array of baseline values (all ZERO)
    117         self.data_saverage_out = None
    118         self.pulse_time_of_maximum = None
    119         self.pulse_amplitude = None
    120131
    121132    def __iter__(self):
     
    136147
    137148        #print 'nevents = ', self.nevents, 'event_id = ', self.event_id.value
    138 
    139         return self.acal_data, self.start_cells, self.trigger_type.value
     149        if self.return_dict:
     150            return self.__dict__
     151        else:
     152            return self.acal_data, self.start_cells, self.trigger_type.value
    140153
    141154    def next_event(self):
     
    165178            # rotate the pixel baseline mean to the Data startCell
    166179            blm_pixel = np.roll( blm[pixel,:], -self.start_cells[pixel] )
    167             tom_pixel =  tom[pixel,:]
     180            # rotate the pixel gain mean to the Data startCell
    168181            gm_pixel = np.roll( gm[pixel,:], -self.start_cells[pixel] )
     182            # the 'trigger offset mean' does not need to be rolled
     183            # on the contrary, it seems there is an offset in the DRS data,
     184            # which is related to its distance to the startCell, not to its
     185            # distance to the beginning of the physical pipeline in the DRS chip
     186            tom_pixel = tom[pixel,:]
     187           
    169188            acal_data[pixel,:] -= blm_pixel[0:self.nroi]
    170189            acal_data[pixel,:] -= tom_pixel[0:self.nroi]
Note: See TracChangeset for help on using the changeset viewer.