Esempio n. 1
0
def plot_arrival_times():
    graph = GraphArtist()

    figure()
    sim = data.root.showers.E_1PeV.zenith_22_5
    t = get_front_arrival_time(sim, 20, 5, pi / 8)
    n, bins = histogram(t, bins=linspace(0, 50, 201))
    mct = monte_carlo_timings(n, bins, 100000)
    n, bins, patches = hist(mct, bins=linspace(0, 20, 101), histtype='step')
    graph.histogram(n, bins, linestyle='black!50')

    mint = my_t_draw_something(data, 2, 100000)
    n, bins, patches = hist(mint, bins=linspace(0, 20, 101), histtype='step')
    graph.histogram(n, bins)

    xlabel("Arrival time [ns]")
    ylabel("Number of events")

    graph.set_xlabel(r"Arrival time [\si{\nano\second}]")
    graph.set_ylabel("Number of events")
    graph.set_xlimits(0, 20)
    graph.set_ylimits(min=0)
    graph.save('plots/SIM-T')

    print(median(t), median(mct), median(mint))
Esempio n. 2
0
def plot_trace(station_group, idx):
    events = station_group.events
    blobs = station_group.blobs

    traces_idx = events[idx]['traces']
    traces = get_traces(blobs, traces_idx)
    traces = array(traces)
    x = arange(traces.shape[1])
    x *= 2.5

    clf()
    plot(x, traces.T)
    xlim(0, 200)

    #line_styles = ['solid', 'dashed', 'dotted', 'dashdotted']
    line_styles = ['black', 'black!80', 'black!60', 'black!40']
    styles = (u for u in line_styles)

    graph = GraphArtist(width=r'.5\linewidth')
    for trace in traces:
        graph.plot(x, trace / 1000, mark=None, linestyle=styles.next())
    graph.set_xlabel(r"Time [\si{\nano\second}]")
    graph.set_ylabel(r"Signal [\si{\volt}]")
    graph.set_xlimits(0, 200)
    graph.save('plots/traces')
Esempio n. 3
0
def plot_arrival_times():
    graph = GraphArtist()

    figure()
    sim = data.root.showers.E_1PeV.zenith_22_5
    t = get_front_arrival_time(sim, 20, 5, pi / 8)
    n, bins = histogram(t, bins=linspace(0, 50, 201))
    mct = monte_carlo_timings(n, bins, 100000)
    n, bins, patches = hist(mct, bins=linspace(0, 20, 101), histtype='step')
    graph.histogram(n, bins, linestyle='black!50')

    mint = my_t_draw_something(data, 2, 100000)
    n, bins, patches = hist(mint, bins=linspace(0, 20, 101), histtype='step')
    graph.histogram(n, bins)

    xlabel("Arrival time [ns]")
    ylabel("Number of events")

    graph.set_xlabel(r"Arrival time [\si{\nano\second}]")
    graph.set_ylabel("Number of events")
    graph.set_xlimits(0, 20)
    graph.set_ylimits(min=0)
    graph.save('plots/SIM-T')

    print median(t), median(mct), median(mint)
Esempio n. 4
0
def plot_R():
    graph = GraphArtist(width=r'.45\linewidth')

    n, bins, patches = hist(
        data.root.simulations.E_1PeV.zenith_22_5.shower_0.coincidences.col(
            'r'),
        bins=100,
        histtype='step')
    graph.histogram(n, bins, linestyle='black!50')

    shower = data.root.simulations.E_1PeV.zenith_22_5.shower_0
    ids = shower.observables.get_where_list(
        '(n1 >= 1) & (n3 >= 1) & (n4 >= 1)')
    R = shower.coincidences.read_coordinates(ids, field='r')
    n, bins, patches = hist(R, bins=100, histtype='step')
    graph.histogram(n, bins)

    xlabel("Core distance [m]")
    ylabel("Number of events")

    print "mean", mean(R)
    print "median", median(R)

    graph.set_xlabel(r"Core distance [\si{\meter}]")
    graph.set_ylabel("Number of events")
    graph.set_xlimits(min=0)
    graph.set_ylimits(min=0)
    graph.save('plots/SIM-R')
