def test_icecube_load(): aeff = EffectiveArea.from_dataset(EffectiveArea.supported_datasets[0]) eres = EnergyResolution.from_dataset( EnergyResolution.supported_datasets[0]) ares = AngularResolution.from_dataset( AngularResolution.supported_datasets[0]) detector = IceCube(aeff, eres, ares)
def test_angular_resolution(): # Load ang_res = AngularResolution.from_dataset( "20181018", ret_ang_err_p=0.9, offset=0.4, ) # Sample ra = 0.0 # rad dec = np.pi / 4 # rad Etrue = 1e5 # GeV ang_res.sample(Etrue, (ra, dec)) # Return angular error assert ang_res.ret_ang_err == ang_res.get_ret_ang_err(Etrue)
index_to_sim = np.array( [1.8, 2.0, 2.19, 2.4, 2.6, 2.8]) #np.array([2.0, 2.19]) #np.linspace(1.8, 2.6, 10) output_file = FILE_STEM + 'output/sim/source_1e3_6_30_new_Emin5e2.h5' # Effective area Aeff_filename = FILE_STEM + 'input/IC86-2012-TabulatedAeff.txt' effective_area = EffectiveArea(Aeff_filename) # Energy resolution eres_file = FILE_STEM + 'input/effective_area.h5' energy_res = EnergyResolution(eres_file) # Angular resolution Ares_file = FILE_STEM + 'input/IC86-2012-AngRes.txt' ang_res = AngularResolution(Ares_file) # Detector detector = IceCube(effective_area, energy_res, ang_res) # Shared runs N_per_core = int(N / COMM.size) start_time = time.time() else: detector = None dec_to_sim = None index_to_sim = None N_per_core = None
def test_angres_load(): for dataset_id in AngularResolution.supported_datasets: _ = AngularResolution.from_dataset(dataset_id)
sim_reco_energy = f["reco_energy"][()] sim_index = f["source_0/index"][()] sim_dec = f["dec"][()] energy_likelihood = MarginalisedEnergyLikelihoodFromSim( sim_reco_energy, sim_dec, sim_index=sim_index, min_E=50, max_E=5e10) with h5py.File(sim_bg_file, "r") as f: sim_reco_energy = f["reco_energy"][()] bg_energy_likelihood = MarginalisedEnergyLikelihoodFixed(sim_reco_energy, min_E=50, max_E=5e10) # Direction likelihood angres_2 = AngularResolution(Ares_2_file) angres_a = AngularResolution(Ares_a_file) angres_list = [angres_2, angres_a] index_list = [2.0, 3.7] direction_likelihood = EnergyDependentSpatialGaussianLikelihood( angres_list, index_list) # Index prior index_prior = GaussianPrior(2.19, 0.1) # Events with h5py.File(sim_bg_file, "r") as f: energies = f["reco_energy"][()] ras = f["ra"][()] decs = f["dec"][()]
import numpy as np from pytest import approx from icecube_tools.detector.effective_area import EffectiveArea from icecube_tools.detector.energy_resolution import EnergyResolution from icecube_tools.detector.angular_resolution import AngularResolution from icecube_tools.detector.detector import IceCube from icecube_tools.source.flux_model import PowerLawFlux from icecube_tools.source.source_model import DiffuseSource, PointSource from icecube_tools.neutrino_calculator import NeutrinoCalculator, PhiSolver from icecube_tools.simulator import Simulator aeff = EffectiveArea.from_dataset("20181018") angres = AngularResolution.from_dataset("20181018") eres = EnergyResolution.from_dataset("20150820") detector = IceCube(aeff, eres, angres) pl_params = (1e-18, 1e5, 2.2, 1e4, 1e8) pl_flux = PowerLawFlux(*pl_params) point_source = PointSource(pl_flux, z=0.3) diffuse_source = DiffuseSource(pl_flux) sources = [point_source, diffuse_source] def test_nu_calc(): nu_calc = NeutrinoCalculator([point_source], aeff) Nnu = nu_calc( time=1, min_energy=1e4,