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

Merge branch 'fix_w2_index_problem' into 'master'

w2 write problem

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