def __load_cr_template(self, station_id): path = os.path.join( self.__path, 'templates_cr_station_{}.pickle'.format(station_id)) if (os.path.exists(path)): self.__cr_templates[station_id] = read_pickle(path) zen_ref = np.deg2rad(60) az_ref = np.deg2rad(0) self.__ref_cr_templates[station_id] = self.__cr_templates[ station_id][0][zen_ref][az_ref] else: self.logger.error("template file {} not found".format(path)) raise IOError
def __init__(self, seed=1234, library=None): logger.warning("setting seed to {}".format(seed)) self._random_generator = np.random.RandomState(seed) self._random_numbers = {} self._version = (1, 1) # # load shower library into memory if(library is None): library = os.path.join(os.path.dirname(__file__), "shower_library/ARZ_library_v{:d}.{:d}.pkl".format(*self._version)) else: if(not os.path.exists(library)): logger.error("user specified pulse library {} not found.".format(library)) raise FileNotFoundError("user specified pulse library {} not found.".format(library)) self.__check_and_get_library() logger.warning("loading pulse library into memory") self._library = io_utilities.read_pickle(library)
def __init__(self, seed=1234, interp_factor=1, interp_factor2=100, library=None, arz_version='ARZ2020'): logger.warning("setting seed to {}".format(seed, interp_factor)) self._random_generator = np.random.RandomState(seed) self._interp_factor = interp_factor self._interp_factor2 = interp_factor2 self._random_numbers = {} self._version = (1, 2) # # load shower library into memory if(library is None): library = os.path.join(os.path.dirname(__file__), "shower_library/library_v{:d}.{:d}.pkl".format(*self._version)) else: if(not os.path.exists(library)): logger.error("user specified shower library {} not found.".format(library)) raise FileNotFoundError("user specified shower library {} not found.".format(library)) self.__check_and_get_library() self.__set_model_parameters(arz_version) logger.warning("loading shower library ({}) into memory".format(library)) self._library = io_utilities.read_pickle(library)
rr = np.random.triangular(rmin, rmax, rmax, n_events) phiphi = np.random.uniform(0, 2 * np.pi, n_events) xx = rr * np.cos(phiphi) yy = rr * np.sin(phiphi) zz = np.random.uniform(zmin, zmax, n_events) points = np.array([xx, yy, zz]).T x_receiver = np.array([0., 0., -5.]) results_C0s_cpp = np.zeros((n_events, 10)) n_freqs = 256 // 2 + 1 # n_freqs = 5 results_A_cpp = np.zeros((n_events, 2, n_freqs)) t_start = time.time() ff = np.linspace(0, 500 * units.MHz, n_freqs) # tt = 0 for iX, x in enumerate(points): # t_start2 = time.time() r = ray.ray_tracing(x, x_receiver, ice, n_reflections=2) # tt += (time.time() - t_start2) r.find_solutions() if (r.has_solution()): for iS in range(r.get_number_of_solutions()): results_C0s_cpp[iX, iS] = r.get_results()[iS]['C0'] results_C0s_cpp_ref = io_utilities.read_pickle("reference_C0_MooresBay.pkl", encoding='latin1') testing.assert_allclose(results_C0s_cpp, results_C0s_cpp_ref, rtol=1.e-6) print('T06unit_test_C0_mooresbay passed without issues')
from __future__ import absolute_import, division, print_function, unicode_literals import matplotlib.pyplot as plt import logging logging.basicConfig(level=logging.WARNING) import numpy as np from scipy import signal import argparse from datetime import datetime from NuRadioReco.utilities import units, io_utilities from radiotools import plthelpers as php plt.switch_backend('agg') i = 2 results = io_utilities.read_pickle("sim_results_{:02d}.pkl".format(i), encoding='latin1') d = results['depth'] zen = np.array(results['exp'])[:, 0] az = np.array(results['exp'])[:, 1] fig, (ax, ax2) = plt.subplots(2, 1, sharex=True) ax.scatter(d, (np.array(results['corr_LPDA'])[:, 0] - zen) / units.deg, label='corr LPDA', s=10, marker='o', alpha=0.5) ax.scatter(d, (np.array(results['corr_dipole'])[:, 0] - zen) / units.deg, label='corr dipole', s=10, marker='d', alpha=0.5) # ax.scatter(d, (np.array(results['time_LPDA'])[:, 0] - zen) / units.deg, label='times LPDA', # s=10, marker='^', alpha=0.5) # ax.scatter(d, (np.array(results['time_dipole'])[:, 0] - zen) / units.deg, label='times dipole', # s=10, marker='x', alpha=0.5) ax.set_ylabel("zenith (reco - exp) [deg]") ax.legend()
n_index = 1.78 domega = 0.05 * units.deg theta = np.arccos(1. / n_index) + domega dt = 0.5 * units.ns n_samples = 256 R = 1 * units.km models = ['Alvarez2009', 'ARZ2019', 'Alvarez2000', 'ARZ2020'] shower_types = ['EM', 'HAD'] Es = 10**np.linspace(15, 19, 5) * units.eV domegas = np.linspace(-5, 5, 10) * units.deg thetas = np.arccos(1. / n_index) + domegas reference = io_utilities.read_pickle(reference_file, encoding='latin1') i = -1 for model in models: print(f"testing model {model}") for E in Es: print(f"testing energy {E}") for shower_type in shower_types: print(f"testing shower type {shower_type}") for theta in thetas: print(f"testing theta {theta/units.deg} deg") i += 1 trace = get_time_trace(E, theta, n_samples, dt, shower_type,
import numpy as np from NuRadioReco.utilities import units from NuRadioReco.utilities import io_utilities import os from scipy import interpolate as intp import glob import sys from matplotlib import pyplot as plt if __name__ == "__main__": library_path = sys.argv[1] lib = io_utilities.read_pickle(library_path) f, ax = plt.subplots(1, len(lib), sharey=True) for iS, shower_type in enumerate(lib): b = [] nb = [] for E in lib[shower_type]: nE = len(lib[shower_type][E]['charge_excess']) b.append(E) nb.append(nE) ax[iS].bar(np.log10(b), nE, linewidth=1, edgecolor='k', width=0.05) ax[iS].set_xlabel("log10(shower energy [eV])") ax[iS].set_title(shower_type) ax[0].set_ylabel('number of showers') f.tight_layout() plt.show()
import numpy as np from numpy import testing np.random.seed(0) n_index = 1.78 domega = 0.05 * units.deg theta = np.arccos(1. / n_index) + domega dt = 0.5 * units.ns n_samples = 256 R = 1 * units.km models = ['Alvarez2009', 'ARZ2019', 'Alvarez2000'] shower_types = ['EM', 'HAD'] Es = 10**np.linspace(15, 19, 5) * units.eV domegas = np.linspace(-5, 5, 10) * units.deg thetas = np.arccos(1. / n_index) + domegas reference = io_utilities.read_pickle("reference_v1.pkl") i = -1 for model in models: for E in Es: for shower_type in shower_types: for theta in thetas: i += 1 trace = get_time_trace(E, theta, n_samples, dt, shower_type, n_index, R, model) testing.assert_almost_equal(trace, reference[i])