def plot_raw(raw_traces): length = 2.5 * len(raw_traces[0]) plot = Plot() max_signal = max(chain.from_iterable(raw_traces)) plot.add_pin_at_xy(500, max_signal, 'pre-trigger', location='above', use_arrow=False) plot.draw_vertical_line(1000, 'gray') plot.add_pin_at_xy(1750, max_signal, 'trigger', location='above', use_arrow=False) plot.draw_vertical_line(2500, 'gray') plot.add_pin_at_xy(4250, max_signal, 'post-trigger', location='above', use_arrow=False) for i, raw_trace in enumerate(raw_traces): plot.plot(arange(0, length, 2.5), raw_trace, mark=None, linestyle=COLORS[i]) plot.set_ylimits(min=0) plot.set_xlimits(min=0, max=length) plot.set_ylabel(r'Signal strength [ADC counts]') plot.set_xlabel(r'Sample [\si{\nano\second}]') plot.save_as_pdf('raw')
def zoom_pulse(raw_traces): plot = Plot() start, end = get_outer_limits(raw_traces, 253) for i, raw_trace in enumerate(raw_traces): plot.plot(arange(start * 2.5, end * 2.5, 2.5), raw_trace[start:end], mark=None, linestyle=COLORS[i]) hisparc_version = 2 if hisparc_version == 3: low = 81 high = 150 elif hisparc_version == 2: low = 253 high = 323 plot.draw_horizontal_line(low, 'gray') plot.add_pin_at_xy(start * 2.5, low, 'low', location='above right', use_arrow=False) plot.draw_horizontal_line(high, 'gray') plot.add_pin_at_xy(start * 2.5, high, 'high', location='above right', use_arrow=False) plot.set_ylimits(min=0) plot.set_xlimits(min=start * 2.5, max=end * 2.5 - 2.5) plot.set_ylabel(r'Signal strength [ADC counts]') plot.set_xlabel(r'Sample [\si{\nano\second}]') plot.save_as_pdf('pulse')
def main(): locations = np.genfromtxt( 'data/SP-DIR-plot_sciencepark_cluster-detectors.txt', names=['x', 'y']) stations = np.genfromtxt( 'data/SP-DIR-plot_sciencepark_cluster-stations.txt', names=['id', 'x', 'y']) graph = Plot() graph.scatter(locations['x'], locations['y']) graph.set_axis_equal() locations = ['right'] * len(stations) locations[0] = 'left' locations[5] = 'above right' locations = iter(locations) for num, x, y in stations: graph.add_pin_at_xy(x, y, int(num), location=next(locations), use_arrow=False, style='gray,label distance=1ex') x = [stations['x'][u] for u in [0, 2, 5]] y = [stations['y'][u] for u in [0, 2, 5]] x.append(x[0]) y.append(y[0]) graph.plot(x, y, mark=None, linestyle='dashed') graph.add_pin_at_xy([x[0], x[1]], [y[0], y[1]], r'\SI{128}{\meter}', relative_position=.4, location='below right', use_arrow=False) graph.add_pin_at_xy([x[0], x[2]], [y[0], y[2]], r'\SI{151}{\meter}', relative_position=.5, location='left', use_arrow=False) graph.add_pin_at_xy([x[2], x[1]], [y[2], y[1]], r'\SI{122}{\meter}', relative_position=.5, location='above right', use_arrow=False) graph.set_xlabel(r"Distance [\si{\meter}]") graph.set_ylabel(r"Distance [\si{\meter}]") graph.save('sciencepark')
def plot_traces(traces, label='', raw=False): """Plot traces Does not take different mV/ADC for HiSPARC II-III into account! :param traces: list of lists of trace values. :param label: name (suffix) for the output pdf. """ colors = ['black', 'red', 'black!40!green', 'blue'] plot = Plot(width=r'.6\textwidth') times = arange(0, len(traces[0]) * 2.5, 2.5) for i, trace in enumerate(traces): if not raw: if max(trace) * 0.57 < 500: use_milli = True trace = [t * -0.57 for t in trace] else: use_milli = False trace = [t * -0.57 / 1e3 for t in trace] plot.plot(times, trace, linestyle='%s, thin' % colors[i], mark=None) if len(traces[0]) == 2400 and raw: plot.add_pin_at_xy(500, 10, 'pre-trigger', location='below', use_arrow=False) plot.add_pin_at_xy(1750, 10, 'trigger', location='below', use_arrow=False) plot.add_pin_at_xy(4250, 10, 'post-trigger', location='below', use_arrow=False) plot.draw_vertical_line(1000, 'gray') plot.draw_vertical_line(2500, 'gray') if raw: plot.set_ylabel(r'Signal strength [ADCcounts]') elif use_milli: plot.set_ylabel(r'Signal strength [\si{\milli\volt}]') else: plot.set_ylabel(r'Signal strength [\si{\volt}]') plot.set_xlabel(r'Event time [\si{\ns}]') plot.set_xlimits(0, times[-1]) plot.set_axis_options('line join=round') plot.save_as_pdf('trace_' + label)
def plot_times(): plot = Plot('semilogx') data = read_times() walltimes = data['walltime'] / 60. / 60. # To hours print 'Total time: %d years.' % (sum(walltimes) / 24. / 365.) print 'Longest job: %d hours.' % max(walltimes) print 'Shortest job: %d seconds.' % (min(walltimes) * 60. * 60.) counts, bins = histogram(log10(walltimes), bins=300) plot.histogram(counts, 10**bins, linestyle='fill=black') plot.add_pin_at_xy(4, max(counts), 'short', location='above left', use_arrow=False) plot.draw_vertical_line(4, 'gray') plot.add_pin_at_xy(24, max(counts), 'generic', location='above left', use_arrow=False) plot.draw_vertical_line(24, 'gray') plot.add_pin_at_xy(96, max(counts), 'long', location='above left', use_arrow=False) plot.draw_vertical_line(96, 'gray') plot.add_pin_at_xy(2000, max(counts), 'extra-long', location='above left', use_arrow=False) plot.draw_vertical_line(2000, 'gray') plot.set_ylabel(r'Count') plot.set_xlabel(r'Walltime [\si{\hour}]') plot.set_ylimits(min=0) plot.set_xlimits(min=3e-3, max=3e3) plot.save_as_pdf('shower_walltime')
def main(): plot = Plot(width=r'.5\linewidth', height=r'.5\linewidth') r = linspace(1, 5, 100) phi = linspace(0, 4.5 * pi, 100) x = r * cos(phi) y = r * sin(phi) plot.plot(x, y, mark=None) plot.add_pin('start', relative_position=0, use_arrow=True) plot.add_pin('half', relative_position=.5, use_arrow=True) plot.add_pin('46\%', relative_position=.46, use_arrow=True, location='above') plot.add_pin('end', relative_position=1, use_arrow=True, location='below') phi = linspace(0, 2 * pi, 10) x = 6 * cos(phi) y = 6 * sin(phi) plot.plot(x, y, mark=None, linestyle='thick, gray') plot.add_pin('start', relative_position=0, use_arrow=True, location='above right') plot.add_pin('half', relative_position=.5, use_arrow=True, location='above left') plot.add_pin('70\%', relative_position=.7, use_arrow=True, location='below') plot.add_pin('end', relative_position=1, use_arrow=True, location='below right') plot.plot([-5, 2, 5], [-7.5, -7.5, -7.5], linestyle='lightgray') plot.add_pin('50\%', relative_position=.5, use_arrow=True, location='above right') plot.set_xlimits(-8, 8) plot.set_ylimits(-8, 8) plot.save('relative_pin') # With one logarithmic axis plot = Plot(axis='semilogy') x = [2, 2, 2] y = [1, 10, 100] plot.plot(x, y) for xi, yi in zip(x, y): plot.add_pin_at_xy(xi, yi, '(%d,%d)' % (xi, yi), location='below right') plot.add_pin('half', relative_position=.5, use_arrow=True, location='right') x = [4, 5, 6] y = [3, 3, 3] plot.plot(x, y) for xi, yi in zip(x, y): plot.add_pin_at_xy(xi, yi, '(%d,%d)' % (xi, yi), location='below') plot.add_pin('half', relative_position=.5, use_arrow=True, location='above') x = [3, 4, 5] y = [1, 10, 100] plot.plot(x, y) for xi, yi in zip(x, y): plot.add_pin_at_xy(xi, yi, '(%d,%d)' % (xi, yi), location='above left') plot.add_pin('half', relative_position=.5, use_arrow=True, location='right') plot.save('relative_pin_log')
def main(): """Event display for an event of station 503 Date Time Timestamp Nanoseconds 2012-03-29 10:51:36 1333018296 870008589 Number of MIPs 35.0 51.9 35.8 78.9 Arrival time 15.0 17.5 20.0 27.5 """ # Detector positions in ENU relative to the station GPS x = [-6.34, -2.23, -3.6, 3.46] y = [6.34, 2.23, -3.6, 3.46] # Scale mips to fit the graph n = [35.0, 51.9, 35.8, 78.9] # Make times relative to first detection t = [15., 17.5, 20., 27.5] dt = [ti - min(t) for ti in t] plot = Plot() plot.scatter([0], [0], mark='triangle') plot.add_pin_at_xy(0, 0, 'Station 503', use_arrow=False, location='below') plot.scatter_table(x, y, dt, n) plot.set_scalebar(location="lower right") plot.set_colorbar('$\Delta$t [ns]') plot.set_axis_equal() plot.set_mlimits(max=16.) plot.set_slimits(min=10., max=100.) plot.set_xlabel('x [m]') plot.set_ylabel('y [m]') plot.save('event_display') # Add event by Station 508 # Detector positions in ENU relative to the station GPS x508 = [6.12, 0.00, -3.54, 3.54] y508 = [-6.12, -13.23, -3.54, 3.54] # Event GPS timestamp: 1371498167.016412100 # MIPS n508 = [5.6, 16.7, 36.6, 9.0] # Arrival Times t508 = [15., 22.5, 22.5, 30.] dt508 = [ti - min(t508) for ti in t508] plot = MultiPlot(1, 2, width=r'.33\linewidth') plot.set_xlimits_for_all(min=-10, max=15) plot.set_ylimits_for_all(min=-15, max=10) plot.set_mlimits_for_all(min=0., max=16.) plot.set_colorbar('$\Delta$t [ns]', False) plot.set_colormap('blackwhite') plot.set_scalebar_for_all(location="upper right") p = plot.get_subplot_at(0, 0) p.scatter([0], [0], mark='triangle') p.add_pin_at_xy(0, 0, 'Station 503', use_arrow=False, location='below') p.scatter_table(x, y, dt, n) p.set_axis_equal() p = plot.get_subplot_at(0, 1) p.scatter([0], [0], mark='triangle') p.add_pin_at_xy(0, 0, 'Station 508', use_arrow=False, location='below') p.scatter_table(x508, y508, dt508, n508) p.set_axis_equal() plot.show_yticklabels_for_all([(0, 0)]) plot.show_xticklabels_for_all([(0, 0), (0, 1)]) plot.set_xlabel('x [m]') plot.set_ylabel('y [m]') plot.save('multi_event_display')
def plot_traces(traces1, traces2, overlap=0, label=''): """Plot traces :param traces: list of lists of trace values. :param label: name (suffix) for the output pdf. """ colors1 = ['black', 'red', 'black!40!green', 'blue'] colors2 = ['gray', 'black!40!red', 'black!60!green', 'black!40!blue'] plot = Plot(width=r'1.\textwidth', height=r'.3\textwidth') times1 = arange(0, len(traces1[0]) * 2.5, 2.5) times2 = arange((len(traces1[0]) - overlap) * 2.5, (len(traces1[0]) + len(traces2[0]) - overlap) * 2.5, 2.5) for i, trace in enumerate(traces1): plot.plot(times1, array(trace) + i * 20, linestyle='%s, ultra thin' % colors1[i], mark=None) plot.draw_vertical_line(1000, 'gray, very thin') plot.draw_vertical_line(2500, 'gray, very thin') plot.draw_vertical_line(6000, 'pink, dashed, very thin') plot.add_pin_at_xy(0, 450, r'\tiny{pre-trigger}', location='right', use_arrow=False) plot.add_pin_at_xy(1000, 450, r'\tiny{trigger}', location='right', use_arrow=False) plot.add_pin_at_xy(2500, 450, r'\tiny{post-trigger}', location='right', use_arrow=False) plot.add_pin_at_xy(6000, 450, r'\tiny{end of first event}', location='left', use_arrow=True) for i, trace in enumerate(traces2): plot.plot(times2, array(trace) + i * 20, linestyle='%s, ultra thin' % colors2[i], mark=None) plot.draw_vertical_line(6000 - (overlap * 2.5), 'pink, very thin') plot.draw_vertical_line(7000 - (overlap * 2.5), 'gray, very thin') plot.draw_vertical_line(8500 - (overlap * 2.5), 'gray, very thin') plot.add_pin_at_xy(6000 - (overlap * 2.5), 400, r'\tiny{pre-trigger}', location='right', use_arrow=False) plot.add_pin_at_xy(7000 - (overlap * 2.5), 400, r'\tiny{trigger}', location='right', use_arrow=False) plot.add_pin_at_xy(8500 - (overlap * 2.5), 400, r'\tiny{post-trigger}', location='right', use_arrow=False) plot.set_ylabel(r'Signal strength [ADCcounts]') plot.set_xlabel(r'Event time [\si{\ns}]') plot.set_ylimits(0, 500) plot.set_xlimits(0, times2[-1]) plot.set_axis_options('line join=round') plot.save_as_pdf('trace_' + label)