source: fact/tools/pyscripts/sandbox/dneise/gain/gain.py@ 13421

Last change on this file since 13421 was 13421, checked in by neise, 12 years ago
init
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/usr/bin/python -tti
2#
3#
4
5from pyfact import RawData
6from drs_spikes import DRSSpikes
7from fir_filter import CFD
8from extractor import ZeroXing
9from fir_filter import SlidingAverage
10
11from plotters import Plotter
12
13import sys
14import cPickle
15import matplotlib.pyplot as plt
16import numpy as np
17
18data_filename = 'data/20111017_010.fits.gz'
19calib_filename = 'data/20111017_007.drs.fits.gz'
20out_filename = 'test.pkl'
21
22run = RawData(data_filename, calib_filename, return_dict = True, do_calibration=True)
23despike = DRSSpikes()
24smooth = SlidingAverage(8)
25cfd = CFD()
26find = ZeroXing()
27
28#plt.ion()
29
30peak_list = []
31
32p = Plotter('data[0]')
33
34
35#fig = plt.figure()
36#plt.grid(True)
37
38stupid_list = []
39
40for 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)
Note: See TracBrowser for help on using the repository browser.