Skip to content

Commit

Permalink
Merge pull request #101 from icecube/pprint_config
Browse files Browse the repository at this point in the history
Pprint config
  • Loading branch information
sgriswol authored Jan 12, 2024
2 parents b80db23 + a3056fa commit 05969ba
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/asteria/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ class Simulation:
def __init__(self, config=None, *, model=None, distance=10 * u.kpc, res_dt=2 * u.ms, flavors=None, hierarchy=None,
interactions=Interactions, mixing_scheme=None, mixing_angle=None, E=None, Emin=None, Emax=None,
dE=None, t=None, tmin=None, tmax=None, dt=None, geomfile=None, effvolfile=None):
self.metadata = {key: str(val) for key, val in locals().items() if
val is not None and
key not in ['self', 'E', 't']}
self.metadata.update({'interactions': ', '.join([item.name for item in interactions])})

self.param = {}
if model and not config:

self.metadata.update({'model': {'name': model['name'],
'param': '; '.join([f"{key}, {val}" for key, val in model['param'].items()])}
})
if not E and None in (Emin, Emax, dE):
raise ValueError("Missing or incomplete energy range definition. Use argument `E` or "
"arguments `Emin`, `Emax`, `dE")
Expand All @@ -43,6 +51,7 @@ def __init__(self, config=None, *, model=None, distance=10 * u.kpc, res_dt=2 * u
E = np.arange(_Emin, _Emax + _dE, _dE) * u.MeV
elif not E:
E = np.arange(0, 100, 1) * u.MeV
self.metadata.update({'Emin': 0 * u.MeV, 'Emax': 100 * u.MeV, 'dE': 1 * u.ms})

if not t and None in (tmin, tmax, dt):
raise ValueError("Missing or incomplete energy range definition. Use argument `t` or "
Expand All @@ -58,6 +67,7 @@ def __init__(self, config=None, *, model=None, distance=10 * u.kpc, res_dt=2 * u
else:
t = np.arange(-1, 1, 0.001) * u.s
_dt = 1 * u.ms
self.metadata.update({'tmin': -1 * u.s, 'tmax': 1 * u.s, 'dt': 1 * u.ms})

self.source = Source(model['name'], model['param'])
self.distance = distance
Expand Down

0 comments on commit 05969ba

Please sign in to comment.