Changeset 12986
- Timestamp:
- 03/01/12 15:31:05 (13 years ago)
- Location:
- fact/tools/pyscripts/pyfact
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/extractor.py
r12981 r12986 128 128 """ test the extractors """ 129 129 sg = SignalGenerator() 130 pulse_str = 'len 300 bsl -0.5 noise 0.5 triangle 10 658 100'130 pulse_str = 'len 300 bsl -0.5 noise 0.5 triangle 65 10 8 100' 131 131 pulse = sg(pulse_str) 132 132 event = [] -
fact/tools/pyscripts/pyfact/generator.py
r12982 r12986 44 44 45 45 if 'triangle' in o: 46 self.triangle_height = float(o['triangle'][0]) 47 self.triangle_pos = float(o['triangle'][1]) 48 self.triangle_rise = int(o['triangle'][2]) 49 self.triangle_fall = int(o['triangle'][3]) 46 self.pulses = [] 47 # append 1st pulse to list of pulses 48 self.pulses.append( ( float(o['triangle'][0]) , float(o['triangle'][1]), int(o['triangle'][2]), int(o['triangle'][3]) ) ) 49 number_of_pulses_after_1st = (len(o['triangle'])-4)/2 50 for i in range(number_of_pulses_after_1st): 51 self.pulses.append( ( float(o['triangle'][2*i+4]) , float(o['triangle'][2*i+5]), int(o['triangle'][2]), int(o['triangle'][3]) ) ) 50 52 51 53 if 'spike' in o: … … 66 68 signal[self.step_start:self.step_stop] += self.step_height 67 69 if 'triangle' in self.options: 68 start = self.triangle_pos - self.triangle_rise 69 stop = self.triangle_pos + self.triangle_fall 70 pos = self.triangle_pos 71 height = self.triangle_height 72 signal[start:pos] += np.linspace(0., height, self.triangle_rise) 73 signal[pos:stop] += np.linspace(height, 0. , self.triangle_fall) 70 for pulse in self.pulses: 71 pos = pulse[0] 72 height = pulse[1] 73 rise = pulse[2] 74 fall = pulse[3] 75 start = pos - rise 76 stop = pos + fall 77 signal[start:pos] += np.linspace(0., height, rise) 78 signal[pos:stop] += np.linspace(height, 0. , fall) 74 79 if 'spike' in self.options: 75 80 for spike in self.spikes: … … 84 89 s += ' * bsl: level (-0.5)\n' 85 90 s += ' * step: height, start, end\n' 86 s += ' * triangle: height, position, risingedge, fallingedge\n'91 s += ' * triangle: pos height risingedge, fallingedge [pos height ...]\n' 87 92 s += ' * spike: pos height [pos height ...]\n' 88 93 … … 121 126 if __name__ == '__main__': 122 127 """ test the class """ 123 myGenerator = SignalGenerator('len 100 noise 0.3 bsl -2.5 step 20.3 12 24 triangle 10.2 50 10 30 spike 2 50. 20 50')128 myGenerator = SignalGenerator('len 400 noise 0.3 bsl -2.5 triangle 50 10.2 10 100 65 10 150 20 180 10 250 10 spike 100 50. 20 50 21 49') 124 129 sig = myGenerator() 125 130 print myGenerator
Note:
See TracChangeset
for help on using the changeset viewer.