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

direction dependent luminosity of Tamborra 2014, 27 M_solar model duplicate in version 1.4b1 #261

Closed jakob2508 closed 1 year ago

jakob2508 commented 1 year ago

In SNEWPY version 1.4b1 the luminosity of the Tamborra 2014, 27 M_solar model in direction 1 and 2 for all flavors is the same.

I modified the example notebook and plotted all flavours individually and show that direction 1 and 2 are overlapping.

Here is the minimal code:

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

from astropy import units as u 

from snewpy.neutrino import Flavor
from snewpy.models.ccsn import Tamborra_2014

mpl.rc('font', size=16)
%matplotlib inline

m27_1 = Tamborra_2014(progenitor_mass=27*u.solMass, direction=1)
m27_2 = Tamborra_2014(progenitor_mass=27*u.solMass, direction=2)
m27_3 = Tamborra_2014(progenitor_mass=27*u.solMass, direction=3)

fig, axs = plt.subplots(2, 2, figsize = (10,10),tight_layout=True)
ax = axs.ravel()
for j, flavor in enumerate(Flavor):
    for i, model in enumerate([m27_1, m27_2, m27_3]):
        ax[j].plot(model.time, model.luminosity[flavor]/1e51,  # Report luminosity in units foe/s
                    label='dir = {}'.format(i+1),
                    lw=2,
                    ls='--' if i == 1 else '-')
    ax[j].set(xlim=(0.0, 0.35),
              ylim=(0.0, 75.0),
              xlabel=r'$t-t_{\rm bounce}$ [s]',
              ylabel=r'luminosity [foe s$^{-1}$]',
              title=r'{}: {} $M_\odot$, {}'.format(model.metadata['EOS'], model.metadata['Progenitor mass'].value, flavor.to_tex()))
    ax[j].grid()
    ax[j].legend(loc='lower center', ncol=2, fontsize=15)

This is the plot which shows that direction 1 (full blue line) and direction 2 (dashed orange line) overlay. image

JostMigenda commented 1 year ago

Hi @jakob2508, thanks for reporting this and providing good sample code!

When running this sample code in a new notebook, however, I’m unable to reproduce the issue. I get the following figure instead, where all three directions have clearly distinct luminosities: image

Could you try to delete the Tamborra_2014 directory from the snewpy cache and rerun the code? That will redownload the data files, to exclude any issues related to local caches. You can find the snewpy cache directory by running

from snewpy import model_path
print(model_path)
# should return something like ~/.astropy/cache/snewpy/models
jakob2508 commented 1 year ago

Hi @JostMigenda, thank you very much. This worked perfectly!

JostMigenda commented 1 year ago

Glad to hear that. Have a good weekend and let us know if you have any other feedback or issues in the future!