Changeset 13132
- Timestamp:
- 03/16/12 08:58:47 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/extractor.py
r13028 r13132 130 130 131 131 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()148 132 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 133 def _test_GlobalMaxFinder(): 164 134 gmf = GlobalMaxFinder(30,250) 165 135 print gmf … … 171 141 else: 172 142 print "BAD: time mean:", time.mean() 173 174 print 175 176 # Test FixedWindowIntegrator 143 144 def _test_FixedWindowIntegrator(): 177 145 fwi = FixedWindowIntegrator(50,200) 178 146 print fwi … … 183 151 else: 184 152 print "Test 2: X FixedWindowIntegrator integral.mean failed:", integral.mean() 185 186 print 153 154 def _test_ZeroXing(): 187 155 cfd = CFD() 188 156 sa = SlidingAverage(8) … … 203 171 print 'most probable time of zero-crossing', most_probable_time/10. 204 172 print 'this includes filter delays ... for average filter setting 8 this turns out to be 78.8 most of the time' 173 174 if __name__ == '__main__': 175 """ test the extractors """ 205 176 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 209 188 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.