Changeset 12975


Ignore:
Timestamp:
02/29/12 22:02:53 (13 years ago)
Author:
lusterma
Message:
added iterator to RawData, _test_iter function gives an example on usage, ./pyfact.py can be run directly
File:
1 edited

Legend:

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

    r12947 r12975  
    113113        self.pulse_amplitude = None
    114114
     115    def __iter__(self):
     116        """ iterator """
     117        return self
     118       
     119    def next(self):
     120        """ used by __iter__ """
     121        if self.event_id.value == self.nevents:
     122            raise StopIteration
     123        else:
     124            self.data_file.GetNextRow()
     125            self.calibrate_drs_amplitude()
     126        return self.acal_data, self.start_cells, self.trigger_type.value
     127
    115128    def next_event(self):
    116129        """ load the next event from disk and calibrate it
     
    361374# end of class definition: fnames( object )
    362375
     376def _test_iter():
     377    """ test for function __iter__ """
     378
     379    data_file_name = '/data00/fact-construction/raw/2011/11/24/20111124_111.fits.gz'
     380    calib_file_name = '/data00/fact-construction/raw/2011/11/24/20111124_111.drs.fits.gz'
     381    run = RawData( data_file_name, calib_file_name )
     382
     383    for data, scell, tt in run:
     384        print 'data[0,0] = ', data[0,0], "start_cell[0] =", scell[0], "trigger type = ", tt
     385
     386
    363387if __name__ == '__main__':
    364     """
    365     create an instance
    366     """
    367     data_file_name = '/data03/fact-construction/raw/2011/11/24/20111124_121.fits'
    368     calib_file_name = '/data03/fact-construction/raw/2011/11/24/20111124_111.drs.fits'
    369     rd = rawdata( data_file_name, calib_file_name )
    370     rd.info()
    371     rd.next()
    372    
    373 # for i in range(10):
    374 #    df.GetNextRow()
    375 
    376 #    print 'evNum: ', evNum.value
    377 #    print 'start_cells[0:9]: ', start_cells[0:9]
    378 #    print 'evData[0:9]: ', evData[0:9]
     388    """ tests  """
     389
     390    _test_iter()
Note: See TracChangeset for help on using the changeset viewer.