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

Last change on this file since 13450 was 13446, checked in by neise, 13 years ago
plots each pixels darkcount pulse height histogram
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/usr/bin/python -tti
2#
3#
4
5import sys
6import numpy as np
7import matplotlib.pyplot as plt
8
9if len(sys.argv) > 1:
10 npz_file = np.load(sys.argv[1])
11else:
12 print 'I need a filename'
13 sys.exit(0)
14
15print npz_file.files
16
17# sanitiy check for gain npz files
18#
19expected_filenames = [
20 'result_peak_positions',
21 'result_peak_unfiltered_height',
22 'result_peak_smoothed_height']
23
24abort = False
25for fn in expected_filenames:
26 if not fn in npz_file.files:
27 print 'coulnd not find', fn, 'in ', sys.argv[1]
28 print 'This is probably no gain-npz-file ...'
29 print 'Aborting...'
30 abort = True
31if abort:
32 print npz_file.files
33 sys.exit(1)
34
35data = npz_file['result_peak_smoothed_height']
36data = np.nan_to_num(data)
37
38plt.ion()
39fig = plt.figure()
40
41for i in range(data.shape[1]): # this is a loop over a pixel
42 plt.cla()
43 plt.grid(True)
44 plt.title('Pixel ' + str(i))
45 plt.xlabel('darc count amplitude mV')
46 plt.ylabel('rate')
47 contents,bins,patches = plt.hist(data[:,i,:].flatten(), range=(0,100), bins=200, align='left', histtype='step')
48 #break
49 raw_input('')
Note: See TracBrowser for help on using the repository browser.