def boxplot_arrival_times(group, N): table = group.E_1PeV.zenith_0 sel = table.readWhere('min_n134 >= N') t1 = sel[:]['t1'] t3 = sel[:]['t3'] t4 = sel[:]['t4'] ts = concatenate([t1, t3, t4]) print "Median arrival time delay over all detected events", median(ts) figure() bin_edges = linspace(0, 100, 11) x, arrival_times = [], [] t25, t50, t75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): query = '(min_n134 >= N) & (low <= r) & (r < high)' sel = table.readWhere(query) t1 = sel[:]['t1'] t2 = sel[:]['t2'] ct1 = t1.compress((t1 > -999) & (t2 > -999)) ct2 = t2.compress((t1 > -999) & (t2 > -999)) ts = abs(ct2 - ct1) t25.append(scoreatpercentile(ts, 25)) t50.append(scoreatpercentile(ts, 50)) t75.append(scoreatpercentile(ts, 75)) x.append((low + high) / 2) fill_between(x, t25, t75, color='0.75') plot(x, t50, 'o-', color='black') xlabel("Core distance [m]") ylabel("Arrival time delay [ns]") #title(r"$N_{MIP} \geq %d, \quad \theta = 0^\circ$" % N) xticks(arange(0, 100.5, 10)) utils.savedata((x, t25, t50, t75), N) utils.saveplot(N) graph = GraphArtist() graph.shade_region(x, t25, t75) graph.plot(x, t50, linestyle=None) graph.set_xlabel(r"Core distance [\si{\meter}]") graph.set_ylabel( r"Arrival time difference $|t_2 - t_1|$ [\si{\nano\second}]") graph.set_xlimits(0, 100) graph.set_ylimits(min=0) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_arrival_times(group, N): table = group.E_1PeV.zenith_0 sel = table.read_where('min_n134 >= N') t1 = sel[:]['t1'] t3 = sel[:]['t3'] t4 = sel[:]['t4'] ts = concatenate([t1, t3, t4]) print "Median arrival time delay over all detected events", median(ts) figure() bin_edges = linspace(0, 100, 11) x, arrival_times = [], [] t25, t50, t75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): query = '(min_n134 >= N) & (low <= r) & (r < high)' sel = table.read_where(query) t1 = sel[:]['t1'] t2 = sel[:]['t2'] ct1 = t1.compress((t1 > -999) & (t2 > -999)) ct2 = t2.compress((t1 > -999) & (t2 > -999)) ts = abs(ct2 - ct1) t25.append(scoreatpercentile(ts, 25)) t50.append(scoreatpercentile(ts, 50)) t75.append(scoreatpercentile(ts, 75)) x.append((low + high) / 2) fill_between(x, t25, t75, color='0.75') plot(x, t50, 'o-', color='black') xlabel("Core distance [m]") ylabel("Arrival time delay [ns]") #title(r"$N_{MIP} \geq %d, \quad \theta = 0^\circ$" % N) xticks(arange(0, 100.5, 10)) utils.savedata((x, t25, t50, t75), N) utils.saveplot(N) graph = GraphArtist() graph.shade_region(x, t25, t75) graph.plot(x, t50, linestyle=None) graph.set_xlabel(r"Core distance [\si{\meter}]") graph.set_ylabel(r"Arrival time difference $|t_2 - t_1|$ [\si{\nano\second}]") graph.set_xlimits(0, 100) graph.set_ylimits(min=0) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_phi_reconstruction_results_for_MIP(table, N): figure() THETA = deg2rad(22.5) DTHETA = deg2rad(5.) bin_edges = linspace(-180, 180, 18) x, r_dphi = [], [] d25, d50, d75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): rad_low = deg2rad(low) rad_high = deg2rad(high) query = '(min_n134 >= N) & (rad_low < reference_phi) & (reference_phi < rad_high) & (abs(reference_theta - THETA) <= DTHETA)' sel = table.readWhere(query) dphi = sel[:]['reconstructed_phi'] - sel[:]['reference_phi'] dphi = (dphi + pi) % (2 * pi) - pi r_dphi.append(rad2deg(dphi)) d25.append(scoreatpercentile(rad2deg(dphi), 25)) d50.append(scoreatpercentile(rad2deg(dphi), 50)) d75.append(scoreatpercentile(rad2deg(dphi), 75)) x.append((low + high) / 2) #boxplot(r_dphi, positions=x, widths=1 * (high - low), sym='') fill_between(x, d25, d75, color='0.75') plot(x, d50, 'o-', color='black') xlabel(r"$\phi_K$ [deg]") ylabel(r"$\phi_H - \phi_K$ [deg]") title(r"$N_{MIP} \geq %d, \quad \theta = 22.5^\circ \pm %d^\circ$" % (N, rad2deg(DTHETA))) xticks(linspace(-180, 180, 9)) axhline(0, color='black') utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(x, d25, d75) graph.plot(x, d50, linestyle=None) graph.set_xlabel(r"$\phi_K$ [\si{\degree}]") graph.set_ylabel(r"$\phi_H - \phi_K$ [\si{\degree}]") graph.set_xticks([-180, -90, '...', 180]) graph.set_xlimits(-180, 180) graph.set_ylimits(-23, 23) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_phi_reconstruction_results_for_MIP(table, N): figure() THETA = deg2rad(22.5) DTHETA = deg2rad(5.) bin_edges = linspace(-180, 180, 18) x, r_dphi = [], [] d25, d50, d75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): rad_low = deg2rad(low) rad_high = deg2rad(high) query = '(min_n134 >= N) & (rad_low < reference_phi) & (reference_phi < rad_high) & (abs(reference_theta - THETA) <= DTHETA)' sel = table.read_where(query) dphi = sel[:]['reconstructed_phi'] - sel[:]['reference_phi'] dphi = (dphi + pi) % (2 * pi) - pi r_dphi.append(rad2deg(dphi)) d25.append(scoreatpercentile(rad2deg(dphi), 25)) d50.append(scoreatpercentile(rad2deg(dphi), 50)) d75.append(scoreatpercentile(rad2deg(dphi), 75)) x.append((low + high) / 2) #boxplot(r_dphi, positions=x, widths=1 * (high - low), sym='') fill_between(x, d25, d75, color='0.75') plot(x, d50, 'o-', color='black') xlabel(r"$\phi_K$ [deg]") ylabel(r"$\phi_H - \phi_K$ [deg]") title(r"$N_{MIP} \geq %d, \quad \theta = 22.5^\circ \pm %d^\circ$" % (N, rad2deg(DTHETA))) xticks(linspace(-180, 180, 9)) axhline(0, color='black') utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(x, d25, d75) graph.plot(x, d50, linestyle=None) graph.set_xlabel(r"$\phi_K$ [\si{\degree}]") graph.set_ylabel(r"$\phi_H - \phi_K$ [\si{\degree}]") graph.set_xticks([-180, -90, '...', 180]) graph.set_xlimits(-180, 180) graph.set_ylimits(-23, 23) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_phi_reconstruction_results_for_MIP(group, N): table = group.E_1PeV.zenith_22_5 figure() bin_edges = linspace(-180, 180, 18) x, r_dphi = [], [] d25, d50, d75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): rad_low = deg2rad(low) rad_high = deg2rad(high) query = '(min_n134 >= N) & (rad_low < reference_phi) & (reference_phi < rad_high)' sel = table.read_where(query) dphi = sel[:]['reconstructed_phi'] - sel[:]['reference_phi'] dphi = (dphi + pi) % (2 * pi) - pi r_dphi.append(rad2deg(dphi)) d25.append(scoreatpercentile(rad2deg(dphi), 25)) d50.append(scoreatpercentile(rad2deg(dphi), 50)) d75.append(scoreatpercentile(rad2deg(dphi), 75)) x.append((low + high) / 2) fill_between(x, d25, d75, color='0.75') plot(x, d50, 'o-', color='black') xlabel(r"$\phi_{simulated}$ [deg]") ylabel(r"$\phi_{reconstructed} - \phi_{simulated}$ [deg]") #title(r"$N_{MIP} \geq %d, \quad \theta = 22.5^\circ$" % N) xticks(linspace(-180, 180, 9)) axhline(0, color='black') ylim(-15, 15) utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(x, d25, d75) graph.plot(x, d50, linestyle=None) graph.set_xlabel(r"$\phi_\mathrm{sim}$ [\si{\degree}]") graph.set_ylabel(r"$\phi_\mathrm{rec} - \phi_\mathrm{sim}$ [\si{\degree}]") graph.set_title(r"$N_\mathrm{MIP} \geq %d$" % N) graph.set_xticks([-180, -90, '...', 180]) graph.set_xlimits(-180, 180) graph.set_ylimits(-17, 17) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_phi_reconstruction_results_for_MIP(group, N): table = group.E_1PeV.zenith_22_5 figure() bin_edges = linspace(-180, 180, 18) x, r_dphi = [], [] d25, d50, d75 = [], [], [] for low, high in zip(bin_edges[:-1], bin_edges[1:]): rad_low = deg2rad(low) rad_high = deg2rad(high) query = '(min_n134 >= N) & (rad_low < reference_phi) & (reference_phi < rad_high)' sel = table.readWhere(query) dphi = sel[:]['reconstructed_phi'] - sel[:]['reference_phi'] dphi = (dphi + pi) % (2 * pi) - pi r_dphi.append(rad2deg(dphi)) d25.append(scoreatpercentile(rad2deg(dphi), 25)) d50.append(scoreatpercentile(rad2deg(dphi), 50)) d75.append(scoreatpercentile(rad2deg(dphi), 75)) x.append((low + high) / 2) fill_between(x, d25, d75, color='0.75') plot(x, d50, 'o-', color='black') xlabel(r"$\phi_{simulated}$ [deg]") ylabel(r"$\phi_{reconstructed} - \phi_{simulated}$ [deg]") #title(r"$N_{MIP} \geq %d, \quad \theta = 22.5^\circ$" % N) xticks(linspace(-180, 180, 9)) axhline(0, color='black') ylim(-15, 15) utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(x, d25, d75) graph.plot(x, d50, linestyle=None) graph.set_xlabel(r"$\phi_\mathrm{sim}$ [\si{\degree}]") graph.set_ylabel(r"$\phi_\mathrm{rec} - \phi_\mathrm{sim}$ [\si{\degree}]") graph.set_title(r"$N_\mathrm{MIP} \geq %d$" % N) graph.set_xticks([-180, -90, '...', 180]) graph.set_xlimits(-180, 180) graph.set_ylimits(-17, 17) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_theta_reconstruction_results_for_MIP(table, N): figure() DTHETA = deg2rad(1.) angles = [0, 5, 10, 15, 22.5, 35] r_dtheta = [] x = [] d25, d50, d75 = [], [], [] for angle in angles: theta = deg2rad(angle) sel = table.readWhere( '(min_n134 >= N) & (abs(reference_theta - theta) <= DTHETA)') dtheta = rad2deg(sel[:]['reconstructed_theta'] - sel[:]['reference_theta']) r_dtheta.append(dtheta) d25.append(scoreatpercentile(dtheta, 25)) d50.append(scoreatpercentile(dtheta, 50)) d75.append(scoreatpercentile(dtheta, 75)) x.append(angle) #boxplot(r_dtheta, sym='', positions=angles, widths=2.) fill_between(x, d25, d75, color='0.75') plot(x, d50, 'o-', color='black') xlabel(r"$\theta_K$ [deg]") ylabel(r"$\theta_H - \theta_K$ [deg]") title(r"$N_{MIP} \geq %d$" % N) axhline(0, color='black') ylim(-20, 25) xlim(0, 35) utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(angles, d25, d75) graph.plot(angles, d50, linestyle=None) graph.set_xlabel(r"$\theta_K$ [\si{\degree}]") graph.set_ylabel(r"$\theta_H - \theta_K$ [\si{\degree}]") graph.set_ylimits(-5, 15) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_theta_reconstruction_results_for_MIP(table, N): figure() DTHETA = deg2rad(1.) angles = [0, 5, 10, 15, 22.5, 35] r_dtheta = [] x = [] d25, d50, d75 = [], [], [] for angle in angles: theta = deg2rad(angle) sel = table.read_where('(min_n134 >= N) & (abs(reference_theta - theta) <= DTHETA)') dtheta = rad2deg(sel[:]['reconstructed_theta'] - sel[:]['reference_theta']) r_dtheta.append(dtheta) d25.append(scoreatpercentile(dtheta, 25)) d50.append(scoreatpercentile(dtheta, 50)) d75.append(scoreatpercentile(dtheta, 75)) x.append(angle) #boxplot(r_dtheta, sym='', positions=angles, widths=2.) fill_between(x, d25, d75, color='0.75') plot(x, d50, 'o-', color='black') xlabel(r"$\theta_K$ [deg]") ylabel(r"$\theta_H - \theta_K$ [deg]") title(r"$N_{MIP} \geq %d$" % N) axhline(0, color='black') ylim(-20, 25) xlim(0, 35) utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(angles, d25, d75) graph.plot(angles, d50, linestyle=None) graph.set_xlabel(r"$\theta_K$ [\si{\degree}]") graph.set_ylabel(r"$\theta_H - \theta_K$ [\si{\degree}]") graph.set_ylimits(-5, 15) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_theta_reconstruction_results_for_MIP(group, N): group = group.E_1PeV figure() angles = [0, 5, 10, 15, 22.5, 30, 35, 45] r_dtheta = [] d25, d50, d75 = [], [], [] for angle in angles: table = group._f_getChild('zenith_%s' % str(angle).replace('.', '_')) sel = table.readWhere('min_n134 >= %d' % N) dtheta = sel[:]['reconstructed_theta'] - sel[:]['reference_theta'] r_dtheta.append(rad2deg(dtheta)) d25.append(scoreatpercentile(rad2deg(dtheta), 25)) d50.append(scoreatpercentile(rad2deg(dtheta), 50)) d75.append(scoreatpercentile(rad2deg(dtheta), 75)) fill_between(angles, d25, d75, color='0.75') plot(angles, d50, 'o-', color='black') xlabel(r"$\theta_{simulated}$ [deg]") ylabel(r"$\theta_{reconstructed} - \theta_{simulated}$ [deg]") #title(r"$N_{MIP} \geq %d$" % N) axhline(0, color='black') ylim(-10, 25) utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(angles, d25, d75) graph.plot(angles, d50, linestyle=None) graph.set_xlabel(r"$\theta_\mathrm{sim}$ [\si{\degree}]") graph.set_ylabel( r"$\theta_\mathrm{rec} - \theta_\mathrm{sim}$ [\si{\degree}]") graph.set_title(r"$N_\mathrm{MIP} \geq %d$" % N) graph.set_ylimits(-8, 22) artist.utils.save_graph(graph, suffix=N, dirname='plots')
def boxplot_theta_reconstruction_results_for_MIP(group, N): group = group.E_1PeV figure() angles = [0, 5, 10, 15, 22.5, 30, 35, 45] r_dtheta = [] d25, d50, d75 = [], [], [] for angle in angles: table = group._f_get_child('zenith_%s' % str(angle).replace('.', '_')) sel = table.read_where('min_n134 >= %d' % N) dtheta = sel[:]['reconstructed_theta'] - sel[:]['reference_theta'] r_dtheta.append(rad2deg(dtheta)) d25.append(scoreatpercentile(rad2deg(dtheta), 25)) d50.append(scoreatpercentile(rad2deg(dtheta), 50)) d75.append(scoreatpercentile(rad2deg(dtheta), 75)) fill_between(angles, d25, d75, color='0.75') plot(angles, d50, 'o-', color='black') xlabel(r"$\theta_{simulated}$ [deg]") ylabel(r"$\theta_{reconstructed} - \theta_{simulated}$ [deg]") #title(r"$N_{MIP} \geq %d$" % N) axhline(0, color='black') ylim(-10, 25) utils.saveplot(N) graph = GraphArtist() graph.draw_horizontal_line(0, linestyle='gray') graph.shade_region(angles, d25, d75) graph.plot(angles, d50, linestyle=None) graph.set_xlabel(r"$\theta_\mathrm{sim}$ [\si{\degree}]") graph.set_ylabel(r"$\theta_\mathrm{rec} - \theta_\mathrm{sim}$ [\si{\degree}]") graph.set_title(r"$N_\mathrm{MIP} \geq %d$" % N) graph.set_ylimits(-8, 22) artist.utils.save_graph(graph, suffix=N, dirname='plots')
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')
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 boxplot_core_distances_for_mips(group): table = group.E_1PeV.zenith_22_5 figure() r_list = [] r25, r50, r75 = [], [], [] x = [] for N in range(1, 5): sel = table.read_where('min_n134 >= N') r = sel[:]['r'] r_list.append(r) x.append(N) r25.append(scoreatpercentile(r, 25)) r50.append(scoreatpercentile(r, 50)) r75.append(scoreatpercentile(r, 75)) fill_between(x, r25, r75, color='0.75') plot(x, r50, 'o-', color='black') xticks(range(1, 5)) xlabel("Minimum number of particles") ylabel("Core distance [m]") #title(r"$\theta = 22.5^\circ$") utils.saveplot() graph = GraphArtist() graph.shade_region(x, r25, r75) graph.plot(x, r50, linestyle=None) graph.set_xlabel("Minimum number of particles") graph.set_ylabel(r"Core distance [\si{\meter}]") graph.set_ylimits(min=0) graph.set_xticks(range(5)) artist.utils.save_graph(graph, dirname='plots')
def boxplot_core_distances_for_mips(group): table = group.E_1PeV.zenith_22_5 figure() r_list = [] r25, r50, r75 = [], [], [] x = [] for N in range(1, 5): sel = table.readWhere('min_n134 >= N') r = sel[:]['r'] r_list.append(r) x.append(N) r25.append(scoreatpercentile(r, 25)) r50.append(scoreatpercentile(r, 50)) r75.append(scoreatpercentile(r, 75)) fill_between(x, r25, r75, color='0.75') plot(x, r50, 'o-', color='black') xticks(range(1, 5)) xlabel("Minimum number of particles") ylabel("Core distance [m]") #title(r"$\theta = 22.5^\circ$") utils.saveplot() graph = GraphArtist() graph.shade_region(x, r25, r75) graph.plot(x, r50, linestyle=None) graph.set_xlabel("Minimum number of particles") graph.set_ylabel(r"Core distance [\si{\meter}]") graph.set_ylimits(min=0) graph.set_xticks(range(5)) artist.utils.save_graph(graph, dirname='plots')