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 plot_full_spectrum_fit_in_density_range(self, sel, popt, low, high): bins = np.linspace(0, RANGE_MAX, N_BINS + 1) n, bins = np.histogram(sel, bins=bins) x = (bins[:-1] + bins[1:]) / 2 p_gamma, p_landau = self.constrained_full_spectrum_fit( x, n, popt[:2], popt[2:]) plt.figure() plt.plot(x * VNS, n, label='data') self.plot_landau_and_gamma(x, p_gamma, p_landau) y_charged = self.calc_charged_spectrum(x, n, p_gamma, p_landau) plt.plot(x * VNS, y_charged, label='charged particles') plt.yscale('log') plt.xlim(0, 50) plt.ylim(ymin=1) plt.xlabel("Pulse integral [V ns]") plt.ylabel("Count") plt.legend() suffix = '%.1f-%.1f' % (low, high) suffix = suffix.replace('.', '_') utils.saveplot(suffix) n = np.where(n > 0, n, 1e-99) y_charged = np.where(y_charged > 0, y_charged, 1e-99) graph = GraphArtist('semilogy') graph.histogram(n, bins * VNS, linestyle='gray') self.artistplot_alt_landau_and_gamma(graph, x, p_gamma, p_landau) graph.histogram(y_charged, bins * VNS) graph.set_xlabel(r"Pulse integral [\si{\volt\nano\second}]") graph.set_ylabel("Count") graph.set_title( r"$\SI{%.1f}{\per\square\meter} \leq \rho_\mathrm{charged}$ < $\SI{%.1f}{\per\square\meter}$" % (low, high)) graph.set_xlimits(0, 30) graph.set_ylimits(1e0, 1e4) artist.utils.save_graph(graph, suffix, 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 plot_full_spectrum_fit_in_density_range(self, sel, popt, low, high): bins = np.linspace(0, RANGE_MAX, N_BINS + 1) n, bins = np.histogram(sel, bins=bins) x = (bins[:-1] + bins[1:]) / 2 p_gamma, p_landau = self.constrained_full_spectrum_fit(x, n, popt[:2], popt[2:]) plt.figure() plt.plot(x * VNS, n, label="data") self.plot_landau_and_gamma(x, p_gamma, p_landau) y_charged = self.calc_charged_spectrum(x, n, p_gamma, p_landau) plt.plot(x * VNS, y_charged, label="charged particles") plt.yscale("log") plt.xlim(0, 50) plt.ylim(ymin=1) plt.xlabel("Pulse integral [V ns]") plt.ylabel("Count") plt.legend() suffix = "%.1f-%.1f" % (low, high) suffix = suffix.replace(".", "_") utils.saveplot(suffix) n = np.where(n > 0, n, 1e-99) y_charged = np.where(y_charged > 0, y_charged, 1e-99) graph = GraphArtist("semilogy") graph.histogram(n, bins * VNS, linestyle="gray") self.artistplot_alt_landau_and_gamma(graph, x, p_gamma, p_landau) graph.histogram(y_charged, bins * VNS) graph.set_xlabel(r"Pulse integral [\si{\volt\nano\second}]") graph.set_ylabel("Count") graph.set_title( r"$\SI{%.1f}{\per\square\meter} \leq \rho_\mathrm{charged}$ < $\SI{%.1f}{\per\square\meter}$" % (low, high) ) graph.set_xlimits(0, 30) graph.set_ylimits(1e0, 1e4) artist.utils.save_graph(graph, suffix, dirname="plots")