#!/usr/bin/python -tt # # Werner Lustermann # ETH Zurich # import numpy as np from pyfact import RawData from plotter import Plotter from drs_spikes import DRSSpikes import matplotlib.pyplot as plt ch = 0 def drs_calib(acal_data, raw_data, blm, tom, gm, scells, nroi): """ call back function for RawData class """ blm_pixel = np.roll( blm[ch,:], -scells[ch] ) tom_pixel = np.roll( tom[ch,:], -scells[ch] ) gm_pixel = np.roll( gm[ch,:], -scells[ch] ) print 'nroi: ', nroi print 'start: ', scells[ch] print 'blm: ', blm[ch,0:20] print 'blm: ', blm_pixel[0:20] print 'tom: ', tom_pixel[0:20] print 'gm: ', gm_pixel[0:10] print 'raw_data:', raw_data[ch,0:20] raw_data_mV = raw_data[ch,0:20] * 2000./4096. print 'raw_data mV:', raw_data_mV raw_data_blm = raw_data_mV - blm_pixel[0:20] - tom_pixel[0:20] print 'raw_data mV - blm:', raw_data_blm raw_data_gm = raw_data_blm / gm_pixel[0:20] print 'raw_data_gm:', raw_data_gm * 1907.35 print 'acal_data: ', acal_data[ch,0:20] raw_data_plot(raw_data[ch,:]) acal_data_plot(acal_data[ch,:]) path = '/home/luster/win7/FACT/data/raw/20120114/' data_file_name = path + '20120114_024.fits.gz' calib_file_name = path + '20120114_022.drs.fits.gz' path = '/home/luster/win7/FACT/data/raw/20111124/' data_file_name = path + '20111124_117.fits.gz' calib_file_name = path + '20111124_114.drs.fits.gz' run = RawData( data_file_name, calib_file_name , user_action_calib = drs_calib) x = np.linspace(0., run.nroi, run.nroi) raw_data_plot = Plotter('raw_data', x, 'g.', xlabel='slice in logical pipeline', ylabel='amplitude in mV') acal_data_plot = Plotter('cal_data', x, 'r.', xlabel='slice in logical pipeline', ylabel='amplitude in mV') plt.ion() # turn interactive mode on (plots are done immediately) ch = 0 inp = '' data, scell, tt = run.next() #print data[ch,0:10] while ( inp != 'q' ): inp = raw_input('[n|p|q]: ') if inp == 'n': ch = (ch + 1)%1440 elif inp == 'p': ch = (ch + 1)%1440 print ch elif inp == 'q': pass else: data, scell, tt = run.next()