Esempio n. 5
0
def plot_pulseheight_histogram(data):
    events = data.root.hisparc.cluster_kascade.station_601.events
    ph = events.col('pulseheights')

    s = landau.Scintillator()
    mev_scale = 3.38 / 340
    count_scale = 6e3 / .32

    clf()
    n, bins, patches = hist(ph[:, 0],
                            bins=arange(0, 1501, 10),
                            histtype='step')
    x = linspace(0, 1500, 1500)
    plot(x, s.conv_landau_for_x(x,
                                mev_scale=mev_scale,
                                count_scale=count_scale))
    plot(x, count_scale * s.landau_pdf(x * mev_scale))
    ylim(ymax=25000)
    xlim(xmax=1500)

    # Remove one statistical fluctuation from data.  It is not important
    # for the graph, but it detracts from the main message
    index = bins.searchsorted(370)
    n[index] = mean([n[index - 1], n[index + 1]])

    graph = GraphArtist()
    n_trunc = where(n <= 100000, n, 100000)
    graph.histogram(n_trunc, bins, linestyle='gray')
    graph.add_pin('data', x=800, location='above right', use_arrow=True)
    graph.add_pin('$\gamma$', x=90, location='above right', use_arrow=True)
    graph.plot(x,
               s.conv_landau_for_x(x,
                                   mev_scale=mev_scale,
                                   count_scale=count_scale),
               mark=None)
    graph.add_pin('convolved Landau',
                  x=450,
                  location='above right',
                  use_arrow=True)
    graph.plot(x,
               count_scale * s.landau_pdf(x * mev_scale),
               mark=None,
               linestyle='black')
    graph.add_pin('Landau', x=380, location='above right', use_arrow=True)

    graph.set_xlabel(r"Pulseheight [\adc{}]")
    graph.set_ylabel(r"Number of events")
    graph.set_xlimits(0, 1400)
    graph.set_ylimits(0, 21000)
    graph.save("plots/plot_pulseheight_histogram")
def plot_nearest_neighbors(data, limit=None):
    global coincidences
    hisparc_group = data.root.hisparc.cluster_kascade.station_601
    kascade_group = data.root.kascade

    coincidences = KascadeCoincidences(data,
                                       hisparc_group,
                                       kascade_group,
                                       ignore_existing=True)

    #dt_opt = find_optimum_dt(coincidences, p0=-13, limit=1000)
    #print(dt_opt)

    graph = GraphArtist(axis='semilogy')
    styles = iter(['solid', 'dashed', 'dashdotted'])

    uncorrelated = None
    figure()
    #for shift in -12, -13, dt_opt, -14:
    for shift in -12, -13, -14:
        print("Shifting", shift)
        coincidences.search_coincidences(shift, dtlimit=1, limit=limit)
        print(".")
        dts = coincidences.coincidences['dt']
        n, bins, p = hist(abs(dts) / 1e9,
                          bins=linspace(0, 1, 101),
                          histtype='step',
                          label='%.3f s' % shift)
        n = [u if u else 1e-99 for u in n]
        graph.histogram(n, bins, linestyle=styles.next() + ',gray')
        if uncorrelated is None:
            uncorrelated = n, bins

    y, bins = uncorrelated
    x = (bins[:-1] + bins[1:]) / 2
    f = lambda x, N, a: N * exp(-a * x)
    popt, pcov = curve_fit(f, x, y)
    plot(x, f(x, *popt), label=r"$\lambda = %.2f$ Hz" % popt[1])
    graph.plot(x, f(x, *popt), mark=None)

    yscale('log')
    xlabel("Time difference [s]")
    graph.set_xlabel(r"Time difference [\si{\second}]")
    ylabel("Counts")
    graph.set_ylabel("Counts")
    legend()
    graph.set_ylimits(min=10)
    utils.saveplot()
    graph.save('plots/MAT-nearest-neighbors')
