Changeset 13447
- Timestamp:
- 04/25/12 14:48:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/sandbox/dneise/gain/gain.py
r13444 r13447 1 #!/usr/bin/python -tt i1 #!/usr/bin/python -tt 2 2 # 3 3 # 4 4 5 5 from pyfact import RawData 6 from drs_spikes import DRSSpikes 6 from drs_spikes import DRSSpikes 7 7 from fir_filter import CFD 8 8 from fir_filter import SlidingAverage 9 9 10 from plotters import Plotter11 12 10 import sys 13 import cPickle14 import matplotlib.pyplot as plt15 11 import numpy as np 16 12 17 data_filename = 'data/20111017_0 09.fits.gz'13 data_filename = 'data/20111017_010.fits.gz' 18 14 calib_filename = 'data/20111017_006.drs.fits.gz' 19 out_filename = 'test.pkl'20 15 21 16 run = RawData(data_filename, calib_filename, return_dict = True, do_calibration=True) … … 30 25 sws = search_window_size 31 26 32 plt.ion()33 fig = plt.figure()34 fig.hold(True)27 #plt.ion() 28 #fig = plt.figure() 29 #fig.hold(True) 35 30 36 31 # we try to determine the: … … 47 42 48 43 PEAKS_MAX = 10 49 N_INFO = 3 # Position, Height of unfiltered peak, Height of Filtered peak 44 50 45 51 46 # TODO: this operation might under certain circumstances need way to much mem. … … 55 50 # The user will then find a certain nuber of ndarray in the output npz file. 56 51 # But this should not be a major problem. 57 peaks = np.ones( ( N_INFO, run.nevents, run.npix, PEAKS_MAX), dtype=np.float32) 58 52 result_peak_positions = np.ones( (run.nevents, run.npix, PEAKS_MAX), dtype=np.int16) * -1 53 result_peak_unfiltered_height = np.ones( (run.nevents, run.npix, PEAKS_MAX), dtype=np.float32) * -np.inf 54 result_peak_smoothed_height = np.ones( (run.nevents, run.npix, PEAKS_MAX), dtype=np.float32) * -np.inf 59 55 60 56 61 57 for event in run: 62 58 event_id = event['event_id'].value - 1 63 print 'event_id', event_id59 64 60 65 61 data = event['acal_data'] … … 77 73 for dat, fil, orig in zip(data, filtered, data_orig): 78 74 pixel_id += 1 79 print 'pixel id:', pixel_id80 plt.cla()75 print event_id, pixel_id 76 # plt.cla() 81 77 prod = fil[:-1] * fil[1:] 82 78 cand = np.where( prod <= 0)[0] … … 119 115 max_smoothed[i] = dat[max_pos[i]] 120 116 max_orig[i] = orig[max_pos[i]-filter_delay] 117 118 result_peak_positions[event_id,pixel_id, :len(max_pos)] = max_pos 119 result_peak_unfiltered_height[event_id,pixel_id, :len(max_pos)] =max_orig 120 result_peak_smoothed_height[event_id,pixel_id, :len(max_pos)] = max_smoothed 121 121 122 plt.plot(max_pos, max_smoothed, 'ro')123 plt.plot(max_pos, max_orig, 'bo')124 plt.plot(np.arange(len(dat)), dat, 'k:')122 # plt.plot(max_pos, max_smoothed, 'ro') 123 # plt.plot(max_pos, max_orig, 'bo') 124 # plt.plot(np.arange(len(dat)), dat, 'k:') 125 125 126 ret = raw_input('pixel-loop?') 127 if ret == 'q': 128 break 129 ret = raw_input('event-loop?') 130 if ret == 'q': 131 break 132 126 # ret = raw_input('pixel-loop?') 127 # if ret == 'q': 128 # break 129 # ret = raw_input('event-loop?') 130 # if ret == 'q': 131 # break 133 132 133 np.savez('20111017_010-006.npz', 134 result_peak_positions = result_peak_positions, 135 result_peak_unfiltered_height = result_peak_unfiltered_height, 136 result_peak_smoothed_height = result_peak_smoothed_height ) 134 137 135 138 #output = open(out_filename, 'wb')
Note:
See TracChangeset
for help on using the changeset viewer.