def plot_station_offset_matrix(): n = len(STATIONS) stations = { station: Station(station, force_stale=True) for station in STATIONS } for type in ['offset', 'error']: plot = MultiPlot(n, n, width=r'.08\textwidth', height=r'.08\textwidth') for i, station in enumerate(STATIONS): for j, ref_station in enumerate(STATIONS): splot = plot.get_subplot_at(i, j) if i == n: splot.show_xticklabels() if station == ref_station: splot.set_empty() splot.set_label(r'%d' % station, location='center') continue offsets = stations[station].station_timing_offsets(ref_station) bins = list(offsets['timestamp']) bins += [bins[-1] + 86400] splot.histogram(offsets[type], bins, linestyle='very thin') splot.set_axis_options('line join=round') plot_cuts_vertically(splot, stations, station, ref_station) # Even/row rows/columns for row in range(0, n, 2): plot.set_yticklabels_position(row, n - 1, 'right') plot.set_xticklabels_position(n - 1, row, 'bottom') plot.show_yticklabels(row, n - 1) #plot.show_xticklabels(n - 1, row) for row in range(1, n, 2): plot.set_yticklabels_position(row, 0, 'left') plot.set_xticklabels_position(0, row, 'top') plot.show_yticklabels(row, 0) #plot.show_xticklabels(0, row) if type == 'offset': plot.set_ylimits_for_all(None, min=-70, max=70) else: plot.set_ylimits_for_all(None, min=0, max=10) plot.set_xlimits_for_all(None, min=datetime_to_gps(date(2011, 1, 1)), max=datetime_to_gps(date.today())) plot.set_xticks_for_all(None, YEARS_TICKS) # plot.set_xtick_labels_for_all(YEARS_LABELS) plot.set_xlabel(r'Date') plot.set_ylabel(r'Station offset [\si{\ns}]') plot.save_as_pdf('station_offsets_%s' % type)
def plot_afstelling_pmt(): """Plot voor afstellen spanning""" multiplot = MultiPlot(1, 3, width=r'0.4\linewidth') x = pylab.linspace(1e-10, 11, 200) signal = pylab.zeros(x.shape) for N in range(1, 15): scale = 100. / N ** 3 pdf = 80 * scale * pylab.normpdf(x, N, pylab.sqrt(N) * 0.35) signal += pdf gammas = 1e2 * x ** -3 signal += gammas p = multiplot.get_subplot_at(0, 0) v = x * 35 p.plot(v, pylab.where(v >= 30, signal, 1), mark=None) p.draw_vertical_line(200, linestyle='gray') p.set_label(r"$V_\mathrm{PMT}$ te laag") p = multiplot.get_subplot_at(0, 1) v = x * 200 p.plot(v, pylab.where(v >= 30, signal, 1), mark=None) p.draw_vertical_line(200, linestyle='gray') p.set_label(r"$V_\mathrm{PMT}$ correct") p = multiplot.get_subplot_at(0, 2) v = x * 400 p.plot(v, pylab.where(v >= 30, signal, 1), mark=None) p.draw_vertical_line(200, linestyle='gray') p.set_label(r"$V_\mathrm{PMT}$ te hoog") multiplot.set_xlabel(r"Pulseheight [\si{\milli\volt}]") multiplot.set_ylabel("Counts") multiplot.set_xlimits_for_all(min=0, max=1000) multiplot.set_ylimits_for_all(min=1) multiplot.show_xticklabels_for_all() multiplot.set_xticklabels_position(0, 1, 'top') multiplot.set_yticks_for_all(ticks=None) multiplot.save('afstelling_pmt')
def multiplot(): # data series x = [0, 40, 60, 69, 80, 90, 100] y = [0, 0, 0.5, 2.96, 2, 1, .5] multiplot = MultiPlot(1, 2) # make graph graph1 = multiplot.get_subplot_at(0, 0) graph2 = multiplot.get_subplot_at(0, 1) # make Plot graph1.plot(x, y, mark=None, linestyle='smooth,very thick') graph2.plot(x, y, mark=None, linestyle='smooth,very thick') multiplot.show_xticklabels_for_all() multiplot.show_yticklabels(0, 0) multiplot.set_xticklabels_position(0, 1, 'top') multiplot.set_yticks_for_all(ticks=range(6)) graph1.set_xlimits(0, 100) graph2.set_xlimits(60, 80) multiplot.set_ylimits_for_all(min=0, max=5) # set scale: 1cm equals 10 or 5 units along the x-axis graph1.set_xscale(cm=10) graph2.set_xscale(cm=5) # set scale: 1cm equals 1 unit along the y-axis graph1.set_yscale(cm=1) graph2.set_yscale(cm=1) # set graph paper graph1.use_graph_paper() graph2.use_graph_paper() # set labels multiplot.set_xlabel(r"$f [\si{\mega\hertz}]$") multiplot.set_ylabel("signal strength") # save graph to file multiplot.save('mm_paper_multiplot')
# Plot voor afstellen spanning multiplot = MultiPlot(1, 3, width=r'.4\linewidth') p = multiplot.get_subplot_at(0, 1) V = x * 200 p.plot(V, where(V >= 30, signal, 1), mark=None) p.draw_vertical_line(200, linestyle='gray') p.set_label(r"$V_\mathrm{PMT}$ correct") p = multiplot.get_subplot_at(0, 2) V = x * 400 p.plot(V, where(V >= 30, signal, 1), mark=None) p.draw_vertical_line(200, linestyle='gray') p.set_label(r"$V_\mathrm{PMT}$ te hoog") p = multiplot.get_subplot_at(0, 0) V = x * 35 p.plot(V, where(V >= 30, signal, 1), mark=None) p.draw_vertical_line(200, linestyle='gray') p.set_label(r"$V_\mathrm{PMT}$ te laag") multiplot.set_xlabel(r"Pulseheight [\si{\milli\volt}]") multiplot.set_ylabel("Counts") multiplot.set_xlimits_for_all(min=0, max=1000) multiplot.set_ylimits_for_all(min=1) multiplot.show_xticklabels_for_all() multiplot.set_xticklabels_position(0, 1, 'top') multiplot.set_yticks_for_all(ticks=None) multiplot.save('afstelling_pmt')
def boxplot_arrival_times(table, N): THETA = deg2rad(0) DTHETA = deg2rad(10.) LOGENERGY = 15 DLOGENERGY = .5 bin_edges = linspace(0, 80, 5) x = [] t25, t50, t75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): query = '(min_n134 >= N) & (low <= r) & (r < high) & (abs(reference_theta - THETA) <= DTHETA) & (abs(log10(k_energy) - LOGENERGY) <= DLOGENERGY)' sel = table.read_where(query) t2 = sel[:]['t2'] t1 = sel[:]['t1'] ct1 = t1.compress((t1 > -999) & (t2 > -999)) ct2 = t2.compress((t1 > -999) & (t2 > -999)) print(len(t1), len(t2), len(ct1), len(ct2)) t25.append(scoreatpercentile(abs(ct2 - ct1), 25)) t50.append(scoreatpercentile(abs(ct2 - ct1), 50)) t75.append(scoreatpercentile(abs(ct2 - ct1), 75)) x.append((low + high) / 2) sx, st25, st50, st75 = loadtxt(os.path.join(DATADIR, 'DIR-boxplot_arrival_times-1.txt')) fig = figure() ax1 = subplot(131) fill_between(sx, st25, st75, color='0.75') plot(sx, st50, 'o-', color='black', markerfacecolor='none') ax2 = subplot(132, sharex=ax1, sharey=ax1) fill_between(x, t25, t75, color='0.75') plot(x, t50, 'o-', color='black') ax3 = subplot(133, sharex=ax1, sharey=ax1) plot(sx, st50, 'o-', color='black', markerfacecolor='none') plot(x, t50, 'o-', color='black') ax2.xaxis.set_label_text("Core distance [m]") ax1.yaxis.set_label_text("Arrival time difference $|t_2 - t_1|$ [ns]") fig.suptitle(r"$N_{MIP} \geq %d, \quad \theta = 0^\circ \pm %d^\circ, \quad %.1f \leq \log(E) \leq %.1f$" % (N, rad2deg(DTHETA), LOGENERGY - DLOGENERGY, LOGENERGY + DLOGENERGY)) ylim(ymax=15) xlim(xmax=80) locator_params(tight=True, nbins=4) fig.subplots_adjust(left=.1, right=.95) fig.set_size_inches(5, 2.67) utils.saveplot(N) sx = sx.compress(sx < 80) st25 = st25[:len(sx)] st50 = st50[:len(sx)] st75 = st75[:len(sx)] graph = MultiPlot(1, 3, width=r'.3\linewidth', height=r'.4\linewidth') graph.shade_region(0, 0, sx, st25, st75) graph.plot(0, 0, sx, st50, linestyle=None) graph.plot(0, 2, sx, st50) graph.set_label(0, 0, 'simulation', 'upper left') graph.shade_region(0, 1, x, t25, t75) graph.plot(0, 1, x, t50, linestyle=None, mark='*') graph.plot(0, 2, x, t50, mark='*') graph.set_label(0, 1, 'experiment', 'upper left') graph.set_label(0, 2, 'sim + exp', 'upper left') graph.set_ylimits(0, 15) graph.set_xlimits(0, 80) graph.set_xlabel("Core distance [\si{\meter}]") graph.set_ylabel(r"Arrival time difference $|t_2 - t_1|$ [\si{\nano\second}]") graph.show_xticklabels_for_all([(0, 0), (0, 1), (0, 2)]) graph.set_xticklabels_position(0, 1, 'right') graph.show_yticklabels(0, 0) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_arrival_times(table, N): THETA = deg2rad(0) DTHETA = deg2rad(10.) LOGENERGY = 15 DLOGENERGY = .5 bin_edges = linspace(0, 80, 5) x = [] t25, t50, t75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): query = '(min_n134 >= N) & (low <= r) & (r < high) & (abs(reference_theta - THETA) <= DTHETA) & (abs(log10(k_energy) - LOGENERGY) <= DLOGENERGY)' sel = table.readWhere(query) t2 = sel[:]['t2'] t1 = sel[:]['t1'] ct1 = t1.compress((t1 > -999) & (t2 > -999)) ct2 = t2.compress((t1 > -999) & (t2 > -999)) print len(t1), len(t2), len(ct1), len(ct2) t25.append(scoreatpercentile(abs(ct2 - ct1), 25)) t50.append(scoreatpercentile(abs(ct2 - ct1), 50)) t75.append(scoreatpercentile(abs(ct2 - ct1), 75)) x.append((low + high) / 2) sx, st25, st50, st75 = loadtxt( os.path.join(DATADIR, 'DIR-boxplot_arrival_times-1.txt')) fig = figure() ax1 = subplot(131) fill_between(sx, st25, st75, color='0.75') plot(sx, st50, 'o-', color='black', markerfacecolor='none') ax2 = subplot(132, sharex=ax1, sharey=ax1) fill_between(x, t25, t75, color='0.75') plot(x, t50, 'o-', color='black') ax3 = subplot(133, sharex=ax1, sharey=ax1) plot(sx, st50, 'o-', color='black', markerfacecolor='none') plot(x, t50, 'o-', color='black') ax2.xaxis.set_label_text("Core distance [m]") ax1.yaxis.set_label_text("Arrival time difference $|t_2 - t_1|$ [ns]") fig.suptitle( r"$N_{MIP} \geq %d, \quad \theta = 0^\circ \pm %d^\circ, \quad %.1f \leq \log(E) \leq %.1f$" % (N, rad2deg(DTHETA), LOGENERGY - DLOGENERGY, LOGENERGY + DLOGENERGY)) ylim(ymax=15) xlim(xmax=80) locator_params(tight=True, nbins=4) fig.subplots_adjust(left=.1, right=.95) fig.set_size_inches(5, 2.67) utils.saveplot(N) sx = sx.compress(sx < 80) st25 = st25[:len(sx)] st50 = st50[:len(sx)] st75 = st75[:len(sx)] graph = MultiPlot(1, 3, width=r'.3\linewidth', height=r'.4\linewidth') graph.shade_region(0, 0, sx, st25, st75) graph.plot(0, 0, sx, st50, linestyle=None) graph.plot(0, 2, sx, st50) graph.set_label(0, 0, 'simulation', 'upper left') graph.shade_region(0, 1, x, t25, t75) graph.plot(0, 1, x, t50, linestyle=None, mark='*') graph.plot(0, 2, x, t50, mark='*') graph.set_label(0, 1, 'experiment', 'upper left') graph.set_label(0, 2, 'sim + exp', 'upper left') graph.set_ylimits(0, 15) graph.set_xlimits(0, 80) graph.set_xlabel("Core distance [\si{\meter}]") graph.set_ylabel( r"Arrival time difference $|t_2 - t_1|$ [\si{\nano\second}]") graph.show_xticklabels_for_all([(0, 0), (0, 1), (0, 2)]) graph.set_xticklabels_position(0, 1, 'right') graph.show_yticklabels(0, 0) artist.utils.save_graph(graph, suffix=N, dirname='plots')