Ignore:
Timestamp:
03/16/12 08:58:47 (13 years ago)
Author:
neise
Message:
moved tests out of __main__ into dedicated _test_funcs(), so making __main__ smaller and easier to comprehend
File:
1 edited

Legend:

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

    r13028 r13132  
    130130
    131131
    132 def plotter(signal, text):
    133     x=range(len(signal))
    134     ax = plt.plot(x, signal, 'b.', label='signal')
    135     plt.title(text)
    136     plt.xlabel('sample')
    137     plt.legend()
    138     plt.grid(True)
    139     plt.show()
    140    
    141 def histplotter(signal, text):
    142     plt.xlabel('time of zero crossing')
    143     plt.title(text)
    144     plt.axis([0, 300,0,1440])
    145     plt.grid(True)
    146     n, bins, patches = plt.hist(signal, 3000, facecolor='r', alpha=0.75)
    147     plt.show()
    148132
    149 
    150 if __name__ == '__main__':
    151     """ test the extractors """
    152     sg = SignalGenerator()
    153     pulse_str = 'len 300 bsl -0.5 noise 0.5 triangle 65 10 8 100'
    154     pulse = sg(pulse_str)
    155     event = []
    156     for i in range(1440):
    157         event.append(sg(pulse_str))
    158     event = np.array(event)
    159     print 'test event with 1000 pixel generated, like this:'
    160     print pulse_str
    161     print
    162    
    163     # Test GlobalMaxFinder
     133def _test_GlobalMaxFinder():
    164134    gmf = GlobalMaxFinder(30,250)
    165135    print gmf
     
    171141    else:
    172142        print "BAD: time mean:", time.mean()
    173    
    174     print
    175    
    176     # Test FixedWindowIntegrator
     143
     144def _test_FixedWindowIntegrator():
    177145    fwi = FixedWindowIntegrator(50,200)
    178146    print fwi
     
    183151    else:
    184152        print "Test 2:  X FixedWindowIntegrator integral.mean failed:", integral.mean()
    185    
    186     print
     153
     154def _test_ZeroXing():
    187155    cfd = CFD()
    188156    sa = SlidingAverage(8)
     
    203171    print 'most probable time of zero-crossing', most_probable_time/10.
    204172    print 'this includes filter delays ... for average filter setting 8 this turns out to be 78.8 most of the time'
     173
     174if __name__ == '__main__':
     175    """ test the extractors """
    205176   
    206     #histplotter(times.flatten(), 'times.flatten()')
    207     #plotter(cfd_out[0], 'cfd_out')
    208     #plotter (pulse, pulse_str)
     177    # Generate a fake event, with a triangular pulse at slice 65
     178    sg = SignalGenerator()
     179    pulse_str = 'len 300 bsl -0.5 noise 0.5 triangle 65 10 8 100'
     180    pulse = sg(pulse_str)
     181    event = []
     182    for i in range(1440):
     183        event.append(sg(pulse_str))
     184    event = np.array(event)
     185    print 'test event with 1000 pixel generated, like this:'
     186    print pulse_str
     187    print
    209188   
    210 
    211 
     189    print '_test_GlobalMaxFinder()'
     190    _test_GlobalMaxFinder()
     191    print
     192    print
     193    print '_test_FixedWindowIntegrator()'
     194    _test_FixedWindowIntegrator()
     195    print
     196    print
     197    print '_test_ZeroXing()'
     198    _test_ZeroXing()
     199    print
Note: See TracChangeset for help on using the changeset viewer.