Skip to content
Snippets Groups Projects
Commit a8582cc3 authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Update tests and moved test data to km3net-testdata project

parent ab57ca25
No related branches found
No related tags found
1 merge request!1Merge python environment
Pipeline #14471 failed
......@@ -69,8 +69,8 @@ def run_jobcard(jobcard, outdir, fluxfile=None):
if isinstance(jobcard, str) and isfile(jobcard):
jobcard = read_jobcard(jobcard)
if "neutrino_induced" in jobcard and jobcard["neutrino_induced"][
"nuexp"] == 99:
if "neutrino_induced" in jobcard and "nuexp" in jobcard[
"neutrino_induced"] and jobcard["neutrino_induced"]["nuexp"] == 99:
if fluxfile is None or not isfile(fluxfile):
raise IOError("Fluxfile not found!")
tmp_fluxfile = join(input_dir.name, basename(fluxfile))
......
# 1:Run 2:Event 3:ID 4:Charge 5:perweight 6:position(1) 7:position(2) 8:position(3) 9:momentum(0) 10:momentum(1) 11:momentum(2) 12:momentum(3) 13:history 14:production_ID 15:enu
1 1 901 -1 6.154773E-01 0.000000E+00 0.000000E+00 0.000000E+00 5.050394E-01 2.619802E-02 3.290991E-01 3.821936E-01 0 2 1.000000E+00
1 1 1 1 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 9.380000E-01 0.000000E+00 0.000000E+00 0.000000E+00 0 2 1.000000E+00
1 1 101 1 6.154773E-01 0.000000E+00 0.000000E+00 0.000000E+00 3.918515E-01 -1.150792E-01 2.178788E-02 3.475423E-01 1000002 2 1.000000E+00
1 1 1 1 6.154773E-01 0.000000E+00 0.000000E+00 0.000000E+00 1.041109E+00 8.888118E-02 -3.508870E-01 2.702641E-01 1000002 2 1.000000E+00
# 1:var 2:sum 3:QE 4:Delta 5:highRES 6:1pi 7:DIS 8:2p2h-QE 9:2p2h-Delta 10:2pi
1.0000 0.61548 0.0000 0.61537 0.10661E-03 0.0000 0.0000 0.0000 0.0000 0.0000
......@@ -15,47 +15,19 @@ import numpy as np
from km3buu.output import *
from os import listdir
from os.path import abspath, join, dirname
from km3net_testdata import data_path
TESTDATA_DIR = abspath(join(dirname(__file__), "../data/test-data/"))
TESTDATA_DIR = data_path("km3buu/gibuu_raw")
class TestXSection(unittest.TestCase):
def test_xsection_all(self):
filename = join(TESTDATA_DIR, XSECTION_FILENAMES["all"])
xsection = read_nu_abs_xsection(filename)
self.assertAlmostEqual(xsection['var'], 1.0)
self.assertAlmostEqual(xsection['sum'], 0.61548)
self.assertAlmostEqual(xsection['Delta'], 0.61537)
self.assertAlmostEqual(xsection['highRES'], 1.0661e-4)
self.assertAlmostEqual(xsection['Delta'], 0.61537)
class TestFinalEvents(unittest.TestCase):
def setUp(self):
self.filename = join(TESTDATA_DIR, EVENT_FILENAME)
self.final_events = FinalEvents(self.filename)
def test_values(self):
assert self.final_events[0]["id"] == 901
assert self.final_events[0]["charge"] == -1
self.assertAlmostEqual(self.final_events[0]["perweight"], 6.154773e-1)
self.assertAlmostEqual(self.final_events[0]["p_t"], 5.050394e-1)
self.assertAlmostEqual(self.final_events[0]["p_x"], 2.619802e-2)
self.assertAlmostEqual(self.final_events[0]["p_y"], 3.290991e-1)
self.assertAlmostEqual(self.final_events[0]["p_z"], 3.821936e-1)
self.assertAlmostEqual(self.final_events[0]["nu_energy"], 1.0)
assert self.final_events[3]["id"] == 1
assert self.final_events[3]["charge"] == 1
self.assertAlmostEqual(self.final_events[3]["perweight"], 6.154773e-1)
def test_index(self):
assert self.final_events[0] is not None
def test_slicing(self):
assert self.final_events[0:2] is not None
def test_length(self):
assert len(self.final_events) == 4
self.assertAlmostEqual(xsection['var'], 58.631)
self.assertAlmostEqual(xsection['sum'], 8.0929)
self.assertAlmostEqual(xsection['Delta'], 0.26805)
self.assertAlmostEqual(xsection['highRES'], 0.14248)
class TestGiBUUOutput(unittest.TestCase):
......@@ -63,4 +35,5 @@ class TestGiBUUOutput(unittest.TestCase):
self.output = GiBUUOutput(TESTDATA_DIR)
def test_attr(self):
assert hasattr(self.output, "events")
assert hasattr(self.output, "event_info_df")
assert hasattr(self.output, "particle_df")
......@@ -13,3 +13,4 @@ sphinxcontrib-websupport
sphinx-autoapi
setuptools_scm
yapf>=0.25
km3net-testdata
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment