source: branches/trigger_burst_research/plot_more_stuff.py@ 18306

Last change on this file since 18306 was 18306, checked in by dneise, 9 years ago
initial commit of script, which plots some more plots
File size: 4.2 KB
Line 
1# coding: utf-8
2from pylab import *
3import pandas as pd
4import matplotlib.dates as mdates
5from matplotlib.colors import LogNorm
6
7r = pd.DataFrame.from_csv('burst_ratio.csv',
8 infer_datetime_format=True,
9 parse_dates=['fRunStart', 'fRunStop'])
10r = r.dropna()
11
12t = r.fRunStart.values.astype('float64')/1e9
13x = r.fBoardTriggerRateRatioAboveThreshold
14tt = mdates.epoch2num(t)
15
16plt.ion()
17fig, axes = plt.subplots(3,1, sharex=True)
18fig.subplots_adjust(hspace=0.)
19for ax in axes:
20 ax.xaxis.set_major_locator(mdates.MonthLocator())
21 ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
22 ax.xaxis.set_minor_locator( mdates.DayLocator())
23
24plot0 = axes[0].hist2d(tt, x.values,
25 cmap='Greys',
26 bins=(np.arange(int(tt[0])-2, int(tt[-1])+2),
27 np.arange(0, 0.6+1/60., 1./60.)),
28 norm=LogNorm())
29#plt.colorbar(plot0[-1])
30axes[0].set_ylabel("Ratio")
31
32plot1 = axes[1].hist2d(tt, r.fZenithDistanceMean.values,
33 cmap='Greys',
34 bins=(np.arange(int(tt[0])-2, int(tt[-1])+2),
35 np.arange(0, 95, 1.)),
36 norm=LogNorm())
37#plt.colorbar(plot1[-1])
38axes[1].set_ylabel("Zenith [deg]")
39plot2 = axes[2].hist2d(tt, r.fAzimuthMean.values,
40 cmap='Greys',
41 bins=(np.arange(int(tt[0])-2, int(tt[-1])+2),
42 np.arange(-270, 90 , 4)),
43 norm=LogNorm())
44#plt.colorbar(plot2[-1])
45axes[2].set_ylabel("Azimut [deg]")
46#ax.xaxis.set_major_formatter(mdates.AutoDateFormatter(mdates.AutoDateLocator()))
47#ax.xaxis.set_major_locator(mdates.AutoDateLocator())
48
49#ax.format_xdata = mdates.DateFormatter('%Y-%m-%d %H:%M')
50fig.autofmt_xdate()
51plt.grid()
52
53plt.xlabel("Time")
54#plt.tight_layout()
55plt.draw()
56
57"""
58H, b = np.histogram(
59 r.fZenithDistanceMean.values,
60 bins = np.arange(0, 180))
61
62H2, bx, by = np.histogram2d(
63 r.fZenithDistanceMean.values,
64 x.values,
65 bins=(np.arange(0, 180), np.arange(0, 0.6, 1/60.)),
66 )
67
68plt.figure()
69plt.title("normiert")
70plt.imshow(
71 (H2.T/H).T,
72 origin='upper',
73 #extent=[bx[0],bx[-1],by[0],by[-1]],
74 #aspect=180,
75 cmap='Greys',
76 )
77
78"""
79H, b = np.histogram(
80 r.fZenithDistanceMean.values,
81 bins = np.arange(0, 180))
82
83zenit_bin_index = np.digitize(r.fZenithDistanceMean.values, np.arange(0, 180))-1
84w = 1./H[zenit_bin_index]
85
86plt.figure()
87plt.hist2d(
88 r.fZenithDistanceMean.values,
89 x.values,
90 weights=w,
91 #cmap='Greys',
92 bins = (np.arange(0, 180), np.arange(0, 0.6, 1./60.)),
93 norm=LogNorm(),
94 )
95plt.xlabel("fZenithDistanceMean")
96plt.xlim(0, 90)
97plt.ylabel("fBoardTriggerRateRatioAboveThreshold")
98plt.title("fZenithDistanceMean Dependence of Ratio")
99plt.colorbar()
100plt.grid()
101
102H, b = np.histogram(
103 r.fAzimuthMean.values,
104 bins = np.arange(-360, 360))
105
106az_bin_index = np.digitize(r.fAzimuthMean.values, np.arange(-360, 360))-1
107w = 1./H[az_bin_index]
108
109plt.figure()
110plt.hist2d(
111 r.fAzimuthMean.values,
112 x.values,
113 weights=w,
114 #cmap='Greys',
115 bins = (np.arange(-360, 360), np.arange(0, 0.6, 1./60.)),
116 norm=LogNorm()
117 )
118plt.xlabel("fAzimuthMean")
119plt.ylabel("fBoardTriggerRateRatioAboveThreshold")
120plt.title("Azimuth Dependence of Ratio")
121plt.colorbar()
122plt.grid()
123
124nbins = (
125 np.arange(-2*np.pi, 2*np.pi, np.pi/180*5),
126 np.arange(0, 90)
127 )
128
129H1, bx, by = np.histogram2d(
130 x=r.fAzimuthMean.values*np.pi/180.,
131 y=r.fZenithDistanceMean.values,
132 weights=x.values,
133 bins=nbins)
134
135H2, bx, by = np.histogram2d(
136 x=r.fAzimuthMean.values*np.pi/180.,
137 y=r.fZenithDistanceMean.values,
138 bins=nbins)
139
140normed_H1 = H1/H2
141
142above_thr = normed_H1 > 0.05
143
144runs_above_thr = H2.copy()
145runs_above_thr[~above_thr]=0
146
147plt.figure()
148plt.title("Ratio vs. zenith and azimut (normalized for #runs)")
149im = plt.imshow(normed_H1.T,
150 origin='low',
151 interpolation='none',
152 extent=[bx[0], bx[-1], by[0], by[-1]],
153 aspect='auto',
154 norm=LogNorm())
155#im.set_cmap('Greys')
156cbar = plt.colorbar()
157plt.grid()
158plt.xlim(-1.5*np.pi, np.pi/2.)
159plt.xlabel("Azimut [rad]")
160plt.ylabel("Zenith [deg]")
161
162
163
164plt.figure()
165plt.title("Above 5% Ratio")
166im = plt.imshow(above_thr.T,
167 origin='low',
168 interpolation='none',
169 extent=[bx[0], bx[-1], by[0], by[-1]],
170 aspect='auto',
171 norm=LogNorm())
172#im.set_cmap('Greys')
173plt.colorbar()
174plt.grid()
175plt.xlim(-1.5*np.pi, np.pi/2.)
176
177plt.figure()
178plt.title("# runs above thr")
179im = plt.imshow(runs_above_thr.T,
180 origin='low',
181 interpolation='none',
182 extent=[bx[0], bx[-1], by[0], by[-1]],
183 aspect='auto')
184#im.set_cmap('Greys')
185plt.colorbar()
186plt.grid()
187plt.xlim(-1.5*np.pi, np.pi/2.)
188
Note: See TracBrowser for help on using the repository browser.