Commit c9967b83 authored by Marcus Wirtz's avatar Marcus Wirtz
Browse files

[simulations] Adapt library path to new convention

parent c64b371d
Pipeline #340835 failed with stages
in 3 minutes and 25 seconds
......@@ -546,7 +546,7 @@ class SourceBound(BaseSimulation):
self.crs['sources'] = self.universe.sources
self.crs['source_density'] = source_density
def attenuate(self, library_path=PATH+'/simulation/crpropa3__emin_18.5__emax_21.0.npz', inside_fraction=None):
def attenuate(self, library_path=None, inside_fraction=None):
"""
Apply attenuation for far away sources based on CRPropa simulations
......@@ -604,6 +604,8 @@ class SourceBound(BaseSimulation):
if (self.energy_setting is None) or (self.charge_weights is None):
raise Exception("You have to define energies and charges before (set_energy() and set_charges())!")
if library_path is None:
library_path = PATH + '/simulation/crpropa3__emin_18.5__emax_21.0__IRB_Gilmore12.npz'
data = np.load(library_path, allow_pickle=True)
self.dis_bins, self.log10e_bins = data['distances'], data['log10e_bins']
if np.median(np.min(self.universe.distances, axis=1)) < np.min(self.dis_bins):
......
......@@ -455,7 +455,7 @@ class TestReweight(unittest.TestCase):
def setUp(self):
self.charge = {'h': 1, 'he': 2, 'n': 7, 'si': 14, 'fe': 26}
data = np.load(PATH+'/simulation/crpropa3__emin_18.5__emax_21.npz', allow_pickle=True)
data = np.load(PATH+'/simulation/crpropa3__emin_18.5__emax_21.0__IRB_Gilmore12.npz', allow_pickle=True)
self.fractions = data['fractions'].item()
self.log10e_bins = data['log10e_bins']
self.distances = data['distances']
......@@ -472,5 +472,6 @@ class TestReweight(unittest.TestCase):
frac = self.fractions[key]
self.assertTrue(np.sum(frac[i][:, :, self.log10e_bins[:-1] > lge]) == 0.)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment