Пример #1
0
def downsize(filename, destination):
    if os.path.exists(destination):
        print("Already done! Skipping {}".format(destination))
        return

    dataobj = Data(filename)

    flux = {}
    for key in dataobj.get_keys():
        flux[key] = np.zeros(shape=(Ebin, zbin))
        for i_e in range(Ebin):
            for i_z in range(zbin):
                flux[key][i_e][i_z] = dataobj.get_flux( energies[i_e], key=key, angle=zeniths[i_z])

    # okay now we pickle 
    all_data = {}
    all_data["e_true"] = energies
    all_data["a_true"] = zeniths
    all_data["flux"] = flux
    f = open(destination, 'wb')
    pickle.dump(all_data, f, -1)
    f.close()
    print("Saved {}".format(destination))
filename = "effective_area.nu_mu.txt"
area_data = quickload(
    os.path.join(
        os.path.join(config["datapath"], "charm_search_supplemental/"),
        filename))
e_edges = np.array(area_data["e_reco"])
a_edges = np.array(area_data["cos_th"])

e_centers = 0.5 * (e_edges[:-1] + e_edges[1:])
a_centers = 0.5 * (a_edges[:-1] + a_edges[1:])

# get the flux in the centers of each of the bins
null_flux = np.zeros(shape=(len(e_centers), len(a_centers)))
ster_flux = np.zeros(shape=(len(e_centers), len(a_centers)))
keys = ["Mu_nu_CC", "Mu_nuBar_CC"]

for i_e in range(len(e_centers)):
    for i_a in range(len(a_centers)):
        for key in keys:
            null_flux[i_e][i_a] = null_flux[i_e][i_a] + null.get_flux(
                e_centers[i_e] * (1e9), key, angle=a_centers[i_a])
            ster_flux[i_e][i_a] = ster_flux[i_e][i_a] + ster.get_flux(
                e_centers[i_e] * (1e9), key, angle=a_centers[i_a])

plt.pcolormesh(a_edges, e_edges, ster_flux / null_flux)
plt.colorbar()
plt.xlabel("Cos theta")
plt.ylabel("Energy")
plt.yscale('log')
plt.show()
Пример #3
0
#sterile_flux = np.zeros(shape=np.shape(sterile_dat._fluxes[key_list[0]]))

null_flux = np.zeros(shape=(n_bin, n_bin + 1))
sterile_flux = np.zeros(shape=(n_bin, n_bin + 1))

for key in key_list:
    for i in range(len(energies)):
        for j in range(len(angles)):

            energy = energies[i]
            angle = angles[j]

            #            null_flux[i][j] += null_dat._fluxes[key][i][j]
            #            sterile_flux[i][j] += sterile_dat._fluxes[key][i][j]

            null_flux[i][j] += null_dat.get_flux(energy, key, angle=angle)
            sterile_flux[i][j] += sterile_dat.get_flux(energy,
                                                       key,
                                                       angle=angle)

cf = plt.pcolormesh(angles,
                    energies / (1e9),
                    np.log10(null_flux * livetime),
                    cmap=cm.viridis)
plt.yscale('log')
plt.ylabel("True Energy [GeV]", size=14)
plt.xlabel(r"True $\cos\theta$", size=14)
cbar = plt.colorbar()
cbar.set_label("log( Null Flux )")
plt.savefig("null_flux_plot.png", dpi=400)
plt.show()
Пример #4
0
curr = "CC"  # doesn't matter
neut = "nuBar"
root_flav = "Mu"
flavors = ['E', 'Mu', 'Tau']
# flavor neutrino current
keys = ["_".join([flav, neut, curr]) for flav in flavors]

core_b = -0.98
mantle_b = -0.83

energies = np.logspace(2, 7, 200)
angles = np.linspace(-1, 0.2, 100)

this_key = "Mu_nuBar_CC"
flux = [[
    final_probs.get_flux(energy * (1e9), this_key, angle=angle)
    for angle in angles
] for energy in energies]
plt.figure(figsize=(7, 5))
mesh = plt.pcolormesh(angles, energies, flux, cmap=colorscale, vmin=0, vmax=1)
cbar = plt.colorbar(mesh)
cbar.set_label(r"$P(\bar{\nu}_{\mu}\to\bar{\nu}_{\mu})$")
plt.xlim([-1, 0.2])
plt.ylim([1e2, 1e6])
plt.yscale('log')
plt.ylabel(r"$E_{\nu}^{true}$ [GeV]")
plt.xlabel(r"$\cos\theta_{z}^{true}$")
plt.vlines(core_b, ymin=1e2, ymax=10**6, colors="white", ls="-")
plt.text(core_b + 0.02,
         1.5e2,
         "Inner/Outer Core Bdr",