def end(self):
        fig, ax = plt.subplots(1, 1)
        mask = np.abs(self.__delta_azimuth) < (1 * units.deg)
        ax.scatter(np.array(self.__zenith)[mask] / units.deg, np.array(self.__delta_zenith)[mask] / units.deg, s=20)
        ax.set_xlabel("zenith angle (MC) [deg]")
        ax.set_ylabel("(zenith_rec - zenith_MC) [deg]")
        fig.tight_layout()
        fig.savefig("zenith_bias.png")

        from radiotools import plthelpers as php
        bins = np.arange(-10, 10, .1)
        fig, ax = php.get_histogram(np.array(self.__delta_azimuth) / units.deg, bins=bins, xlabel="delta azimuth [deg]")
        fig.savefig("azimuth.png")
        plt.show()
        pass
plt.savefig(os.path.join(plot_folder, "simInputVertex.png"))

# plot incoming direction
zeniths = np.array(zeniths)
azimuths = np.array(azimuths)
fig, axs = php.get_histograms(
    [zeniths / units.deg, azimuths / units.deg],
    bins=[np.arange(0, 181, 2), np.arange(0, 361, 5)],
    xlabels=['zenith [deg]', 'azimuth [deg]'],
    stats=False)
fig.suptitle('neutrino direction')
fig.subplots_adjust(top=0.9)

plt.savefig(os.path.join(plot_folder, "simInputIncoming.png"))

fig, ax = php.get_histogram(np.cos(zeniths),
                            bins=np.arange(-1, 1.01, 0.1),
                            xlabel="cos zenith")
plt.savefig(os.path.join(plot_folder, "simInputIncoming_coszenith.png"))
# plot inelasticity
inelasticity = np.array(inelasticity)
fig, axs = php.get_histogram(inelasticity,
                             bins=np.logspace(np.log10(0.0001), np.log10(1.0),
                                              50),
                             xlabel='inelasticity',
                             figsize=(6, 6),
                             stats=True)
axs.semilogx(True)
plt.title('inelasticity')
plt.savefig(os.path.join(plot_folder, "simInputInelasticity.png"))
Ejemplo n.º 3
0
        if(flav[i]):
            zeniths = np.append(zeniths, [zentemp[i]], axis=0)
            weightstemp = np.append(weightstemp, weights[i])

    
    if typ == 12:
        title = 'electron'
    elif typ == 14:
        title = 'muon'
    elif typ == 16:
        title = 'tau'
        
    zeniths = np.delete(zeniths, 0, axis=0)
    
    fig, ax = php.get_histogram(zeniths / units.deg, weights=weightstemp,
                                ylabel='weighted entries', xlabel='zenith angle [deg]',
                                bins=np.arange(0, 181, 5), figsize=(6, 6))
    ax.set_xticks(np.arange(0, 181, 45))
    ax.set_title(title)
    fig.tight_layout()
    
    fig.savefig(os.path.join(plot_folder, title + '_neutrino_direction.pdf'))

###########################
# calculate sky coverage of 90% quantile
###########################
from radiotools import stats
q2 =stats.quantile_1d(np.array(fin['zeniths'])[triggered], weights, 0.95)
q1 =stats.quantile_1d(np.array(fin['zeniths'])[triggered], weights, 0.05)
from scipy import integrate
def a(theta):
Ejemplo n.º 4
0
            for phi in np.linspace(0, 2 * np.pi, 200):

                l = hp.spherical_to_cartesian(theta, phi)

                #             zen, az = hp.cartesian_to_spherical(v[0], v[1], v[2])
                R1 = np.array([[np.cos(az), -np.sin(az), 0],
                               [np.sin(az), np.cos(az), 0], [0, 0, 1]])
                R2 = np.array([[np.cos(zen), 0, -np.sin(zen)], [0, 1, 0],
                               [np.sin(zen), 0, np.cos(zen)]])
                #             l2 = np.matmul(R1, np.matmul(R2,l))
                l2 = np.matmul(R3, l)
                #             l2 = np.matmul(R2, np.matmul(R1, l))
                l2 *= 400
                #                 print(hp.get_angle(v, l2)/units.deg)
                l2 += vertex
                ax.plot3D([vertex[0], l2[0]], [vertex[1], l2[1]],
                          [vertex[2], l2[2]],
                          'C3-',
                          alpha=0.2)
    if (plot):
        ax.legend()
        #     ax.set_aspect('equal')
        ax.set_xlabel("x [m]")
        ax.set_ylabel("y [m]")
        ax.set_zlabel("z [m]")
        #     plt.ion()
        plt.show()
#     a =     1/0
php.get_histogram(np.array(dTs))
plt.show()
Ejemplo n.º 5
0
    dZ = fin.attrs['zmax'] - fin.attrs['zmin']
    V = dX * dY * dZ
elif('rmin' in fin.attrs):
    rmin = fin.attrs['rmin']
    rmax = fin.attrs['rmax']
    dZ = fin.attrs['zmax'] - fin.attrs['zmin']
    V = np.pi * (rmax**2 - rmin**2) * dZ
Veff = V * density_ice / density_water * 4 * np.pi * np.sum(weights) / n_events
print("Veff = {:.6g} km^3 sr".format(Veff / units.km ** 3))


###########################
# plot neutrino direction
###########################
fig, ax = php.get_histogram(np.array(fin['zeniths'])[triggered] / units.deg, weights=weights,
                            ylabel='weighted entries', xlabel='zenith angle [deg]',
                            bins=np.arange(0, 181, 5), figsize=(6, 6))
ax.set_xticks(np.arange(0, 181, 45))
ax.set_title(trigger_name)
fig.tight_layout()
fig.savefig(os.path.join(plot_folder, 'neutrino_direction.png'))

czen = np.cos(np.array(fin['zeniths'])[triggered])
bins = np.linspace(-1, 1, 21)
fig, ax = php.get_histogram(czen, weights=weights,
                            ylabel='weighted entries', xlabel='cos(zenith angle)',
                            bins=bins, figsize=(6, 6))
# ax.set_xticks(np.arange(0, 181, 45))
ax.set_title(trigger_name)
fig.tight_layout()
fig.savefig(os.path.join(plot_folder, 'neutrino_direction_cos.png'))