Changeset 12987
- Timestamp:
- 03/01/12 15:47:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/pyfact_rename.py
r12975 r12987 119 119 def next(self): 120 120 """ used by __iter__ """ 121 if self.event_id.value == self.nevents: 121 122 if self.data_file.GetNextRow() == False: 122 123 raise StopIteration 123 124 else: 124 self.data_file.GetNextRow()125 125 self.calibrate_drs_amplitude() 126 127 #print 'nevents = ', self.nevents, 'event_id = ', self.event_id.value 126 128 return self.acal_data, self.start_cells, self.trigger_type.value 127 129 … … 158 160 self.acal_data = acal_data * 1907.35 159 161 160 161 def filter_sliding_average(self, window_size=4):162 """ sliding average filter163 164 using:165 self.acal_data166 filling array:167 self.data_saverage_out168 169 """170 171 #scipy.signal.lfilter(b, a, x, axis=-1, zi=None)172 data_saverage_out = self.acal_data.copy()173 b = np.ones( window_size )174 a = np.zeros( window_size )175 a[0] = len(b)176 data_saverage_out[:,:] = signal.lfilter(b, a, data_saverage_out[:,:])177 178 #: data output of sliding average filter179 self.data_saverage_out = data_saverage_out180 181 182 def filter_CFD(self, length=10, ratio=0.75):183 """ constant fraction discriminator (implemented as FIR)184 185 using:186 self.data_saverage_out187 filling array:188 self.data_CFD_out189 190 """191 192 if self.data_saverage_out == None:193 print """error pyfact.filter_CFD was called without194 prior call to filter_sliding_average195 variable self.data_saverage_out is needed196 """197 198 data_CFD_out = self.data_saverage_out.copy()199 b = np.zeros(length)200 a = np.zeros(length)201 b[0] = -1. * ratio202 b[length-1] = 1.203 a[0] = 1.204 data_CFD_out[:,:] = signal.lfilter(b, a, data_CFD_out[:,:])205 206 #: data output of the constant fraction discriminator207 self.data_CFD_out = data_CFD_out208 209 def find_peak(self, min=30, max=250):210 """ find maximum in search window211 212 using:213 self.data_saverage_out214 filling arrays:215 self.pulse_time_of_maximum216 self.pulse_amplitude217 218 """219 220 if self.data_saverage_out == None:221 print """error pyfact.find_peakMax was called without \222 prior call to filter_sliding_average223 variable self.data_saverage_out is needed"""224 pass225 226 pulse_time_of_maximum = np.argmax( self.data_saverage_out[:,min:max],227 1)228 pulse_amplitude = np.max( self.data_saverage_out[:,min:max], 1)229 self.pulse_time_of_maximum = pulse_time_of_maximum230 self.pulse_amplitude = pulse_amplitude231 232 def sum_around_peak(self, left=13, right=23):233 """ integrate signal in gate around Peak234 235 using:236 self.pulse_time_of_maximum237 self.acal_data238 filling array:239 self.pulse_integral_simple240 241 """242 243 if self.pulse_time_of_maximum == None:244 print """error pyfact.sum_around_peak was called \245 without prior call of find_peak246 variable self.pulse_time_of_maximum is needed"""247 pass248 249 # find left and right limit and sum the amplitudes in the range250 pulse_integral_simple = np.empty(self.npix)251 for pixel in range(self.npix):252 min = self.pulse_time_of_maximum[pixel]-left253 max = self.pulse_time_of_maximum[pixel]+right254 pulse_integral_simple[pixel] = self.acal_data[pixel,min:max].sum()255 256 self.pulse_integral_simple = pulse_integral_simple257 162 258 163 def baseline_read_values(self, file, bsl_hist='bsl_sum/hplt_mean'):
Note:
See TracChangeset
for help on using the changeset viewer.