SNEWS2 / snewpy

A Python package for working with supernova neutrinos
https://snewpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
26 stars 19 forks source link

Using `tstart` and `tend` arguments in `snowglobes.generate_fluence` doesn't work #241

Closed Sheshuk closed 1 year ago

Sheshuk commented 1 year ago

I want to generate fluence in interval [0,1]s.

When I try to execute the following code (passing time without units):

t0 = np.array([0])
t1 = np.array([1])
path = snowglobes.generate_fluence('models/Bollig_2016/s27.0c', 'Bollig_2016', 'NoTransformation', d=10,tstart=t0, tend=t1)

I get

UnitConversionError: Can only apply 'greater_equal' function to dimensionless quantities when other argument is not a quantity (unless the latter is all zero/infinity/nan)

If I pass the time with units:

t0 = np.array([0]) <<u.s
t1 = np.array([1]) <<u.s
path = snowglobes.generate_fluence('models/Bollig_2016/s27.0c', 'Bollig_2016', 'NoTransformation', d=10,tstart=t0, tend=t1)

I get

TypeError: unsupported format string passed to numpy.ndarray.__format__

when it tries to produce the label for the time bin in the output text file.

So ATM there arguments are unusable

Sheshuk commented 1 year ago

My bad, I should have used scalar values instead of arrays:

snowglobes.generate_fluence('models/Bollig_2016/s27.0c', 'Bollig_2016', 'NoTransformation', d=10,tstart=0<<u.s, tend=1<<u.s)

then it works. Sorry, closing this issue