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

w2 write problem

parent 596bafd7
No related branches found
No related tags found
1 merge request!36w2 write problem
......@@ -276,6 +276,7 @@ def read_nu_abs_xsection(filepath):
class GiBUUOutput:
def __init__(self, data_dir):
"""
Class for parsing GiBUU output files
......@@ -352,7 +353,13 @@ class GiBUUOutput:
def _read_flux_file(self):
fpath = join(self._data_path, FLUXDESCR_FILENAME)
self.flux_data = np.loadtxt(fpath, dtype=FLUX_INFORMATION_DTYPE)
self.flux_data = np.loadtxt(fpath,
dtype=FLUX_INFORMATION_DTYPE,
usecols=(
0,
1,
2,
))
self.flux_interpolation = UnivariateSpline(self.flux_data["energy"],
self.flux_data["events"])
self._energy_min = np.min(self.flux_data["energy"])
......@@ -594,6 +601,7 @@ class GiBUUOutput:
return self._generated_events
def _determine_flux_index(self):
def fluxfunc(x, a, b):
return a * x**b
......@@ -709,8 +717,8 @@ def write_detector_file(gibuu_output,
header_dct = EMPTY_KM3NET_HEADER_DICT.copy()
header_dct["target"] = element.name
for k,v in geometry.header_entries(gibuu_output._generated_events //
no_files).items():
for k, v in geometry.header_entries(gibuu_output._generated_events //
no_files).items():
header_dct[k] = v
header_dct["coord_origin"] = "{} {} {}".format(*geometry.coord_origin)
header_dct["flux"] = "{:d} 0 0".format(nu_type)
......@@ -750,7 +758,7 @@ def write_detector_file(gibuu_output,
evt.mc_run_id = mc_event_id
# Weights
evt.w.push_back(geometry.volume) #w1 (can volume)
evt.w.push_back(w2[mc_event_id]) #w2
evt.w.push_back(w2[start_id + mc_event_id]) #w2
evt.w.push_back(-1.0) #w3 (= w2*flux)
# Event Information (w2list)
evt.w2list.resize(W2LIST_LENGTH)
......
......@@ -32,6 +32,7 @@ path=/tmp/gseagen
class TestConfig(unittest.TestCase):
def setUp(self):
self.cfg_tmpfile = NamedTemporaryFile(delete=False)
self.mock_image_file = NamedTemporaryFile(delete=False)
......
......@@ -29,6 +29,7 @@ GIBUU_INSTALL_AVAILABLE = environ.get("CONTAINER_GIBUU_EXEC") is not None
@pytest.mark.skipif(not GIBUU_INSTALL_AVAILABLE, reason="GiBUU not installed")
class TestCTRLbyJobcardFile(unittest.TestCase):
def setUp(self):
self.filename = join(TESTDATA_DIR, "km3net_testdata.job")
self.output_dir = TemporaryDirectory()
......@@ -53,6 +54,7 @@ class TestCTRLbyJobcardFile(unittest.TestCase):
@pytest.mark.skipif(not GIBUU_INSTALL_AVAILABLE, reason="GiBUU not installed")
class TestCTRLbyJobcardObject(unittest.TestCase):
def setUp(self):
log = get_logger("ctrl.py")
log.setLevel("INFO")
......
......@@ -19,6 +19,7 @@ from km3buu import DOCKER_URL, IMAGE_NAME
class TestBuild(unittest.TestCase):
def test_wrong_dir_path(self):
wrong_path = "foobar"
try:
......
......@@ -26,6 +26,7 @@ if GIBUU_INSTALL_AVAILABLE:
class TestJobcard(unittest.TestCase):
def setUp(self):
self.test_jobcard = Jobcard()
# Insert some test elements
......@@ -55,6 +56,7 @@ class TestJobcard(unittest.TestCase):
class TestNeutrinoEnergyRangeJobcard(unittest.TestCase):
def setUp(self):
self.test_fluxfile = TemporaryFile()
self.test_Z = np.random.randint(1, 100)
......@@ -105,6 +107,7 @@ class TestNeutrinoEnergyRangeJobcard(unittest.TestCase):
class TestNeutrinoSingleEnergyJobcard(unittest.TestCase):
def setUp(self):
self.test_fluxfile = TemporaryFile()
self.test_Z = np.random.randint(1, 100)
......@@ -140,6 +143,7 @@ class TestNeutrinoSingleEnergyJobcard(unittest.TestCase):
@pytest.mark.skipif(not GIBUU_INSTALL_AVAILABLE, reason="GiBUU not installed")
class TestJobcardSeed(unittest.TestCase):
def setUp(self):
jc = generate_neutrino_jobcard(100,
"CC",
......
......@@ -37,6 +37,7 @@ except ModuleNotFoundError:
class TestXSection(unittest.TestCase):
def test_xsection_all(self):
filename = join(TESTDATA_DIR, XSECTION_FILENAMES["all"])
xsection = read_nu_abs_xsection(filename)
......@@ -47,6 +48,7 @@ class TestXSection(unittest.TestCase):
class TestGiBUUOutput(unittest.TestCase):
def setup_class(self):
self.output = GiBUUOutput(TESTDATA_DIR)
......@@ -91,6 +93,7 @@ class TestGiBUUOutput(unittest.TestCase):
@pytest.mark.skipif(not KM3NET_LIB_AVAILABLE,
reason="KM3NeT dataformat required")
class TestOfflineFile(unittest.TestCase):
def setUp(self):
output = GiBUUOutput(TESTDATA_DIR)
datafile = NamedTemporaryFile(suffix=".root")
......@@ -145,6 +148,7 @@ class TestOfflineFile(unittest.TestCase):
@pytest.mark.skipif(not KM3NET_LIB_AVAILABLE,
reason="KM3NeT dataformat required")
class TestMultiFileOutput(unittest.TestCase):
def setUp(self):
output = GiBUUOutput(TESTDATA_DIR)
datafile = NamedTemporaryFile(suffix=".root")
......
......@@ -28,6 +28,7 @@ MUON_TESTFILE = join(dirname(__file__), "data/muon_range_seawater.txt")
class TestMuonRangeSeaWater(unittest.TestCase):
def setUp(self):
self.ref_values = np.loadtxt(MUON_TESTFILE).T
......@@ -39,6 +40,7 @@ class TestMuonRangeSeaWater(unittest.TestCase):
class TestVisEnergyParticle(unittest.TestCase):
def setUp(self):
with open(PARTICLE_TESTFILE, "r") as f:
tmp = f.readline()
......@@ -57,6 +59,7 @@ class TestVisEnergyParticle(unittest.TestCase):
class TestVisEnergyWeightFunctions(unittest.TestCase):
def setUp(self):
self.ref_values = np.loadtxt(FUNCTIONS_TESTFILE).T
......
......@@ -28,6 +28,7 @@ pp.RandomGenerator.get().set_seed(1234)
@pytest.mark.skip(reason="CI boost lib problem")
class TestTauPropagation(unittest.TestCase):
def setUp(self):
data = ak.Array({
"lepOut_E": [
......
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