def boxplot_core_distances_for_mips(table):
    THETA = deg2rad(22.5)
    DTHETA = deg2rad(1.)
    DN = .5

    ENERGY = 1e15
    DENERGY = 2e14

    MAX_R = 80

    r25_list = []
    r50_list = []
    r75_list = []
    x = []
    for N in range(1, 5):
        sel = table.read_where('(abs(min_n134 - N) <= DN) & (abs(reference_theta - THETA) <= DTHETA) & (abs(k_energy - ENERGY) <= DENERGY) & (r <= MAX_R)')
        r = sel[:]['r']
        r25_list.append(scoreatpercentile(r, 25))
        r50_list.append(scoreatpercentile(r, 50))
        r75_list.append(scoreatpercentile(r, 75))
        x.append(N)
        print(len(r))

    sx, sr25, sr50, sr75 = loadtxt(os.path.join(DATADIR, 'DIR-save_for_kascade_boxplot_core_distances_for_mips.txt'))

    fig = figure()

    ax1 = subplot(131)
    fill_between(sx, sr25, sr75, color='0.75')
    plot(sx, sr50, 'o-', color='black', markerfacecolor='none')

    ax2 = subplot(132, sharex=ax1, sharey=ax1)
    fill_between(x, r25_list, r75_list, color='0.75')
    plot(x, r50_list, 'o-', color='black')

    ax3 = subplot(133, sharex=ax1, sharey=ax1)
    plot(x, sr50, 'o-', color='black', markerfacecolor='none')
    plot(x, r50_list, 'o-', color='black')

    ax2.xaxis.set_label_text("Minimum number of particles $\pm %.1f$" % DN)
    ax1.yaxis.set_label_text("Core distance [m]")
    fig.suptitle(r"$\theta = 22.5^\circ \pm %d^\circ, \quad %.1f \leq \log(E) \leq %.1f$" % (rad2deg(DTHETA), log10(ENERGY - DENERGY), log10(ENERGY + DENERGY)))

    ax1.xaxis.set_ticks([1, 2, 3, 4])
    fig.subplots_adjust(left=.1, right=.95)

    ylim(ymin=0)
    xlim(.8, 4.2)

    fig.set_size_inches(5, 2.67)
    utils.saveplot()

    graph = MultiPlot(1, 3, width=r'.3\linewidth', height=r'.4\linewidth')

    graph.shade_region(0, 0, sx, sr25, sr75)
    graph.plot(0, 0, sx, sr50, linestyle=None)
    graph.plot(0, 2, sx, sr50)
    graph.set_label(0, 0, 'simulation')

    graph.shade_region(0, 1, x, r25_list, r75_list)
    graph.plot(0, 1, x, r50_list, linestyle=None, mark='*')
    graph.plot(0, 2, x, r50_list, mark='*')
    graph.set_label(0, 1, 'experiment')

    graph.set_label(0, 2, 'sim + exp')

    graph.set_ylimits(0, 50)
    graph.set_xlabel("Minimum number of particles $\pm %.1f$" % DN)
    graph.set_ylabel("Core distance [\si{\meter}]")
    graph.show_xticklabels_for_all([(0, 0), (0, 1), (0, 2)])
    graph.show_yticklabels(0, 0)

    artist.utils.save_graph(graph, dirname='plots')
Exemple #2
0
def boxplot_core_distances_for_mips(table):
    THETA = deg2rad(22.5)
    DTHETA = deg2rad(1.)
    DN = .5

    ENERGY = 1e15
    DENERGY = 2e14

    MAX_R = 80

    r25_list = []
    r50_list = []
    r75_list = []
    x = []
    for N in range(1, 5):
        sel = table.readWhere(
            '(abs(min_n134 - N) <= DN) & (abs(reference_theta - THETA) <= DTHETA) & (abs(k_energy - ENERGY) <= DENERGY) & (r <= MAX_R)'
        )
        r = sel[:]['r']
        r25_list.append(scoreatpercentile(r, 25))
        r50_list.append(scoreatpercentile(r, 50))
        r75_list.append(scoreatpercentile(r, 75))
        x.append(N)
        print len(r)

    sx, sr25, sr50, sr75 = loadtxt(
        os.path.join(
            DATADIR,
            'DIR-save_for_kascade_boxplot_core_distances_for_mips.txt'))

    fig = figure()

    ax1 = subplot(131)
    fill_between(sx, sr25, sr75, color='0.75')
    plot(sx, sr50, 'o-', color='black', markerfacecolor='none')

    ax2 = subplot(132, sharex=ax1, sharey=ax1)
    fill_between(x, r25_list, r75_list, color='0.75')
    plot(x, r50_list, 'o-', color='black')

    ax3 = subplot(133, sharex=ax1, sharey=ax1)
    plot(x, sr50, 'o-', color='black', markerfacecolor='none')
    plot(x, r50_list, 'o-', color='black')

    ax2.xaxis.set_label_text("Minimum number of particles $\pm %.1f$" % DN)
    ax1.yaxis.set_label_text("Core distance [m]")
    fig.suptitle(
        r"$\theta = 22.5^\circ \pm %d^\circ, \quad %.1f \leq \log(E) \leq %.1f$"
        % (rad2deg(DTHETA), log10(ENERGY - DENERGY), log10(ENERGY + DENERGY)))

    ax1.xaxis.set_ticks([1, 2, 3, 4])
    fig.subplots_adjust(left=.1, right=.95)

    ylim(ymin=0)
    xlim(.8, 4.2)

    fig.set_size_inches(5, 2.67)
    utils.saveplot()

    graph = MultiPlot(1, 3, width=r'.3\linewidth', height=r'.4\linewidth')

    graph.shade_region(0, 0, sx, sr25, sr75)
    graph.plot(0, 0, sx, sr50, linestyle=None)
    graph.plot(0, 2, sx, sr50)
    graph.set_label(0, 0, 'simulation')

    graph.shade_region(0, 1, x, r25_list, r75_list)
    graph.plot(0, 1, x, r50_list, linestyle=None, mark='*')
    graph.plot(0, 2, x, r50_list, mark='*')
    graph.set_label(0, 1, 'experiment')

    graph.set_label(0, 2, 'sim + exp')

    graph.set_ylimits(0, 50)
    graph.set_xlabel("Minimum number of particles $\pm %.1f$" % DN)
    graph.set_ylabel("Core distance [\si{\meter}]")
    graph.show_xticklabels_for_all([(0, 0), (0, 1), (0, 2)])
    graph.show_yticklabels(0, 0)

    artist.utils.save_graph(graph, 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.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')
Exemple #4
0
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')