evd3apa.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import h5py
4 import numpy as np
5 from mpl_toolkits.axes_grid1 import make_axes_locatable
6 import matplotlib as mpl
7 import sys
8 import math
9 
10 def main(argv):
11 
12  inputfile = 'r5387_e89634.h5'
13  t0 = 0
14  t1 = 6000
15  w0 = 0
16  w1 = 480*3
17  sc = 50
18  do_save_image = 0
19 
20  args = argv[1:]
21  while len(args) > 0:
22  if args[0] == '-f' and len(args) > 1:
23  inputfile = args[1]
24  del args[0:2]
25  elif args[0] == '-w0' and len(args) > 1:
26  w0 = int(args[1])
27  del args[0:2]
28  elif args[0] == '-w1' and len(args) > 1:
29  w1 = int(args[1])
30  del args[0:2]
31  elif args[0] == '-t0' and len(args) > 1:
32  t0 = int(args[1])
33  del args[0:2]
34  elif args[0] == '-t1' and len(args) > 1:
35  t1 = int(args[1])
36  del args[0:2]
37  elif args[0] == '-sc' and len(args) > 1:
38  sc = int(args[1])
39  del args[0:2]
40  elif args[0] == '-save':
41  do_save_image = 1
42  del args[0]
43  else:
44  print('Unknown option %s' % args[0])
45  return 1
46 
47  f = h5py.File(inputfile, 'r')
48 
49  #fsize = math.log(sc)*5
50  #mpl.rcParams.update({'font.size' : fsize})
51  mpl.rcParams.update({'font.size' : (w1-w0)/sc/1.6})
52 
53  #f = h5py.File("r5779_e12360.h5", 'r')
54  #f = h5py.File("r5770_e59001.h5", 'r')
55  #f = h5py.File("r5826_e83959.h5", 'r')
56  #f = h5py.File("r5759_e58084.h5", 'r')
57  #f = h5py.File("r5244_e10488.h5", 'r')
58  #f = h5py.File("r5809_e10747.h5", 'r')
59 
60  #f = h5py.File("r5439_e13.h5", 'r')
61  #f = h5py.File("r5145_e81569.h5", 'r')
62  #f = h5py.File("r5458_e21389.h5", 'r')
63  #f = h5py.File("r5432_e50486.h5", 'r')
64  #f = h5py.File("r5772_e15132.h5", 'r')
65  #f = h5py.File("r5815_e962.h5", 'r')
66 
67  #f = h5py.File("r5770_e50648.h5", 'r')
68  #f = h5py.File("r5203_e1290.h5", 'r')
69  #f = h5py.File("r5759_e84253.h5", 'r')
70  #f = h5py.File("r5759_e84081.h5", 'r')
71  #f = h5py.File("r5759_e58.h5", 'r')
72  #f = h5py.File("r5759_e77.h5", 'r')
73  #f = h5py.File("r5145_e27422.h5", 'r')
74  #f = h5py.File("r5145_e27543.h5", 'r')
75  #f = h5py.File("r5387_e89634.h5", 'r')
76 
77 
78  n1 = np.array(f["wiresigs/adc"][:])
79  evttime = np.array(f["evtids/evttime"][:])
80  run = np.array(f["evtids/eid"][:])
81  from datetime import datetime
82  timestamp = int(evttime[0])
83  dt_object = datetime.fromtimestamp(timestamp)
84  import matplotlib
85  import matplotlib.pyplot as plt
86  fig, ax = plt.subplots()
87  y = np.reshape(n1, (n1.shape[0]//6000, 6000))
88  z = np.flip(y.transpose(),0)
89  #t0 = 0
90  #t1 = 5999
91  #t0 = 2750
92  #t1 = 4999
93  #t0 = 2000
94  #t1 = 4999
95  #w0 = 0
96  #w1 = 480*3-1
97  #w0 = 0
98  #w1 = 250
99  z1 = z[6000-t1:6000-t0, w0:w1]
100  #mpl.rcParams["image.origin"] = 'lower'
101  #im = ax.imshow(z1, extent=[w0, w1, t0, t1], aspect='auto', vmax=10.0, vmin=-2.5)
102  im = ax.imshow(z1, extent=[w0, w1, t0, t1], aspect='auto', vmax=10.0, vmin=-2.5)
103  im.set_cmap('jet')
104  divider = make_axes_locatable(plt.gca())
105  cax = divider.append_axes("right", "3%", pad="2%")
106  cb = plt.colorbar(im, cax=cax)
107 
108  #cb = fig.colorbar(im, ax=ax, extend='max', extendrect=True, use_gridspec=True)
109  cb.set_label("Charge/tick/channel (ke)")
110  fig.set_size_inches((w1-w0+1)*0.479/sc, (t1-t0+1)*0.5*0.16/sc)
111  #fig.set_size_inches((w1-w0+1)*0.479/30, (t1-t0+1)*0.5*0.16/30)
112  #fig.set_size_inches((w1-w0+1)*0.479/20, (t1-t0+1)*0.5*0.16/20)
113  ax.set_xlabel("Wire number")
114  ax.set_ylabel("Ticks (0.5 $\mu$s)")
115  ax.set_title("ProtoDUNE-SP Run {} Event {} @{} UTC".format(run[0][0], run[0][2], dt_object))
116  #plt.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
117  plt.tight_layout()
118  if do_save_image:
119  plt.savefig("R{}_E{}_T1T5T9_w{}_{}_t{}_{}_sc{}.png".format(run[0][0],run[0][2],w0,w1,t0,t1,sc))
120  plt.savefig("R{}_E{}_T1T5T9_w{}_{}_t{}_{}_sc{}.pdf".format(run[0][0],run[0][2],w0,w1,t0,t1,sc))
121  plt.show()
122 
123 if __name__ == '__main__':
124  sys.exit(main(sys.argv))
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
def main(argv)
Definition: evd3apa.py:10