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

Merge branch 'randomseed' into 'master'

Random Generator Seed

See merge request !13
parents 159590d2 6bd94feb
No related branches found
No related tags found
1 merge request!13Random Generator Seed
Pipeline #22417 passed with warnings
...@@ -104,6 +104,7 @@ def generate_neutrino_jobcard(events, ...@@ -104,6 +104,7 @@ def generate_neutrino_jobcard(events,
do_decay=False, do_decay=False,
photon_propagation=True, photon_propagation=True,
fluxfile=None, fluxfile=None,
seed=0,
input_path=INPUT_PATH): # pragma: no cover input_path=INPUT_PATH): # pragma: no cover
""" """
Generate a jobcard for neutrino interaction Generate a jobcard for neutrino interaction
...@@ -130,6 +131,9 @@ def generate_neutrino_jobcard(events, ...@@ -130,6 +131,9 @@ def generate_neutrino_jobcard(events,
Propagate photons and write it out Propagate photons and write it out
fluxfile: str (default: None) fluxfile: str (default: None)
Fluxfile, 1st col energy [GeV] and 2nd col flux [A.U.] Fluxfile, 1st col energy [GeV] and 2nd col flux [A.U.]
seed: int (default: 0)
Input seed for the random number generator in GiBUU
(0: some seed will be drawn based on system time)
input_path: str input_path: str
The input path pointing to the GiBUU lookup data which should be used The input path pointing to the GiBUU lookup data which should be used
""" """
...@@ -175,6 +179,7 @@ def generate_neutrino_jobcard(events, ...@@ -175,6 +179,7 @@ def generate_neutrino_jobcard(events,
jc["eventoutput"]["writeperturbativeparticles"] = write_pert jc["eventoutput"]["writeperturbativeparticles"] = write_pert
jc["eventoutput"]["writerealparticles"] = write_real jc["eventoutput"]["writerealparticles"] = write_real
# MISC # MISC
jc["initRandom"]["Seed"] = seed
jc["insertion"]["propagateNoPhoton"] = not photon_propagation jc["insertion"]["propagateNoPhoton"] = not photon_propagation
return jc return jc
...@@ -12,8 +12,11 @@ __status__ = "Development" ...@@ -12,8 +12,11 @@ __status__ = "Development"
import unittest import unittest
import numpy as np import numpy as np
from itertools import combinations
from km3buu.jobcard import * from km3buu.jobcard import *
from tempfile import TemporaryFile from km3buu.ctrl import run_jobcard
from km3buu.output import GiBUUOutput
from tempfile import TemporaryFile, TemporaryDirectory
class TestJobcard(unittest.TestCase): class TestJobcard(unittest.TestCase):
...@@ -127,3 +130,22 @@ class TestNeutrinoSingleEnergyJobcard(unittest.TestCase): ...@@ -127,3 +130,22 @@ class TestNeutrinoSingleEnergyJobcard(unittest.TestCase):
def test_photon_propagation_flag(self): def test_photon_propagation_flag(self):
self.assertEqual(self.test_jobcard["insertion"]["propagateNoPhoton"], self.assertEqual(self.test_jobcard["insertion"]["propagateNoPhoton"],
not self.photon_propagation_flag) not self.photon_propagation_flag)
class TestJobcardSeed(unittest.TestCase):
def setUp(self):
jc = generate_neutrino_jobcard(100,
"CC",
"electron", (1.0, 2.0), (1, 1),
do_decay=False,
photon_propagation=False,
seed=1234)
self.dfs = []
for i in range(2):
output_dir = TemporaryDirectory()
run_jobcard(jc, output_dir.name, container=True)
self.dfs.append(GiBUUOutput(output_dir.name).df)
def test_output(self):
for a, b in combinations(self.dfs, 2):
assert all((a == b).all(1))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment