Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow scalar input for 't', 'E' and 'data' arguments of Container class #301

Merged
merged 6 commits into from
Feb 13, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions python/snewpy/flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ def __init__(self,
data: :class:`astropy.Quantity`
3D array of the stored quantity, must have dimensions compatible with (flavor, time, energy)

flavor: list of :class:`snewpy.neutrino.Flavor`
flavor: list or a single value of :class:`snewpy.neutrino.Flavor`
array of flavors (should be ``len(flavor)==data.shape[0]``

time: array of :class:`astropy.Quantity`
time: :class:`astropy.Quantity`
sampling points in time (then ``len(time)==data.shape[1]``)
or time bin edges (then ``len(time)==data.shape[1]+1``)

energy: array of :class:`astropy.Quantity`
energy: :class:`astropy.Quantity`
sampling points in energy (then ``len(energy)=data.shape[2]``)
or energy bin edges (then ``len(energy)=data.shape[2]+1``)

Expand All @@ -119,10 +119,11 @@ def __init__(self,
if self.unit is not None:
#try to convert to the unit
data = data.to(self.unit)
self.array = data
self.flavor = np.sort(flavor)
self.time = time
self.energy = energy
#convert the input values to arrays if they are scalar
self.array = u.Quantity(data, ndmin=3)
self.time = u.Quantity(time, ndmin=1)
self.energy = u.Quantity(energy, ndmin=1)
self.flavor = np.sort(np.array(flavor, ndmin=1))

if integrable_axes is not None:
#store which axes can be integrated
Expand Down
Loading