import numpy as np
import sys
import pickle as pickle

from NuRadioMC.utilities.Veff import get_Veff_Aeff, get_Veff_Aeff_array

top_dir = '/data/user/brianclark/Gen2/simulation_output/secondaries_500km2/step3/surface_4LPDA_PA_15m_RNOG_300K_1.50km/config_Alv2009_noise_100ns/D09surface_4LPDA_pa_15m_250MHz/e'

data = get_Veff_Aeff(top_dir, n_cores=4)
output = open('thefile.pkl', 'wb')
pickle.dump(data, output)

Beispiel #2
0
import numpy as np
import sys

from NuRadioMC.utilities.Veff import get_Veff_Aeff, get_Veff_Aeff_array

if __name__ == "__main__":

	depth = ''
	if(len(sys.argv) == 4):
		print("no depth specified!")
		sys.exit()
	else:
		depth = sys.argv[1]

	top_dir='/data/user/brianclark/Gen2/test_out/'
	data = get_Veff_Aeff(top_dir+depth+'m/', n_cores=8)
	Veffs, energies, energies_low, energies_up, zenith_bins, utrigger_names = get_Veff_Aeff_array(data)
	np.savez('veffs_'+depth+'m.npz',Veffs=Veffs, energies=energies, energies_low=energies_low, energies_up=energies_up, zenith_bins=zenith_bins, utrigger_names=utrigger_names)

folder = args.folder
output_file = args.output_file
"""
The function get_Veff in utilities.Veff calculates effective volumes using the
path to a folder with NuRadioMC outputs as an argument. In this folder there
should be several files containing the simulation results for different energies,
although in our example we will only use one. There can also be several sets
of files for different zenith bands. get_Veff will return a dictionary with all
the information to calculate effective volumes for different energies and
zenith bands.

IMPORTANT: if the n_events_per_file argument has been used so that the NuRadioMC
files are split, the module utilities.merge_hdf5 should be used to merge the files.
Once every energy bin has a unique HDF5 output file, the Veff module can be run.
"""
data_Veff = get_Veff_Aeff(folder)
"""
Although data_Veff has all the information we need, it is a bit cumbersome
to read directly, so that's why we resort to the function get_Veff_array. This
function returns a 5-element tuple with:
- An 4-D array with the effective volumes
- A 1-D array with the centre energies for each bin (if point_bins=False)
- The zenith bins for each one of the zenith band simulations (in our case, we
only have a single zenith band equal to the whole sky)
- A list with the trigger names
- A 1-D array with the angular weights for each zenith band simulation. If the solid
angle for a simulation set is larger than for the other, it should carry more weight
when we try to patch them all together to get the total volumes.
"""
Veff_array, energies, energies_low, energies_high, zenith_bins, trigger_names = get_Veff_Aeff_array(
    data_Veff)
Beispiel #4
0
from NuRadioMC.utilities import fluxes
from NuRadioMC.utilities.Veff import get_Veff_Aeff, get_Veff_Aeff_array, get_index, get_Veff_water_equivalent
from NuRadioMC.examples.Sensitivities import E2_fluxes3 as limits
plt.switch_backend('agg')

if __name__ == "__main__":

    path = 'output'
    if (len(sys.argv) == 1):
        print(
            "no path specified, assuming that hdf5 files are in directory 'output'"
        )
    else:
        path = sys.argv[1]

    data = get_Veff_Aeff(path)
    Veffs, energies, energies_low, energies_up, zenith_bins, utrigger_names = get_Veff_Aeff_array(
        data)
    # calculate the average over all zenith angle bins (in this case only one bin that contains the full sky)
    Veff = np.average(Veffs[:, :,
                            get_index("all_triggers", utrigger_names), 0],
                      axis=1)
    # we also want the water equivalent effective volume times 4pi
    Veff = get_Veff_water_equivalent(Veff) * 4 * np.pi
    # calculate the uncertainty for the average over all zenith angle bins. The error relative error is just 1./sqrt(N)
    Veff_error = Veff / np.sum(
        Veffs[:, :, get_index("all_triggers", utrigger_names), 2], axis=1)**0.5
    # plot effective volume
    fig, ax = plt.subplots(1, 1, figsize=(6, 6))
    ax.errorbar(energies / units.eV,
                Veff / units.km**3 / units.sr,