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

Fornax models: `get_initial_spectra()` returns wrong units #167

Closed JostMigenda closed 2 years ago

JostMigenda commented 2 years ago

The unit of get_initial_spectra()’s return value for Fornax_2019 and Fornax_2021 is different than for all other models:

>>> b = Bollig_2016("models/Bollig_2016/s11.2c")  # example; same for most other SupernovaModel subclasses
>>> b.get_initial_spectra(0.5*u.s, 20*u.MeV)[Flavor.NU_E]
<Quantity 1.1760078e+61 1 / (erg s)>

>>> f = Fornax_2021("models/Fornax_2021/lum_spec_16M_r10000_dat.h5")
>>> f.get_initial_spectra(0.5*u.s, 20*u.MeV)[Flavor.NU_E]
<Quantity 7.50688478e+50 erg / (MeV s)>

This causes problems when using these return values with other software such as SNOwGLoBES or sntools. This example (adapted from SNOwGLoBES_usage.ipynb)

modeltype = 'Fornax_2021'
model = 'lum_spec_15M_r10000_dat.h5'
transformation = 'NoTransformation'
distance = 10
outfile = f"{modeltype}_{model}_{transformation}"
tarredfile = snowglobes.generate_fluence(f'models/{model_type}/{model}', modeltype, transformation, distance, outfile)

generates flux files that are malformed:

# should be:
4.00000000E-04   5.37645463E+03   7.49690820E+03   7.49690820E+03   […]
# actual output:
4.00000000E-04   4.72473777E-07 erg2 / MeV   7.12462780E-07 erg2 / MeV   7.12462780E-07 erg2 / MeV   […]

Running snowglobes.simulate() then crashes due to malformed input files.

JostMigenda commented 2 years ago

It looks to me like the Fornax models returns a differential luminosity, while they should return a differential number luminosity; so it should be sufficient to divide by the particle energy. @sybenzvi I think you originally implemented both Fornax models—do I understand that correctly?