SNEWPY: A Data Pipeline from Supernova Simulations to Neutrino Signals

Current neutrino detectors will observe hundreds to thousands of neutrinos from a Galactic supernovae, and future detectors will increase this yield by an order of magnitude or more. With such a data set comes the potential for a huge increase in our understanding of the explosions of massive stars, nuclear physics under extreme conditions, and the properties of the neutrino. However, there is currently a large gap between supernova simulations and the corresponding signals in neutrino detectors, which will make any comparison between theory and observation very difficult. SNEWPY is an open-source software package which bridges this gap. The SNEWPY code can interface with supernova simulation data to generate from the model either a time series of neutrino spectral fluences at Earth, or the total time-integrated spectral fluence. Data from several hundred simulations of core-collapse, thermonuclear, and pair-instability supernovae is included in the package. This output may then be used by an event generator such as sntools or an event rate calculator such as SNOwGLoBES. Additional routines in the SNEWPY package automate the processing of the generated data through the SNOwGLoBES software and collate its output into the observable channels of each detector. In this paper we describe the contents of the package, the physics behind SNEWPY, the organization of the code, and provide examples of how to make use of its capabilities.

supernova simulations and the corresponding signals in neutrino detectors, which will make any comparison between theory and observation very difficult. SNEWPY is an open-source software package which bridges this gap. The SNEWPY code can interface with supernova simulation data to generate from the model either a time series of neutrino spectral fluences at Earth, or the total time-integrated spectral fluence. Data from several hundred simulations of core-collapse, thermonuclear, and pair-instability supernovae is included in the package. This output may then be used by an event generator such as sntools or an event rate calculator such as SNOwGLoBES. Additional routines in the SNEWPY package automate the processing of the generated data through the SNOwGLoBES software and collate its output into the observable channels of each detector. In this paper we describe the contents of the package, the physics behind The neutrino signal from a supernova in the Milky Way Galaxy will be a golden opportunity to advance our understanding of how stars explode and probe the properties of the neutrino. For reviews of the physics potential of a supernova neutrino signal we refer the reader to several recent reviews (Scholberg 2012;Janka et al. 2016;Horiuchi & Kneller 2018). Many different detectors worldwide will record events from the supernova and naturally there is much interest from experimenters about what they might observe. Present-day detectors, such as Super-Kamiokande (Ikeda et al. 2007), Borexino (Monzani 2006), KamLAND (Eguchi et al. 2003), LVD (Agafonova et al. 2008;Agafonova et al. 2007), or the dedicated supernova burst detector HALO (Duba et al. 2008), are expected to record tens to hundreds of thousands of neutrino events each from a Galactic or nearby core-collapse supernova (CCSN). Such a neutrino burst would also be recorded with very high statistics in detectors such as IceCube (Halzen et al. 1994(Halzen et al. , 1996Abbasi et al. 2011) and KM3NeT (Aiello et al. 2021) but without event-by-event reconstruction. Ever larger and more ambitious detectors are under construction or proposed, including DUNE (Acciarri et al. 2016a(Acciarri et al. , 2015(Acciarri et al. , 2016b, Hyper-Kamiokande (Abe et al. 2018), and JUNO . The physical and astronomical potential of megaton scale detectors has been considered (Suzuki et al. 2001;Kistler et al. 2011). In addition, dark matter detectors are becoming of sufficient size that they, too, are capable of detecting a significant number of neutrinos from a CCSN burst via coherent elastic neutrino-nucleus scattering (Horowitz et al. 2003;Lang et al. 2016;Lai 2021). Other types of supernovae or compact object mergers involving neutron stars also produce neutrino bursts that are detectable if they occur sufficiently nearby (Odrzywolek & Plewa 2011;Wright et al. 2016Wright et al. , 2017bRosswog & Liebendörfer 2003;Caballero et al. 2009;Lin & Lunardini 2020).
With so many detectors capable of detecting the next Galactic or near-Galactic supernova, there is a need for theoretical predictions of neutrino emission from supernova simulations and the resulting neutrino signals in detectors on Earth. To determine how well these detectors can provide quantitative information about the supernova explosion mechanism and nuclear physics under extreme conditions, we need a suite of neutrino signal templates to compare observations with theory. However, there is snewpy.models snewpy. flavor_transformation snewpy.snowglobes presently a substantial gulf between the data from a supernova simulation and the neutrino spectra at Earth. This gap has been bridged on a few occasions (Kneller et al. 2008;Reid et al. 2011;Wu et al. 2015;Gava et al. 2009)-see also Wright et al. (2016Wright et al. ( , 2017b,a)-but there are not enough such data sets to cover the wide range of available supernova models and they are time consuming to generate.
The SNEWPY code has been written with the intent of bridging this gap. SNEWPY provides a consistent interface to hundreds of supernova simulation data sets to extract the neutrino emission. It can then convolve this with a prescription for the flavor transformation to generate the spectral fluence (time-integrated flux) reaching a detector on Earth either in a set of time bins or over the entire simulation time window. This output can be processed with an event generator such as sntools (Migenda et al. 2021) or an event rate calculator such as SNOwGLoBES (Scholberg et al. 2021). SNEWPY also includes routines that automate the processing of the data with SNOwGLoBES and collate its output to determine the total event rates in the observable channels of each detector.
In this paper we give an overview of the SNEWPY package, its capabilities, and the large library of simulation data sets. The overall organization of the code is described in section 2 before proceeding to discuss in detail SNEWPY's interfaces to simulation data in section 3, the flavor transformations prescriptions in section 4, and the SNOwGLoBES interface in section 5. To demonstrate the capabilities of the software and how it is used in practice, in section 6 we provide two examples of applications of SNEWPY: the first example is a complete data pipeline using SNEWPY's interface with SNOwGLoBES, and the second example shows how it can be integrated into the event generator sntools.

THE STRUCTURE OF SNEWPY
SNEWPY is an open-source package written in Python, designed to bridge the gap between supernova simulations and detector observations. It is built upon NumPy (Harris et al. 2020) and SciPy (Virtanen et al. 2020) and uses Astropy (Astropy Collaboration et al. 2013, 2018 for model I/O and unit conversions. Figure 1 shows the high-level structure of a complete supernova data pipeline implemented in SNEWPY. This pipeline takes an input file from a supernova simulation, then • extracts neutrino fluxes produced in the supernova as a function of time, energy, and flavor, • applies a flavor transformation prescription to determine the fluxes reaching Earth, and • runs them through the detector response software SNOwGLoBES, before providing the computed event rates per detector and interaction channel either in the form of figures or as structured data for further processing. Matching this set of steps, SNEWPY is divided into three main modules 1 : snewpy.models, which interfaces with the simulation data that comes with SNEWPY, snewpy.flavor transformation, which implements the different flavor transformation prescriptions, and snewpy.snowglobes, which integrates with SNOwGLoBES and provides functions to generate SNOwGLoBES-formatted data files, runs them through SNOwGLoBES for a chosen set of neutrino detectors and finally collates the resulting outputs. SNEWPY was designed in this way so that the user can insert or extract data at the interfaces between the components. For example, the user may have an alternative method (such as an analytic formula) for generating the neutrino spectra at Earth and therefore does not need to generate a time series from a simulation. Another user could use SNEWPY to provide a consistent interface to different supernova models or a large library of flavor transformations, without having to run the SNOwGLoBES software. In what follows, we describe these three main modules of SNEWPY in more detail.

SUPERNOVA NEUTRINO MODELS
Core-collapse supernova models depend on many different factors-both physical parameters of the progenitor (e. g. its mass and metallicity) and implementation parameters of the simulation (e. g. the degree of spatial symmetry and the equation of state). The choice of parameters strongly affects the predicted neutrino emission and thus what we detect at Earth. To best estimate the sensitivity of a detector (or set of detectors) to a wide variety of explosion models and parameter values, it is common practice to use a broad sample of simulation models. It is better still if those models are provided by different modeling groups using different numerical algorithms and approaches. Unfortunately, this often means simulation data is provided in different formats. Rather than attempt to reduce all simulations to a common format, SNEWPY solves this problem by providing an extensible module called models which contains an abstract SupernovaModel base class with the absolute minimal functionality to undertake the calculation of the neutrino spectra at Earth from the simulation. The SupernovaModel class defines just three member functions: • get time: access the list of snapshot times from the simulation; • get initial spectra: obtain the neutrino spectra as a function of time, energy, flavor, and angle at the surface of emission (neutrinosphere) within the progenitor; • get transformed spectra: obtain neutrino spectra as a function of time, energy, and flavor after some flavor transformation (see Section 4).
Specific supernova models are implemented as subclasses of SupernovaModel. Each subclass must contain custom implementations of get time and get initial spectra, since these depend on the format of the input files. At the present time, snewpy.models contains twelve SupernovaModel  (Nakazato) e (Nakazato) x (Nakazato) x (Nakazato) Figure 2. Luminosity of different neutrino flavors as a function of time for the nakazato-shen-z0.004-trev100ms-s20.0 model (thick lines, blue and green) and the Bollig 2016/s27.0c model (thin lines, orange and red). Both models come with SNEWPY and were originally presented in Nakazato et al. (2013) and , respectively. subclasses, which are named according to the modeling group or publication describing the simulations. A list of available models and their properties is provided in Table 1 and two example models are shown in figure 2.
Across these models, neutrino fluxes from hundreds of core-collapse simulations are available and can be downloaded by SNEWPY on demand. In addition, SNEWPY has data from two pairinstability supernovae (PISNe) from Wright et al. (2017a), and two Type-Ia supernovae (Wright et al. 2016(Wright et al. , 2017a. 2 Given so many models we do not attempt to describe them all here and refer the reader to their associated literature.
Each SupernovaModel subclass is able to construct a neutrino spectrum Φ α at the neutrinosphere for the neutrino species ν e , ν x ,ν e , andν x . Here, x stands for the µ and τ flavors, which are treated as identical in almost all current supernova simulations, including those in table 1. 3 Once simulations that treat all six flavors-3 neutrino plus 3 antineutrino flavors-as separate become more frequent, we expect to update SNEWPY to accommodate this.
The customized get initial spectra member function of each model class extracts the neutrino spectra Φ(E ν ) from the simulation data if it is provided but, more commonly, the method constructs a  (27) The s11.2c and s27.0c models shown in Fig. 17 of , using the LS220 EOS. Kuroda 2020 20 0.00 -0.476, depending on rotation and magnetic field 3D simulation of a magnetized rotating star from Kuroda (2021) using a 20 M progenitor by Woosley & Heger (2007) and SFHo EOS.

THE FLAVOR TRANSFORMATION PRESCRIPTIONS
The second component of SNEWPY is the flavor transformation prescriptions which relate the neutrino fluxes produced in the supernova to those arriving on Earth. This library of prescriptions in SNEWPY accounts for effects of propagation through the outer layers of the star, neutrino decay during vacuum propagation to Earth, or mixing with sterile neutrinos. The user may easily create new prescriptions to include additional scenarios or vary oscillation parameters for one of the existing prescriptions to test the sensitivity of a detector. In this section we first describe the general form of these transformations and then their implementation in SNEWPY.

General Form of Flavor Transformations
The spectral fluxes of the three neutrino flavors at Earth can be arranged into a column vector, where we use the subscript F to indicate the neutrino flavor basis, and r ⊕ indicates the location of Earth. When we refer to a generic element of the flavor basis, we shall use Greek subscripts α and β; the subscripts e, µ and τ are the specific flavor of the neutrinos, while the subscript x indicates either µ or τ . The neutrino spectra at Earth are not those that were emitted at the neutrinosphere inside the progenitor, but have been mixed on their way to Earth by flavor transformation effects. The flavor transformation of neutrinos is a quantum mechanical phenomenon that occurs due to the mismatch between the flavor states of the neutrinos and the eigenstates of the free Hamiltonian. For a complete discussion of the phenomenon we refer the reader to the reviews mentioned previously Horiuchi & Kneller 2018). Flavor transformation of the neutrinos occurs while they are within the supernova and then at some point on their trip to Earth the neutrinos decohere and arrive in their mass eigenstates. We shall denote quantities which are in the mass basis by the subscript M and when we wish to refer to a generic mass states we shall use the italic subscripts i, j; the subscripts 1, 2 and 3 are specific mass states.
The spectral flux of a particular flavor at Earth is the incoherent sum of the parts of the spectral flux of each mass state with a given flavor, which can be written as The elements of the matrix D are given by D αi = U V,αi 2 , where U V,αi are the elements of the vacuum mixing matrix for neutrinos. The antineutrino fluxes in the flavor basis are related to the antineutrino fluxes in the mass basis by the same matrix D. We shall denote antineutrino quantities by an overbar. The relationship for antineutrinos is thusF F (r ⊕ ) = DF M (r ⊕ ). The column vector of the spectral fluxes of the mass states are the diagonal elements of the spectral flux matrix F M , constructed by where c is the speed of light, ρ M is the density matrix in the mass basis, θ is the angle with respect to the line from the supernova to Earth, and the integral is over all the neutrino propagation angles. The conversion of the flux matrix to a column vector-and the ignoring of the off-diagonal elements of the flux matrix-is the effect of decoherence. Accounting for decoherence, F M can be written as where the {|ν j } are basis vectors in the mass basis. The same conversion occurs for the antineutrinos.
where d is the distance of the supernova from Earth, and Φ M (r ⊕ ) is the spectral number luminosity matrix in the mass basis at Earth. The matrix Φ M at Earth is related to the matter basis spectral matrix at the neutrinosphere Φ M (R ν ) -the matter basis becomes the mass basis in the vacuum -by with S M (r ⊕ , R ν ) being the propagator of the matter/mass states and R ν indicating the neutrinosphere. Note that this formula does not account for absorption, emission, or scattering of neutrinos. Finally, the matrix Φ M (R ν ) is related to the spectral matrix in the flavor basis at the neutrinosphere by with U as the so-called matter mixing matrix at the neutrinosphere. The matrix U , and the equivalent matrix for the antineutrinosŪ , depend upon the mass ordering and the initial density. The spectral matrix at the neutrinosphere in the flavor basis is taken to be pure diagonal: where the {|ν β } are the basis vectors in the flavor basis. Note that in practice the spectra Φ β (R ν ) are usually taken to be the spectra at the largest radius in the simulation and not the actual neutrinosphere. Putting all this together so as to relate In these equations, the quantities ν i |S M (r ⊕ , R ν ) U † |ν β have the physical interpretation of being the probability amplitudes that a neutrino emitted as a particular flavor β reaches Earth in mass state i. The propagators S M andS M and the mixing matrices U andŪ are the quantities which can vary depending upon the evolution of the matter states through the mantle of the supernova, and the flavor transformation scenario.
Equations (11) and (12) can be simplified considerably by summarizing the effect of transformations as where the quantities {p αβ } and {p αβ } are the various survival and transition probabilities that a neutrino emitted as a particular flavor β is detected as flavor α at Earth. Equations (13) to (16) are generalizations of those found in Dighe & Smirnov (2000); Horiuchi & Kneller (2018) and elsewhere, since we shall consider cases where p αβ = p βα .

Implementation of Flavor Transformations in SNEWPY
SNEWPY implements neutrino flavor transformations in its flavor transformation module. This module contains an abstract base class FlavorTransformation which defines a minimal interface for computing neutrino survival and transformation probabilities used in equations (13) to (16). For example, the survival probability p ee = Pr(ν e → ν e ) is computed using the member function prob ee, and the transition probability p ex = Pr(ν x → ν e ) is computed using the member function prob ex. For forward compatibility, SNEWPY has been written such that the transition probabilities can depend on time and neutrino energy.
Using this interface, it is easy to support many different kinds of flavor transformation scenarios with subclasses that inherit the interface of FlavorTransformation. Currently, the module snewpy.flavor transformation supports fifteen transformation scenarios: six for the normal mass ordering (NMO), six for the inverted mass ordering (IMO), and three which are independent of the mass ordering. The list of transformations included in SNEWPY is provided in Table 2. The values used for the neutrino mixing parameters are contained inside two instances of a class called Mix-ingParameters that is also part of SNEWPY, one instance for the NMO and another for the IMO. They are set by default to the values from Esteban et al. (2020) but may be modified by the user.   and antineutrinos (right panels) using the ThreeFlavorDecoherence prescription and a distance to the supernova of 10 kpc. Both mass orderings are equivalent in this prescription. We show the nakazato-shen-z0.004-trev100ms-s20.0 model (Nakazato et al. 2013) that comes with SNEWPY, at the simulation time of 100 ms and at a supernova distance of 10 kpc.
With both the model and flavor transformation prescriptions now defined, the previously mentioned get transformed spectra member function of each model class is seen to be the implementation of equations (13) to (16). For the purposes of illustration, we show in figure 3 an example of how flavor transformations affect the neutrino spectra. This example uses the ThreeFlavorDecoherence prescription, which mixes the initial spectra for the neutrinos so that the flux of each flavor at Earth is equal (and the same for antineutrinos).

SNEWPY'S INTERFACE WITH SNOwGLoBES
The module snewpy.snowglobes contains functions to interact with the SNOwGLoBES software. This interaction typically occurs in three steps: generating the data files of the neutrino fluences at Earth in the SNOwGLoBES format, processing those files through the SNOwGLoBES software, and then collating the data output from SNOwGLoBES.

Generating SNOwGLoBES Input Files
The snewpy.snowglobes module contains the two functions generate time series and generate fluence. The generate time series function constructs a set of data files at a set of snapshot times from a chosen simulation. For each snapshot, the code extracts (or constructs) the neutrino spectra at the neutrinosphere. It then applies a user-selected flavor transformation prescription to those spectra and scales with a user-selected supernova distance to generate the flux at Earth. Finally, the function writes the fluence-the flux multiplied by the time bin width-for the snapshot to a SNOwGLoBES-formatted file and collates the files for different snapshot times into a single compressed output file. A number of options are available to the user to control how many snapshots are created and their spacing in time.
The generate fluence function works similarly but applies a time integration of the fluence in each time bin to compute the total fluence.

Simulating Detector Effects with SNOwGLoBES
The snewpy.snowglobes module contains a function named simulate which takes a compressed file, such as those generated by generate time series or generate fluence, and runs the contents through the SNOwGLoBES software. The bulk of the simulate function is a translation into Python of the script supernova.pl that comes with SNOwGLoBES: simulate also creates a supernova.glb file then invokes supernova, the executable in SNOwGLoBES. The mandatory arguments passed to simulate are the location of the SNOwGLoBES installation directory and the path to the compressed input file. Another, optional argument is the name of a detector. If this argument is not supplied, SNOwGLoBES is repeatedly invoked for all supported detectors. There is no output from the simulate function itself; instead, upon successful execution of the function a large set of files (each containing the event rate in a given set of energy bins for a particular interaction channel due to a particular flavor) is generated in the SNOwGLoBES output folder. We refer the reader to the SNOwGLoBES documentation (Scholberg et al. 2021) for details about the interaction channels that SNOwGLoBES computes and how the calculation is done.

Collating Information from SNOwGLoBES
Finally, the snewpy.snowglobes module contains a function named collate, which collates the output generated by SNOwGLoBES into the observable channels of each detector in the four combinations of weighted and unweighted event rates and with and without applying detector energy smearing.
Like the simulate function, the mandatory arguments passed to collate are the location of the SNOwGLoBES installation directory and the name of the compressed input file. Again, an optional final argument is the name of the detector that was chosen for the SNOwGLoBES event rate calculation and if this argument is not supplied, it is assumed all detectors in the SNOwGLoBES suite were used. The collate function writes the collated data to a new compressed file, whose name is based on the name of the file that was run through SNOwGLoBES, and returns a dictionary of the collated results. Additional optional arguments to the function will cause it to generate simple Matplotlib (Hunter 2007) histogram figures from the collated data, which will be also placed in the compressed file, or to delete SNOwGLoBES output files.

SNEWPY USAGE EXAMPLES
Included in the SNEWPY repository are many Jupyter notebooks containing many instances of using the software for various purposes. Here we provide two short examples.

Using SNEWPY with SNOwGLoBES
In this section we provide a simple example of using SNEWPY with the SNOwGLoBES software. This particular script reproduces the Super-Kamiokande entry in Table 4 of Al Kharusi et al. (2021) for the 11.2 M model assuming adiabatic MSW oscillations with the normal mass ordering (4045 neutrinos). A script that calculates the entire Table 4 in Al Kharusi et al. (2021) is one of the previously mentioned Jupyter notebooks that are included in the package.
from snewpy import snowglobes SNOwGLoBES_path = "/path/to/snowglobes/" # directory where SNOwGLoBES is located SNEWPY_model_dir = "/path/to/snewpy/models/" # directory with model input files distance = 10 # Supernova distance in kpc detector = "wc100kt30prct" # Name of SNOwGLoBES detector model to use modeltype = 'Bollig_2016' # Model type from snewpy.models model = 's11.2c' # Name of model transformation = 'AdiabaticMSW' # Desired flavor transformation # Construct file system path of model file and name of output file model_path = SNEWPY_model_dir + "/" + modeltype + "/" + model outfile = modeltype + "_" + model + "_" + transformation  (Migenda et al. 2021) is an event generator that takes neutrino fluxes from supernova simulations and generates a list of resulting neutrino interactions in a detector with a realistic distribution of event time as well as energy and direction of outgoing particles. This list can then be used with a full detector simulation and event reconstruction toolchain for situations in which the approximate treatment of detector effects in SNOwGLoBES is insufficient. In a recent update, sntools integrated SNEWPY to benefit from the large number of supernova models and flavor transformations it implements.
For example, generating a set of neutrino events in the Hyper-Kamiokande detector (Abe et al. 2018) for the first 500 ms of one of the models included in SNEWPY at a supernova distance of 50 kpc can be done as follows: # install sntools (this automatically installs SNEWPY as a dependency) pip install sntools # download supernova model files that are part of SNEWPY python -c 'import snewpy; snewpy.get_models("Bollig_2016")' # run sntools using an input file from SNEWPY sntools SNEWPY_models/Bollig_2016/s27.0c --format SNEWPY-Bollig_2016 --distance 50 --detector HyperK --starttime 0 --endtime 500 SNEWPY's modular design also makes it possible to use its flavor transformations with unsupported input fluxes. The following example shows how to apply SNEWPY's ThreeFlavorDecoherence flavor transformation to an input file format that is natively supported by sntools but not by SNEWPY. 4 # download sample input file curl https://raw.githubusercontent.com/JostMigenda/sntools/v1.0b2/fluxes/intp2001.data -o intp2001.data # run sntools using a flavor transformation from SNEWPY sntools intp2001.data --format nakazato --detector HyperK --distance 50 --starttime 0 --endtime 500 --transformation SNEWPY-ThreeFlavorDecoherence At the moment, sntools does not support all supernova models and flavor transformations listed in sections 3 and 4.2, respectively, since some require additional physical parameters such as sterile neutrino mixing angles. Improvements are expected in future versions of sntools.

SUMMARY
The SNEWPY software package connects supernova simulations with detector response software such as SNOwGLoBES and sntools, allowing users to calculate the expected event rates in various neutrino detectors for each model. We expect SNEWPY will prove useful to modelers and theorists interested in what detectors will observe given some new piece of physics in a simulation, and to experimentalists wishing to evaluate the sensitivity of their detector to supernova neutrinos. In the future we plan to enhance the capabilities of SNEWPY and suggestions from the community about the features we should add are warmly welcome. Modelers interested in adding their simulations to the model library are encouraged to contact us.

ACKNOWLEDGMENTS
This work is supported by the National Science Foundation "Windows on the Universe: the Era of Multi-Messenger Astrophysics" Program: "WoU-MMA: Collaborative Research: A Next-Generation SuperNova Early Warning System for Multimessenger Astronomy" through Grant Nos. 1914448, 1914409, 1914447, 1914418, 1914410, 1914416, and 1914426. This work is also supported at NC State by DOE grant DE-FG02-02ER41216, at King's College London by STFC, and at Stockholm University by the Swedish Research Council (Project No. 2020-00452). In this appendix we provide the equations for the survival and transition probabilities that appear in equations (13) to (16) for all 15 flavor transformation prescriptions that SNEWPY currently implements.

A.1. The Extreme Cases
The first two transformations implemented in SNEWPY are NoTransformation and Comple-teExchange. For NoTransformation, the set of probabilities is given by while CompleteExchange corresponds to p ee = 0, p ex = 1 p xx = 0.5, p xe = 0.5 p ee = 0,p ex = 1 p xx = 0.5,p xe = 0.5 (A2)

A.2. The Three Flavor Mixing Prescriptions
For nontrivial cases of mixing between three active flavors, we only need to compute the elements of the D matrix from the "electron" flavor row in terms of the vacuum mixing angles θ 12 and θ 13 . The expressions in the 'electron' flavor row of the matrix are: D e1 = cos 2 θ 12 cos 2 θ 13 , D e2 = sin 2 θ 12 cos 2 θ 13 , Using equation (15) from , we evaluate the matter mixing angles given in their equations (16a) to (16f) in the limit where the MSW potential becomes large. Using their notation, we find that for normal mass ordering (NMO),θ 12 → π/2,θ 13 → π/2 for neutrinos, while for the antineutrinosθ 12 → 0,θ 13 → 0. The angleθ 23 can be set to zero with no loss of generality if the spectra of µ and τ flavor neutrinos are taken to be equal, because any mixing between them is not observable. In the high density limit the 'β' and 'δ' phases are also irrelevant and we can pick the Majorana phases 'α i ' to give positive definite values in the U matrix because these phases were shown not to be observable Galais et al. (2012). Thus we find For inverted mass ordering (IMO) in the same high density limit,θ 12 → π/2,θ 13 → 0 for the neutrinos, andθ 12 → 0,θ 13 → π/2 for the antineutrinos. Again, the angleθ 23 can be set to zero with no loss of generality and again, in the high density limit, the phases are also irrelevant. This gives for the IMO With U andŪ now defined, we turn our attention to the S matrices. The various prescriptions depend on the details of the flavor transformations: The AdiabaticMSW transformation assumes adiabatic neutrino evolution for both mass orderings. Given the values of the mixing angle θ 12 , θ 13 and θ 23 from experiment and typical supernova density profiles, the neutrino propagation through the supernova is adiabatic in the absence of neutrino self-interactions.  . The untransformed (solid lines) and transformed (dashed lines) spectral flux for neutrinos (left panels) and antineutrinos (right panels) using the AdiabaticMSW prescription. The NMO are the top pair of panels, and the IMO are the bottom pair. We show the nakazato-shen-z0.004-trev100ms-s20.0 model (Nakazato et al. 2013) that comes with SNEWPY, at the simulation time of 100 ms and at a supernova distance of 10 kpc.

A.2.2. Nonadiabatic MSW Effect
The NonAdiabaticMSWH transformation assumes that the H resonance mixing is nonadiabatic while the L resonance is adiabatic. This case is relevant when a shock is present at the H resonance densities (Schirato & Fuller 2002). For the NMO the H resonance occurs in the neutrinos (Kneller For this case we find: In figure 5, we show the effect of these two prescriptions on example neutrino spectra.

A.2.3. Two-Flavor Decoherence
The TwoFlavorDecoherence transformation is relevant when there is 10% amount of turbulence in the vicinity of the H resonance-see Kneller (2010); Kneller & Mauney (2013). This prescription models 50% mixing between the matter states which participate in the H resonance. In the NMO this is ν 2 and ν 3 , and S M is whileS M is again a diagonal unitary matrix in this scenario. Thus we find For the IMO, the H resonance occurs in the antineutrinos between antineutrino matter statesν 1 andν 3 so in this prescriptionS M matrix has the general form of while S M is diagonal. This leads to In figure 6 we show the effect of these two prescriptions on example neutrino spectra

A.2.4. Three-Flavor Decoherence
The ThreeFlavorDecoherence transformation leads to 33% mixing between all neutrino matter states and antineutrino matter states. Every element of the S M andS M matrices has a magnitude of 1/ √ 3. This case is relevant when there are large amounts of turbulence in the vicinity of the H resonance no matter the mass ordering-see Kneller & Mauney (2013). With this structure for the S m andS m matrices we obtain p ee = 1/3 p ex = 1 − p ee p xx = (1 + p ee )/2 p xe = (1 − p ee )/2 The effect of this prescription on example neutrino spectra was shown in figure 3.

A.3. Neutrino Decay
SNEWPY also considers two cases of neutrino decay for three active neutrino flavors. The two prescriptions provided with SNEWPY for neutrino decay assume adiabatic evolution through the mantle of the supernova followed by decay of the heaviest mass neutrino state to the lightest in the vacuum after they have decohered. To account for neutrino decay we must insert another matrix G between the D matrix and the mass state flux vector in equation (4), i.e., D → D G. The matrix which accounts for the decay of the antineutrinos is the same. Note that we use the approximation that the energy of the neutrino does not change-future versions of SNEWPY will correct this assumption.
If the heaviest neutrino has a mass m and a lifetime τ , we define the inverse decay length as Γ = mc/(Eτ ). If the distance to the supernova is d, then the flux of the heaviest neutrino mass state decays by the factor e −Γd and the lightest mass state increases by the amount 1 + e −Γd . The structure of the matrix G depends upon the mass ordering.
• NeutrinoDecay -Adiabatic evolution through the mantle of the supernova followed by neutrino decay of the heaviest mass state to the lightest without changing the neutrino energy. For the normal mass ordering the G matrix is which gives for the NMO: and using this new matrix we find for the IMO: In figure 7, we show the effect of this prescription on example neutrino spectra.

A.4. The Four Neutrino Mixing Prescriptions
We have also included prescriptions for neutrino mixing of three active flavors and a fourth, undetectable, sterile flavor. To keep things simple, we have made a number of reasonable assumptions or approximations for these prescriptions. First, we added just one more mixing angle θ 14 and assumed the fourth mass eigenstate is the heaviest. In terms of the mixing angles, the required elements of D we will require are: D e1 = cos 2 θ 12 cos 2 θ 13 cos 2 θ 14 (A24) D e2 = sin 2 θ 12 cos 2 θ 13 cos 2 θ 14 (A25) D e3 = sin 2 θ 13 cos 2 θ 14 (A26) D e4 = sin 2 θ 14 (A27) D s1 = cos 2 θ 12 cos 2 θ 13 sin 2 θ 14 (A28) D s2 = sin 2 θ 12 cos 2 θ 13 sin 2 θ 14 (A29) D s3 = sin 2 θ 13 sin 2 θ 14 (A30) D s4 = cos 2 θ 14 . (A31) In these active-sterile mixing scenarios we must consider the effect of the neutral current contribution to the MSW potential which has the effect that the initial density becomes more of an issue in determining the structure of the U andŪ matrices. For an electron fraction Y e < 1/3, the sterile flavor maps to the heaviest matter eigenstate while for Y e > 1/3 it is the electron flavor which maps to the heaviest. However, in supernovae the point where Y e = 1/3 is typically very close to the edge of the proto-neutron star where the density gradients are large. The current experimental limits on θ 14 are such that it is difficult to find a supernova density profile where the Y = 1/3 resonance is adiabatic. Thus, we have assumed that the only active-sterile mixing channel that could be either adiabatic or nonadiabatic is the ν e -ν s resonance that is set by the mass splitting δm 2 14 . The MSW 'es' resonance is sometimes called the 'outer' es resonance or H resonance (Nunokawa et al. 1997;McLaughlin et al. 1999;Fetter et al. 2003;Beun et al. 2006;Keränen et al. 2007;Esmaili et al. 2014). Any other new resonance introduced by adding the sterile flavor- Esmaili et al. (2014) calls them H resonances-is completely nonadiabatic. The mass ordering among the active flavors also needs to be specified, which gives us four cases total.
If we place the neutrinosphere between the Y e = 1/3 and ν e -ν s MSW resonance then the structure of the matrices U andŪ for the NMO are: Putting this all together we find the following formulae in the four cases we consider. • AdiabaticMSWes: For the NMO: For the IMO: In figure 8, we show the effect of these prescriptions on example neutrino spectra.
which leads to for both mass orderings. In figure 9, we show the effect of these prescriptions on example neutrino spectra.