Skip to content

Commit

Permalink
Added metadata member for config exports
Browse files Browse the repository at this point in the history
  • Loading branch information
sgriswol committed Jan 12, 2024
1 parent b80db23 commit a7f0647
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/asteria/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ 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:

Expand All @@ -43,6 +48,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 +64,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 a7f0647

Please sign in to comment.