| 1 | # coding: utf-8
|
|---|
| 2 | from pylab import *
|
|---|
| 3 | import pandas as pd
|
|---|
| 4 | import matplotlib.dates as mdates
|
|---|
| 5 | from matplotlib.colors import LogNorm
|
|---|
| 6 |
|
|---|
| 7 | r = pd.DataFrame.from_csv('burst_ratio.csv',
|
|---|
| 8 | infer_datetime_format=True,
|
|---|
| 9 | parse_dates=['fRunStart', 'fRunStop'])
|
|---|
| 10 | r = r.dropna()
|
|---|
| 11 |
|
|---|
| 12 | t = r.fRunStart.values.astype('float64')/1e9
|
|---|
| 13 | x = r.fBoardTriggerRateRatioAboveThreshold
|
|---|
| 14 | tt = mdates.epoch2num(t)
|
|---|
| 15 |
|
|---|
| 16 | plt.ion()
|
|---|
| 17 | fig, axes = plt.subplots(3,1, sharex=True)
|
|---|
| 18 | fig.subplots_adjust(hspace=0.)
|
|---|
| 19 | for 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 |
|
|---|
| 24 | plot0 = 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])
|
|---|
| 30 | axes[0].set_ylabel("Ratio")
|
|---|
| 31 |
|
|---|
| 32 | plot1 = 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])
|
|---|
| 38 | axes[1].set_ylabel("Zenith [deg]")
|
|---|
| 39 | plot2 = 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])
|
|---|
| 45 | axes[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')
|
|---|
| 50 | fig.autofmt_xdate()
|
|---|
| 51 | plt.grid()
|
|---|
| 52 |
|
|---|
| 53 | plt.xlabel("Time")
|
|---|
| 54 | #plt.tight_layout()
|
|---|
| 55 | plt.draw()
|
|---|
| 56 |
|
|---|
| 57 | """
|
|---|
| 58 | H, b = np.histogram(
|
|---|
| 59 | r.fZenithDistanceMean.values,
|
|---|
| 60 | bins = np.arange(0, 180))
|
|---|
| 61 |
|
|---|
| 62 | H2, 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 |
|
|---|
| 68 | plt.figure()
|
|---|
| 69 | plt.title("normiert")
|
|---|
| 70 | plt.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 | """
|
|---|
| 79 | H, b = np.histogram(
|
|---|
| 80 | r.fZenithDistanceMean.values,
|
|---|
| 81 | bins = np.arange(0, 180))
|
|---|
| 82 |
|
|---|
| 83 | zenit_bin_index = np.digitize(r.fZenithDistanceMean.values, np.arange(0, 180))-1
|
|---|
| 84 | w = 1./H[zenit_bin_index]
|
|---|
| 85 |
|
|---|
| 86 | plt.figure()
|
|---|
| 87 | plt.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 | )
|
|---|
| 95 | plt.xlabel("fZenithDistanceMean")
|
|---|
| 96 | plt.xlim(0, 90)
|
|---|
| 97 | plt.ylabel("fBoardTriggerRateRatioAboveThreshold")
|
|---|
| 98 | plt.title("fZenithDistanceMean Dependence of Ratio")
|
|---|
| 99 | plt.colorbar()
|
|---|
| 100 | plt.grid()
|
|---|
| 101 |
|
|---|
| 102 | H, b = np.histogram(
|
|---|
| 103 | r.fAzimuthMean.values,
|
|---|
| 104 | bins = np.arange(-360, 360))
|
|---|
| 105 |
|
|---|
| 106 | az_bin_index = np.digitize(r.fAzimuthMean.values, np.arange(-360, 360))-1
|
|---|
| 107 | w = 1./H[az_bin_index]
|
|---|
| 108 |
|
|---|
| 109 | plt.figure()
|
|---|
| 110 | plt.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 | )
|
|---|
| 118 | plt.xlabel("fAzimuthMean")
|
|---|
| 119 | plt.ylabel("fBoardTriggerRateRatioAboveThreshold")
|
|---|
| 120 | plt.title("Azimuth Dependence of Ratio")
|
|---|
| 121 | plt.colorbar()
|
|---|
| 122 | plt.grid()
|
|---|
| 123 |
|
|---|
| 124 | nbins = (
|
|---|
| 125 | np.arange(-2*np.pi, 2*np.pi, np.pi/180*5),
|
|---|
| 126 | np.arange(0, 90)
|
|---|
| 127 | )
|
|---|
| 128 |
|
|---|
| 129 | H1, 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 |
|
|---|
| 135 | H2, bx, by = np.histogram2d(
|
|---|
| 136 | x=r.fAzimuthMean.values*np.pi/180.,
|
|---|
| 137 | y=r.fZenithDistanceMean.values,
|
|---|
| 138 | bins=nbins)
|
|---|
| 139 |
|
|---|
| 140 | normed_H1 = H1/H2
|
|---|
| 141 |
|
|---|
| 142 | above_thr = normed_H1 > 0.05
|
|---|
| 143 |
|
|---|
| 144 | runs_above_thr = H2.copy()
|
|---|
| 145 | runs_above_thr[~above_thr]=0
|
|---|
| 146 |
|
|---|
| 147 | plt.figure()
|
|---|
| 148 | plt.title("Ratio vs. zenith and azimut (normalized for #runs)")
|
|---|
| 149 | im = 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')
|
|---|
| 156 | cbar = plt.colorbar()
|
|---|
| 157 | plt.grid()
|
|---|
| 158 | plt.xlim(-1.5*np.pi, np.pi/2.)
|
|---|
| 159 | plt.xlabel("Azimut [rad]")
|
|---|
| 160 | plt.ylabel("Zenith [deg]")
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 | plt.figure()
|
|---|
| 165 | plt.title("Above 5% Ratio")
|
|---|
| 166 | im = 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')
|
|---|
| 173 | plt.colorbar()
|
|---|
| 174 | plt.grid()
|
|---|
| 175 | plt.xlim(-1.5*np.pi, np.pi/2.)
|
|---|
| 176 |
|
|---|
| 177 | plt.figure()
|
|---|
| 178 | plt.title("# runs above thr")
|
|---|
| 179 | im = 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')
|
|---|
| 185 | plt.colorbar()
|
|---|
| 186 | plt.grid()
|
|---|
| 187 | plt.xlim(-1.5*np.pi, np.pi/2.)
|
|---|
| 188 |
|
|---|