1 | #!/usr/bin/python -tti
|
---|
2 |
|
---|
3 | # script, which saves a lot of information about
|
---|
4 | # DRS spikes in a file, for further analysis.
|
---|
5 | from pyfact import RawData
|
---|
6 | from drs_spikes import DRSSpikes
|
---|
7 | import numpy as np
|
---|
8 | from plotters import Plotter
|
---|
9 | import scipy.signal as signal
|
---|
10 | # I need a callback function for the call of DRSSpikes
|
---|
11 | # this function should be a member of RawData,
|
---|
12 | # so that it knows all necessary information
|
---|
13 | # In order to do this, I should inherit from RawData
|
---|
14 | # and just add one single function.
|
---|
15 | data_file_name = '/home/dominik/20120223_205.fits.gz'
|
---|
16 | calib_file_name = '/home/dominik/20120223_202.drs.fits.gz'
|
---|
17 | outfile = None
|
---|
18 |
|
---|
19 | run = RawData( data_file_name, calib_file_name, return_dict=True)
|
---|
20 | despike = DRSSpikes()
|
---|
21 |
|
---|
22 | single_pattern = np.array( (-1,2,-1) )
|
---|
23 | double_pattern = np.array( (-1,1,1,-1) )
|
---|
24 |
|
---|
25 | bins = None
|
---|
26 |
|
---|
27 | histplot = Plotter('hist')
|
---|
28 | cplot = Plotter('corr')
|
---|
29 | for event in run:
|
---|
30 | print event['event_id']
|
---|
31 | data = event['acal_data'][:,12:-12]
|
---|
32 |
|
---|
33 | for pixel,sig in enumerate(data):
|
---|
34 | corr = signal.correlate( sig, single_pattern, 'same')
|
---|
35 | #cplot.name = corr+'_'+str(event['event_id']+'_'+str(pixel)
|
---|
36 | cplot(corr)
|
---|
37 | hist = np.histogram( corr, bins=1000, range=(0,2000) )
|
---|
38 | if bins == None:
|
---|
39 | bins = hist[0]
|
---|
40 | else:
|
---|
41 | bins += hist[0]
|
---|
42 |
|
---|
43 | histplot(bins)
|
---|