1 | #!/usr/bin/python -tti
|
---|
2 | #
|
---|
3 | #
|
---|
4 |
|
---|
5 | from pyfact import RawData
|
---|
6 | from drs_spikes import DRSSpikes
|
---|
7 | from fir_filter import CFD
|
---|
8 | from extractor import ZeroXing
|
---|
9 | from fir_filter import SlidingAverage
|
---|
10 |
|
---|
11 | from plotters import Plotter
|
---|
12 |
|
---|
13 | import sys
|
---|
14 | import cPickle
|
---|
15 | import matplotlib.pyplot as plt
|
---|
16 | import numpy as np
|
---|
17 |
|
---|
18 | data_filename = 'data/20111017_010.fits.gz'
|
---|
19 | calib_filename = 'data/20111017_007.drs.fits.gz'
|
---|
20 | out_filename = 'test.pkl'
|
---|
21 |
|
---|
22 | run = RawData(data_filename, calib_filename, return_dict = True, do_calibration=True)
|
---|
23 | despike = DRSSpikes()
|
---|
24 | smooth = SlidingAverage(8)
|
---|
25 | cfd = CFD()
|
---|
26 | find = ZeroXing()
|
---|
27 |
|
---|
28 | #plt.ion()
|
---|
29 |
|
---|
30 | peak_list = []
|
---|
31 |
|
---|
32 | p = Plotter('data[0]')
|
---|
33 |
|
---|
34 |
|
---|
35 | #fig = plt.figure()
|
---|
36 | #plt.grid(True)
|
---|
37 |
|
---|
38 | stupid_list = []
|
---|
39 |
|
---|
40 | for event in run:
|
---|
41 | print event['event_id'].value
|
---|
42 | data = event['acal_data']
|
---|
43 | data = despike(data)
|
---|
44 | data = smooth(data)
|
---|
45 | filtered = cfd(data)
|
---|
46 | filtered = smooth(filtered)
|
---|
47 | peak_positions = find(data)
|
---|
48 |
|
---|
49 | # find peak heights
|
---|
50 | # and get rid of too small peaks
|
---|
51 | # good_peaks = []
|
---|
52 | # for idx,pixel in enumerate(peak_positions):
|
---|
53 | # good_peaks.append([])
|
---|
54 | # for peak_pos in pixel:
|
---|
55 | # peak_height = data[idx][int(peak_pos)]
|
---|
56 | # stupid_list.append(peak_height)
|
---|
57 | # if peak_height > 4.0:
|
---|
58 | # good_peaks[-1].append((peak_pos,peak_height))
|
---|
59 | #
|
---|
60 | # plt.hist(np.array(stupid_list))
|
---|
61 |
|
---|
62 | p((data[0],filtered[0]))
|
---|
63 | print 'peak_positions:', map(int, peak_positions[0])
|
---|
64 |
|
---|
65 | peak_pussies = map(int, peak_positions[0])
|
---|
66 | peak_h = []
|
---|
67 | for i in peak_pussies:
|
---|
68 | peak_h.append(data[0][i-8])
|
---|
69 |
|
---|
70 |
|
---|
71 | pp = Plotter('peaks', x=peak_pussies)
|
---|
72 | pp(peak_h)
|
---|
73 |
|
---|
74 |
|
---|
75 | ret = raw_input('quit?')
|
---|
76 | if ret=='q':
|
---|
77 | break
|
---|
78 |
|
---|
79 | # peak_list.append( good_peaks )
|
---|
80 |
|
---|
81 |
|
---|
82 | #output = open(out_filename, 'wb')
|
---|
83 | #cPickle.dump(data_filename, output, -1)
|
---|
84 | #cPickle.dump(calib_filename, output, -1)
|
---|
85 | #cPickle.dump(peak_list, output, -1)
|
---|