- Timestamp:
- 04/25/12 07:50:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/pyfact.py
r13384 r13441 297 297 298 298 # ----------------------------------------------------------------------------- 299 class RawDataFake( object ): 300 """ raw data FAKE access similar to real RawData access 301 """ 302 303 304 def __init__(self, data_file_name, calib_file_name, 305 user_action_calib=lambda acal_data, data, blm, tom, gm, scells, nroi: None, 306 baseline_file_name=''): 307 self.__module__='pyfact' 308 309 self.nroi = 300 310 self.npix = 9 311 self.nevents = 1000 312 313 self.simulator = None 314 315 self.time = np.ones(1024) * 0.5 316 317 318 self.event_id = c_ulong(0) 319 self.trigger_type = c_ushort(4) 320 self.data = np.zeros( self.npix * self.nroi, np.int16 ).reshape(self.npix ,self.nroi) 321 self.start_cells = np.zeros( self.npix, np.int16 ) 322 self.board_times = np.zeros( 40, np.int32 ) 323 def __iter__(self): 324 """ iterator """ 325 return self 326 327 def next(self): 328 """ used by __iter__ """ 329 self.event_id = c_ulong(self.event_id.value + 1) 330 self.board_times = self.board_times + 42 331 332 if self.event_id.value >= self.nevents: 333 raise StopIteration 334 else: 335 self._make_event_data() 336 337 return self.__dict__ 338 339 def _make_event_data(self): 340 sample_times = self.time.cumsum() - time[0] 341 342 # random start cell 343 self.start_cells = np.ones( self.npix, np.int16 ) * np.random.randint(0,1024) 344 345 starttime = self.start_cells[0] 346 347 signal = self._std_sinus_simu(sample_times, starttime) 348 349 data = np.vstack( (signal,signal) ) 350 for i in range(8): 351 data = np.vstack( (data,signal) ) 352 353 self.data = data 354 355 def _std_sinus_simu(self, times, starttime): 356 period = 10 # in ns 357 358 # give a jitter on starttime 359 starttime = np.random.normal(startime, 0.05) 360 361 phase = 0.0 362 signal = 10 * np.sin(times * 2*np.pi/period + starttime + phase) 363 364 # add some noise 365 noise = np.random.normal(0.0, 0.5, signal.shape) 366 signal += noise 367 return signal 368 369 def info(self): 370 """ print run information 371 372 """ 373 374 print 'data file: ', data_file_name 375 print 'calib file: ', calib_file_name 376 print 'calibration file' 377 print 'N baseline_mean: ', self.Nblm 378 print 'N gain mean: ', self.Ngm 379 print 'N TriggeroffsetMean: ', self.Ntom 380 381 # ----------------------------------------------------------------------------- 299 382 class fnames( object ): 300 383 """ organize file names of a FACT data run
Note:
See TracChangeset
for help on using the changeset viewer.