def plot_nearest_neighbors(data, limit=None):
    global coincidences
    hisparc_group = data.root.hisparc.cluster_kascade.station_601
    kascade_group = data.root.kascade

    coincidences = KascadeCoincidences(data, hisparc_group, kascade_group,
                                       ignore_existing=True)

    #dt_opt = find_optimum_dt(coincidences, p0=-13, limit=1000)
    #print dt_opt

    graph = GraphArtist(axis='semilogy')
    styles = iter(['solid', 'dashed', 'dashdotted'])

    uncorrelated = None
    figure()
    #for shift in -12, -13, dt_opt, -14:
    for shift in -12, -13, -14:
        print "Shifting", shift
        coincidences.search_coincidences(shift, dtlimit=1, limit=limit)
        print "."
        dts = coincidences.coincidences['dt']
        n, bins, p = hist(abs(dts) / 1e9, bins=linspace(0, 1, 101),
                          histtype='step', label='%.3f s' % shift)
        n = [u if u else 1e-99 for u in n]
        graph.histogram(n, bins, linestyle=styles.next() + ',gray')
        if uncorrelated is None:
            uncorrelated = n, bins

    y, bins = uncorrelated
    x = (bins[:-1] + bins[1:]) / 2
    f = lambda x, N, a: N * exp(-a * x)
    popt, pcov = curve_fit(f, x, y)
    plot(x, f(x, *popt), label=r"$\lambda = %.2f$ Hz" % popt[1])
    graph.plot(x, f(x, *popt), mark=None)

    yscale('log')
    xlabel("Time difference [s]")
    graph.set_xlabel(r"Time difference [\si{\second}]")
    ylabel("Counts")
    graph.set_ylabel("Counts")
    legend()
    graph.set_ylimits(min=10)
    utils.saveplot()
    graph.save('plots/MAT-nearest-neighbors')
def plot_front_passage():
    sim = data.root.showers.E_1PeV.zenith_0.shower_0
    leptons = sim.leptons
    R = 40
    dR = 2
    low = R - dR
    high = R + dR
    global t
    t = leptons.read_where('(low < core_distance) & (core_distance <= high)',
                          field='arrival_time')

    n, bins, patches = hist(t, bins=linspace(0, 30, 31), histtype='step')

    graph = GraphArtist()
    graph.histogram(n, bins)
    graph.set_xlabel(r"Arrival time [\si{\nano\second}]")
    graph.set_ylabel("Number of leptons")
    graph.set_ylimits(min=0)
    graph.set_xlimits(0, 30)
    graph.save('plots/front-passage')
def plot_front_passage():
    sim = data.root.showers.E_1PeV.zenith_0.shower_0
    leptons = sim.leptons
    R = 40
    dR = 2
    low = R - dR
    high = R + dR
    global t
    t = leptons.read_where('(low < core_distance) & (core_distance <= high)',
                          field='arrival_time')

    n, bins, patches = hist(t, bins=linspace(0, 30, 31), histtype='step')

    graph = GraphArtist()
    graph.histogram(n, bins)
    graph.set_xlabel(r"Arrival time [\si{\nano\second}]")
    graph.set_ylabel("Number of leptons")
    graph.set_ylimits(min=0)
    graph.set_xlimits(0, 30)
    graph.save('plots/front-passage')
def boxplot_core_distance_vs_time():
    plt.figure()

    sim = data.root.showers.E_1PeV.zenith_0.shower_0
    leptons = sim.leptons

    #bins = np.logspace(0, 2, 25)
    bins = np.linspace(0, 100, 15)
    x, arrival_time, widths = [], [], []
    t25, t50, t75 = [], [], []
    for low, high in zip(bins[:-1], bins[1:]):
        sel = leptons.readWhere(
            '(low < core_distance) & (core_distance <= high)')
        x.append(np.mean([low, high]))
        arrival_time.append(sel[:]['arrival_time'])
        widths.append((high - low) / 2)
        ts = sel[:]['arrival_time']
        t25.append(scoreatpercentile(ts, 25))
        t50.append(scoreatpercentile(ts, 50))
        t75.append(scoreatpercentile(ts, 75))

    fill_between(x, t25, t75, color='0.75')
    plot(x, t50, 'o-', color='black')

    plt.xlabel("Core distance [m]")
    plt.ylabel("Arrival time [ns]")

    #utils.title("Shower front timing structure")
    utils.saveplot()

    graph = GraphArtist()
    graph.plot(x, t50, linestyle=None)
    graph.shade_region(x, t25, t75)
    graph.set_xlabel(r"Core distance [\si{\meter}]")
    graph.set_ylabel(r"Arrival time [\si{\nano\second}]")
    graph.set_ylimits(0, 30)
    graph.set_xlimits(0, 100)
    graph.save('plots/front-passage-vs-R')
