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

Suppress warnings during the models spectra calculation #257

Open
Sheshuk opened this issue Jun 3, 2023 · 0 comments
Open

Suppress warnings during the models spectra calculation #257

Sheshuk opened this issue Jun 3, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Sheshuk
Copy link
Contributor

Sheshuk commented Jun 3, 2023

Sometimes running the calculation of the neutrino spectra from the models produce runtime warnings, even when the calculation is within the valid range. These warnings are of no concern to user and just flood the logs

Example:

import numpy as np
import astropy.units as u
from snewpy.models import ccsn

m = ccsn.Bollig_2016(progenitor_mass=11.2<<u.M_sun)
spectra = m.get_initial_spectra(m.get_time(), np.linspace(0,100,51)<<u.MeV)

produces following warnings:

.../snewpy/python/snewpy/models/base.py:305: RuntimeWarning: divide by zero encountered in log
  np.exp(np.log(L) - (2+a)*np.log(Ea) + (1+a)*np.log(1+a)
.../snewpy/python/snewpy/models/base.py:305: RuntimeWarning: invalid value encountered in subtract
  np.exp(np.log(L) - (2+a)*np.log(Ea) + (1+a)*np.log(1+a)
.../snewpy/python/snewpy/models/base.py:306: RuntimeWarning: divide by zero encountered in divide
  - loggamma(1+a) + a*np.log(E) - (1+a)*(E/Ea)) / (u.erg * u.s)

This makes no problem in the final spectra/flux array, because all the NaN/inf values get filled as zero in the final result, but the warnings are a nuisance and should be suppressed.

@Sheshuk Sheshuk added the bug Something isn't working label Jun 3, 2023
@Sheshuk Sheshuk self-assigned this Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant