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

Merge branch 'python' of git.km3net.de:simulation/km3buu into python

parents 1eff21fa 10ff31b7
No related branches found
No related tags found
1 merge request!1Merge python environment
Pipeline #11177 failed
......@@ -20,21 +20,29 @@ from os import listdir
from os.path import isfile, join, abspath
from tempfile import TemporaryDirectory
from .jobcard import Jobcard
EVENT_FILENAME = "FinalEvents.dat"
XSECTION_FILENAMES = {"all": "neutrino_absorption_cross_section_ALL.dat"}
class NeutrinoAbsorptionXSection:
def __init__(self, filepath):
self._filepath = filepath
with open(self._filepath, "r") as f:
lines = f.readlines()
header = re.sub(r'\d+:|#', '', lines[0]).split()
values = map(float, lines[1].split())
self._xsections = dict(zip(header, values))
def read_nu_abs_xsection(filepath):
"""
Read the crosssections calculated by GiBUU
Parameters
----------
filepath: str
Filepath to the GiBUU output file with neutrino absorption cross-section
(neutrino_absorption_cross_section_*.dat)
def __getitem__(self, key):
return self._xsections[key]
"""
with open(filepath, "r") as f:
lines = f.readlines()
header = re.sub(r'\d+:|#', '', lines[0]).split()
dt = np.dtype([(field, np.float64) for field in header])
values = np.genfromtxt(StringIO(lines[-1]), dtype=dt)
return values
class FinalEvents:
......@@ -113,5 +121,17 @@ class GiBUUOutput:
if XSECTION_FILENAMES["all"] in self.output_files:
setattr(
self, "xsection",
NeutrinoAbsorptionXSection(
read_nu_abs_xsection(
join(self._data_path, XSECTION_FILENAMES["all"])))
self._jobcard = None
def associate_jobcard(self, jobcard):
"""
Append a jobcard to the wrapped output directory
Parameters
----------
jobcard: Jobcard
Jobcard object instance
"""
self._jobcard = jobcard
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