Esempio n. 11
0
def plot_R():
    graph = GraphArtist(width=r'.45\linewidth')

    n, bins, patches = hist(data.root.simulations.E_1PeV.zenith_22_5.shower_0.coincidences.col('r'), bins=100, histtype='step')
    graph.histogram(n, bins, linestyle='black!50')

    shower = data.root.simulations.E_1PeV.zenith_22_5.shower_0
    ids = shower.observables.get_where_list('(n1 >= 1) & (n3 >= 1) & (n4 >= 1)')
    R = shower.coincidences.read_coordinates(ids, field='r')
    n, bins, patches = hist(R, bins=100, histtype='step')
    graph.histogram(n, bins)

    xlabel("Core distance [m]")
    ylabel("Number of events")

    print("mean", mean(R))
    print("median", median(R))

    graph.set_xlabel(r"Core distance [\si{\meter}]")
    graph.set_ylabel("Number of events")
    graph.set_xlimits(min=0)
    graph.set_ylimits(min=0)
    graph.save('plots/SIM-R')
Esempio n. 12
0
def boxplot_core_distance_vs_time():
    plt.figure()

    sim = data.root.showers.E_1PeV.zenith_0.shower_0
    leptons = sim.leptons

    #bins = np.logspace(0, 2, 25)
    bins = np.linspace(0, 100, 15)
    x, arrival_time, widths = [], [], []
    t25, t50, t75 = [], [], []
    for low, high in zip(bins[:-1], bins[1:]):
        sel = leptons.read_where('(low < core_distance) & (core_distance <= high)')
        x.append(np.mean([low, high]))
        arrival_time.append(sel[:]['arrival_time'])
        widths.append((high - low) / 2)
        ts = sel[:]['arrival_time']
        t25.append(scoreatpercentile(ts, 25))
        t50.append(scoreatpercentile(ts, 50))
        t75.append(scoreatpercentile(ts, 75))

    fill_between(x, t25, t75, color='0.75')
    plot(x, t50, 'o-', color='black')

    plt.xlabel("Core distance [m]")
    plt.ylabel("Arrival time [ns]")

    #utils.title("Shower front timing structure")
    utils.saveplot()

    graph = GraphArtist()
    graph.plot(x, t50, linestyle=None)
    graph.shade_region(x, t25, t75)
    graph.set_xlabel(r"Core distance [\si{\meter}]")
    graph.set_ylabel(r"Arrival time [\si{\nano\second}]")
    graph.set_ylimits(0, 30)
    graph.set_xlimits(0, 100)
    graph.save('plots/front-passage-vs-R')
def plot_pulseheight_histogram(data):
    events = data.root.hisparc.cluster_kascade.station_601.events
    ph = events.col("pulseheights")

    s = landau.Scintillator()
    mev_scale = 3.38 / 340
    count_scale = 6e3 / 0.32

    clf()
    n, bins, patches = hist(ph[:, 0], bins=arange(0, 1501, 10), histtype="step")
    x = linspace(0, 1500, 1500)
    plot(x, s.conv_landau_for_x(x, mev_scale=mev_scale, count_scale=count_scale))
    plot(x, count_scale * s.landau_pdf(x * mev_scale))
    ylim(ymax=25000)
    xlim(xmax=1500)

    # Remove one statistical fluctuation from data.  It is not important
    # for the graph, but it detracts from the main message
    index = bins.searchsorted(370)
    n[index] = mean([n[index - 1], n[index + 1]])

    graph = GraphArtist()
    n_trunc = where(n <= 100000, n, 100000)
    graph.histogram(n_trunc, bins, linestyle="gray")
    graph.add_pin("data", x=800, location="above right", use_arrow=True)
    graph.add_pin("$\gamma$", x=90, location="above right", use_arrow=True)
    graph.plot(x, s.conv_landau_for_x(x, mev_scale=mev_scale, count_scale=count_scale), mark=None)
    graph.add_pin("convolved Landau", x=450, location="above right", use_arrow=True)
    graph.plot(x, count_scale * s.landau_pdf(x * mev_scale), mark=None, linestyle="black")
    graph.add_pin("Landau", x=380, location="above right", use_arrow=True)

    graph.set_xlabel(r"Pulseheight [\adc{}]")
    graph.set_ylabel(r"Number of events")
    graph.set_xlimits(0, 1400)
    graph.set_ylimits(0, 21000)
    graph.save("plots/plot_pulseheight_histogram")