Skip to content

Commit

Permalink
Merge branch 'nuclear-multimessenger-astronomy:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
haukekoehn authored Aug 31, 2023
2 parents b12c840 + 4b74bc6 commit df0e573
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
10 changes: 9 additions & 1 deletion doc/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,12 @@ We use a model from [Piro et al. 2021](https://arxiv.org/abs/2007.08543). Follow

### Supernovae

We rely on a few different models for supernovae from [sncosmo](https://github.com/sncosmo/sncosmo). For example, the nugent-hyper model [(Levan et al. 2005)](https://arxiv.org/abs/astro-ph/0403450) used for SN Ib/c supernovae with the stretch and scale set to match the intrinsic (dereddened, rest frame) $R$-band luminosity of SN 1998bw at maximum light. The main free parameter is the absolute magnitude.
We rely on models for supernovae from [sncosmo](https://github.com/sncosmo/sncosmo). For example, the nugent-hyper model [(Levan et al. 2005)](https://arxiv.org/abs/astro-ph/0403450) used for SN Ib/c supernovae with the stretch and scale set to match the intrinsic (dereddened, rest frame) $R$-band luminosity of SN 1998bw at maximum light. The main free parameter is the absolute magnitude.

All models listed [here](https://sncosmo.readthedocs.io/en/stable/source-list.html) can be used. We provide a prior file called sncosmo-generic.prior that only provides:

* luminosity distance
* timeshift
* supernova_mag_boost

The latter parameter shifts the absolute magnitude up and down.
17 changes: 6 additions & 11 deletions nmma/em/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
from scipy.special import logsumexp
import scipy.constants
from sncosmo.models import _SOURCES

from . import utils

Expand Down Expand Up @@ -725,7 +726,7 @@ def generate_lightcurve(self, sample_times, parameters):
filters=self.filters,
)

if self.model == "nugent-hyper":
if "supernova_mag_boost" in parameters:
for filt in mag.keys():
mag[filt] += parameters["supernova_mag_boost"]

Expand Down Expand Up @@ -1009,6 +1010,8 @@ def parameter_conversion(converted_parameters, added_keys):
else:
model_names = [model_name_arg]

sncosmo_names = [val["name"] for val in _SOURCES.get_loaders_metadata()]

for model_name in model_names:
if model_name == "TrPi2018":
lc_model = GRBLightCurveModel(
Expand All @@ -1019,18 +1022,10 @@ def parameter_conversion(converted_parameters, added_keys):
filters=filters,
)

elif model_name == "nugent-hyper":
lc_model = SupernovaLightCurveModel(
sample_times=sample_times,
model="nugent-hyper",
parameter_conversion=parameter_conversion,
filters=filters,
)

elif model_name == "salt2":
elif model_name in sncosmo_names:
lc_model = SupernovaLightCurveModel(
sample_times=sample_times,
model="salt2",
model=model_name,
parameter_conversion=parameter_conversion,
filters=filters,
)
Expand Down
6 changes: 3 additions & 3 deletions nmma/em/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,16 +621,16 @@ def sn_lc(
nus = scipy.constants.c / (1e-10 * lambdas)

model = sncosmo.Model(source=model_name)
if model_name == "nugent-hyper":
model.set(z=z)
elif model_name == "salt2":
if model_name in ["salt2", "salt3"]:
model.set(
z=z,
t0=np.median(tt),
x0=parameters["x0"],
x1=parameters["x1"],
c=parameters["c"],
)
else:
model.set(z=z)

# regularize the absolute magnitude
abs_mag -= Planck18.distmod(z).value
Expand Down
3 changes: 3 additions & 0 deletions nmma/eos/create_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ def main(args=None):
# check the binary type
assert args.binary_type in ["BNS", "NSBH"], "Unknown binary type"

seed = args.generation_seed
np.random.seed(seed)

# check injection file format
if args.injection_file:
assert (
Expand Down
5 changes: 4 additions & 1 deletion nmma/tests/injections.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def create_injection_from_command_line(model_name):
path to the injection file created by nmma_create_injection
"""

prior_path = os.path.join("./priors/", model_name + ".prior")
if model_name == "nugent-hyper":
prior_path = os.path.join("./priors/", "sncosmo-generic" + ".prior")
else:
prior_path = os.path.join("./priors/", model_name + ".prior")
assert os.path.exists(prior_path), "prior file does not exist"
injection_name = os.path.join(test_directory, model_name + "_injection.json")

Expand Down
2 changes: 1 addition & 1 deletion priors/nugent-hyper.prior → priors/sncosmo-generic.prior
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
luminosity_distance = Uniform(minimum=0, maximum=7000, name='luminosity_distance',latex_label='$D_L$')
luminosity_distance = Uniform(minimum=0, maximum=7000, name='luminosity_distance',latex_label='$D_L$')
timeshift = Uniform(minimum=-2.0, maximum=1.0, name='trigger_time',latex_label='$t_0$')
supernova_mag_boost = Uniform(name='supernova_mag_boost', minimum=-5., maximum=5., latex_label='$\\rm{SNmag}$')
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
luminosity_distance = Uniform(minimum=0, maximum=7000, name='luminosity_distance',latex_label='$D_L$')
redshift = Uniform(minimum=0.0, maximum=1.0, name='redshift')
luminosity_distance = Uniform(minimum=0, maximum=7000, name='luminosity_distance',latex_label='$D_L$')
redshift = Uniform(minimum=0.0, maximum=1.0, name='redshift')
timeshift = Uniform(minimum=-2.0, maximum=1.0, name='trigger_time',latex_label='$t_0$')
inclination_EM = Sine(name='inclination_EM', minimum=0, maximum=0.8, latex_label='$\\iota$')
log10_E0 = Uniform(name='log10_E0', minimum=0, maximum=70, latex_label='$\\log_{10}E_{0}$')
thetaCore = Uniform(name='thetaCore', minimum=0.01, maximum=np.pi / 2, latex_label='$\\theta_{c}$')
thetaWing = Uniform(name='thetaWing', minimum=0.01, maximum=np.pi / 2, latex_label='$\\theta_{w}$')
log10_n0 = Uniform(name='log10_n0', minimum=-4.9, maximum=10, latex_label='$\\log_{10}n_{0}$')
p = Uniform(name='p', minimum=2, maximum=8, latex_label='$p$')
log10_epsilon_e = Uniform(name='log10_epsilon_e', minimum=-4, maximum=0, latex_label='$\\log_{10}\\epsilon_{e}$')
log10_epsilon_B = Uniform(name='log10_epsilon_B', minimum=-5, maximum=0, latex_label='$\\log_{10}\\epsilon_{B}$')
inclination_EM = Sine(name='inclination_EM', minimum=0, maximum=0.8, latex_label='$\\iota$')
log10_E0 = Uniform(name='log10_E0', minimum=0, maximum=70, latex_label='$\\log_{10}E_{0}$')
thetaCore = Uniform(name='thetaCore', minimum=0.01, maximum=np.pi / 2, latex_label='$\\theta_{c}$')
thetaWing = Uniform(name='thetaWing', minimum=0.01, maximum=np.pi / 2, latex_label='$\\theta_{w}$')
log10_n0 = Uniform(name='log10_n0', minimum=-4.9, maximum=10, latex_label='$\\log_{10}n_{0}$')
p = Uniform(name='p', minimum=2, maximum=8, latex_label='$p$')
log10_epsilon_e = Uniform(name='log10_epsilon_e', minimum=-4, maximum=0, latex_label='$\\log_{10}\\epsilon_{e}$')
log10_epsilon_B = Uniform(name='log10_epsilon_B', minimum=-5, maximum=0, latex_label='$\\log_{10}\\epsilon_{B}$')
supernova_mag_boost = Uniform(name='supernova_mag_boost', minimum=-5., maximum=5., latex_label='$\\rm{SNmag}$')

0 comments on commit df0e573

Please sign in to comment.