redback 1.0.2__py3-none-any.whl → 1.0.31__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redback/__init__.py +1 -1
- redback/constraints.py +15 -0
- redback/eos.py +1 -0
- redback/get_data/fink.py +1 -1
- redback/model_library.py +2 -2
- redback/priors/bazin_sne.prior +5 -0
- redback/priors/csm_shock_and_arnett.prior +11 -0
- redback/priors/csm_shock_and_arnett_bolometric.prior +10 -0
- redback/priors/csm_shock_breakout.prior +7 -0
- redback/priors/nicholl_bns.prior +2 -1
- redback/priors/pwn.prior +7 -0
- redback/priors/shocked_cocoon.prior +6 -6
- redback/priors/sn_fallback.prior +8 -0
- redback/priors/stream_stream_tde.prior +10 -0
- redback/priors/stream_stream_tde_bolometric.prior +9 -0
- redback/priors/tde_fallback.prior +9 -0
- redback/priors/tde_fallback_bolometric.prior +6 -0
- redback/priors/tde_synchrotron.prior +6 -0
- redback/priors/two_comp_kne_rosswog_heatingrate.prior +2 -2
- redback/priors/villar_sne.prior +7 -0
- redback/priors.py +1 -1
- redback/simulate_transients.py +11 -4
- redback/tables/GRBs_w_redshift.txt +430 -413
- redback/tables/LGRB_table.txt +70 -6
- redback/tables/SGRB_table.txt +139 -135
- redback/tables/qdot_rosswogkorobkin24.pck +0 -0
- redback/transient/afterglow.py +14 -5
- redback/transient/kilonova.py +5 -2
- redback/transient/prompt.py +14 -4
- redback/transient/supernova.py +6 -2
- redback/transient/tde.py +5 -2
- redback/transient/transient.py +27 -10
- redback/transient_models/afterglow_models.py +110 -146
- redback/transient_models/combined_models.py +39 -33
- redback/transient_models/extinction_models.py +1 -2
- redback/transient_models/general_synchrotron_models.py +518 -0
- redback/transient_models/integrated_flux_afterglow_models.py +2 -2
- redback/transient_models/kilonova_models.py +88 -72
- redback/transient_models/magnetar_models.py +1 -1
- redback/transient_models/phenomenological_models.py +57 -2
- redback/transient_models/shock_powered_models.py +159 -110
- redback/transient_models/supernova_models.py +161 -7
- redback/transient_models/tde_models.py +849 -4
- redback/utils.py +28 -12
- {redback-1.0.2.dist-info → redback-1.0.31.dist-info}/METADATA +42 -5
- {redback-1.0.2.dist-info → redback-1.0.31.dist-info}/RECORD +49 -35
- {redback-1.0.2.dist-info → redback-1.0.31.dist-info}/WHEEL +1 -1
- {redback-1.0.2.dist-info → redback-1.0.31.dist-info}/LICENCE.md +0 -0
- {redback-1.0.2.dist-info → redback-1.0.31.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from inspect import isfunction
|
|
2
2
|
import numpy as np
|
|
3
3
|
|
|
4
|
-
from scipy.integrate import
|
|
4
|
+
from scipy.integrate import simpson
|
|
5
5
|
|
|
6
6
|
from redback.utils import logger, citation_wrapper
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ def integrated_flux_afterglowpy_base_model(time, **kwargs):
|
|
|
45
45
|
lightcurve_at_nu = flux_density.reshape(len(nu_1d), len(time))
|
|
46
46
|
prefactor = 1e-26
|
|
47
47
|
lightcurve_at_nu = prefactor * lightcurve_at_nu
|
|
48
|
-
integrated_flux =
|
|
48
|
+
integrated_flux = simpson(np.array(lightcurve_at_nu), axis=0, x=nu_1d)
|
|
49
49
|
return integrated_flux
|
|
50
50
|
|
|
51
51
|
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021arXiv210510108S/abstract')
|
|
@@ -4,13 +4,14 @@ import pandas as pd
|
|
|
4
4
|
from astropy.table import Table, Column
|
|
5
5
|
from scipy.interpolate import interp1d, RegularGridInterpolator
|
|
6
6
|
from astropy.cosmology import Planck18 as cosmo # noqa
|
|
7
|
-
from scipy.integrate import
|
|
7
|
+
from scipy.integrate import cumulative_trapezoid
|
|
8
8
|
from collections import namedtuple
|
|
9
9
|
from redback.photosphere import TemperatureFloor, CocoonPhotosphere
|
|
10
10
|
from redback.interaction_processes import Diffusion, AsphericalDiffusion
|
|
11
11
|
|
|
12
12
|
from redback.utils import calc_kcorrected_properties, interpolated_barnes_and_kasen_thermalisation_efficiency, \
|
|
13
|
-
electron_fraction_from_kappa, citation_wrapper, lambda_to_nu,
|
|
13
|
+
electron_fraction_from_kappa, citation_wrapper, lambda_to_nu, _calculate_rosswogkorobkin24_qdot, \
|
|
14
|
+
kappa_from_electron_fraction
|
|
14
15
|
from redback.eos import PiecewisePolytrope
|
|
15
16
|
from redback.sed import blackbody_to_flux_density, get_correct_output_format_from_spectra, Blackbody
|
|
16
17
|
from redback.constants import *
|
|
@@ -18,7 +19,7 @@ import redback.ejecta_relations as ejr
|
|
|
18
19
|
|
|
19
20
|
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021MNRAS.505.3016N/abstract')
|
|
20
21
|
def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
21
|
-
mtov, epsilon, alpha,
|
|
22
|
+
mtov, epsilon, alpha, cos_theta_open, cos_theta, **kwargs):
|
|
22
23
|
"""
|
|
23
24
|
Calculates quantities for the Nicholl et al. 2021 BNS model
|
|
24
25
|
|
|
@@ -31,7 +32,7 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
31
32
|
:param epsilon: fraction of disk that gets unbound/ejected
|
|
32
33
|
:param alpha: Enhancement of blue ejecta by NS surface winds if mtotal < prompt collapse,
|
|
33
34
|
can turn off by setting alpha=1
|
|
34
|
-
:param
|
|
35
|
+
:param cos_theta_open: Lanthanide opening angle
|
|
35
36
|
:param cos_theta: Viewing angle of observer
|
|
36
37
|
:param kwargs: Additional keyword arguments
|
|
37
38
|
:param dynamical_ejecta_error: Error in dynamical ejecta mass, default is 1 i.e., no error in fitting formula
|
|
@@ -50,7 +51,7 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
50
51
|
n_ave = 0.743
|
|
51
52
|
dynamical_ejecta_error = kwargs.get('dynamical_ejecta_error', 1.0)
|
|
52
53
|
disk_ejecta_error = kwargs.get('disk_ejecta_error', 1.0)
|
|
53
|
-
theta_open = np.arccos(
|
|
54
|
+
theta_open = np.arccos(cos_theta_open)
|
|
54
55
|
|
|
55
56
|
fq = (1 - (mass_2 / mass_1) ** (10. / (3 - n_ave))) / (1 + (mass_2 / mass_1) ** (10. / (3 - n_ave)))
|
|
56
57
|
|
|
@@ -210,14 +211,14 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
210
211
|
kappa_blue * mejecta_blue) / (mejecta_purple + mejecta_red + mejecta_blue)
|
|
211
212
|
|
|
212
213
|
# Viewing angle and lanthanide-poor opening angle correction from Darbha and Kasen 2020
|
|
213
|
-
ct = (1 -
|
|
214
|
+
ct = (1 - cos_theta_open ** 2) ** 0.5
|
|
214
215
|
|
|
215
|
-
if
|
|
216
|
+
if cos_theta > ct:
|
|
216
217
|
area_projected_top = np.pi * ct * cos_theta
|
|
217
218
|
else:
|
|
218
|
-
theta_p = np.arccos(
|
|
219
|
+
theta_p = np.arccos(cos_theta_open /
|
|
219
220
|
(1 - cos_theta ** 2) ** 0.5)
|
|
220
|
-
theta_d = np.arctan(np.sin(theta_p) /
|
|
221
|
+
theta_d = np.arctan(np.sin(theta_p) / cos_theta_open *
|
|
221
222
|
(1 - cos_theta ** 2) ** 0.5 / np.abs(cos_theta))
|
|
222
223
|
area_projected_top = (theta_p - np.sin(theta_p) * np.cos(theta_p)) - (ct *
|
|
223
224
|
cos_theta * (theta_d - np.sin(theta_d) * np.cos(
|
|
@@ -228,9 +229,9 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
228
229
|
if minus_cos_theta < -1 * ct:
|
|
229
230
|
area_projected_bottom = 0
|
|
230
231
|
else:
|
|
231
|
-
theta_p2 = np.arccos(
|
|
232
|
+
theta_p2 = np.arccos(cos_theta_open /
|
|
232
233
|
(1 - minus_cos_theta ** 2) ** 0.5)
|
|
233
|
-
theta_d2 = np.arctan(np.sin(theta_p2) /
|
|
234
|
+
theta_d2 = np.arctan(np.sin(theta_p2) / cos_theta_open *
|
|
234
235
|
(1 - minus_cos_theta ** 2) ** 0.5 / np.abs(minus_cos_theta))
|
|
235
236
|
|
|
236
237
|
Aproj_bot1 = (theta_p2 - np.sin(theta_p2) * np.cos(theta_p2)) + (ct *
|
|
@@ -247,9 +248,9 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
247
248
|
if cos_theta_ref > ct:
|
|
248
249
|
area_ref_top = np.pi * ct * cos_theta_ref
|
|
249
250
|
else:
|
|
250
|
-
theta_p_ref = np.arccos(
|
|
251
|
+
theta_p_ref = np.arccos(cos_theta_open /
|
|
251
252
|
(1 - cos_theta_ref ** 2) ** 0.5)
|
|
252
|
-
theta_d_ref = np.arctan(np.sin(theta_p_ref) /
|
|
253
|
+
theta_d_ref = np.arctan(np.sin(theta_p_ref) / cos_theta_open *
|
|
253
254
|
(1 - cos_theta_ref ** 2) ** 0.5 / np.abs(cos_theta_ref))
|
|
254
255
|
area_ref_top = (theta_p_ref - np.sin(theta_p_ref) *
|
|
255
256
|
np.cos(theta_p_ref)) - (ct * cos_theta_ref *
|
|
@@ -261,10 +262,10 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
261
262
|
if minus_cos_theta_ref < -1 * ct:
|
|
262
263
|
area_ref_bottom = 0
|
|
263
264
|
else:
|
|
264
|
-
theta_p2_ref = np.arccos(
|
|
265
|
+
theta_p2_ref = np.arccos(cos_theta_open /
|
|
265
266
|
(1 - minus_cos_theta_ref ** 2) ** 0.5)
|
|
266
267
|
theta_d2_ref = np.arctan(np.sin(theta_p2_ref) /
|
|
267
|
-
|
|
268
|
+
cos_theta_open * (1 - minus_cos_theta_ref ** 2) ** 0.5 /
|
|
268
269
|
np.abs(minus_cos_theta_ref))
|
|
269
270
|
|
|
270
271
|
area_ref_bottom = (theta_p2_ref - np.sin(theta_p2_ref) *
|
|
@@ -309,7 +310,7 @@ def _nicholl_bns_get_quantities(mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
309
310
|
|
|
310
311
|
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021MNRAS.505.3016N/abstract')
|
|
311
312
|
def nicholl_bns(time, redshift, mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
312
|
-
mtov, epsilon, alpha, cos_theta, cos_theta_cocoon, temperature_floor_1,
|
|
313
|
+
mtov, epsilon, alpha, cos_theta, cos_theta_open, cos_theta_cocoon, temperature_floor_1,
|
|
313
314
|
temperature_floor_2, temperature_floor_3, **kwargs):
|
|
314
315
|
"""
|
|
315
316
|
Kilonova model from Nicholl et al. 2021, inclides three kilonova components
|
|
@@ -327,6 +328,7 @@ def nicholl_bns(time, redshift, mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
327
328
|
:param alpha: Enhancement of blue ejecta by NS surface winds if mtotal < prompt collapse,
|
|
328
329
|
can turn off by setting alpha=1
|
|
329
330
|
:param cos_theta: Viewing angle of observer
|
|
331
|
+
:param cos_theta_open: Lanthanide opening angle
|
|
330
332
|
:param cos_theta_cocoon: Opening angle of shocked cocoon
|
|
331
333
|
:param temperature_floor_1: Temperature floor of first (blue) component
|
|
332
334
|
:param temperature_floor_2: Temperature floor of second (purple) component
|
|
@@ -351,11 +353,12 @@ def nicholl_bns(time, redshift, mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
351
353
|
cosmology = kwargs.get('cosmology', cosmo)
|
|
352
354
|
dl = cosmology.luminosity_distance(redshift).cgs.value
|
|
353
355
|
dense_resolution = kwargs.get('dense_resolution', 100)
|
|
354
|
-
time_temp = np.geomspace(0.
|
|
356
|
+
time_temp = np.geomspace(0.01, 30, dense_resolution) # in source frame and days
|
|
355
357
|
kappa_gamma = kwargs.get('kappa_gamma', 10)
|
|
358
|
+
ckm = 3e10/1e5
|
|
356
359
|
|
|
357
360
|
if np.max(time) > 20: # in source frame and days
|
|
358
|
-
time_temp = np.geomspace(0.
|
|
361
|
+
time_temp = np.geomspace(0.01, np.max(time) + 5, dense_resolution)
|
|
359
362
|
|
|
360
363
|
time_obs = time
|
|
361
364
|
shocked_fraction = kwargs.get('shocked_fraction', 0.2)
|
|
@@ -364,14 +367,14 @@ def nicholl_bns(time, redshift, mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
364
367
|
|
|
365
368
|
output = _nicholl_bns_get_quantities(mass_1=mass_1, mass_2=mass_2, lambda_s=lambda_s,
|
|
366
369
|
kappa_red=kappa_red, kappa_blue=kappa_blue, mtov=mtov,
|
|
367
|
-
epsilon=epsilon, alpha=alpha,
|
|
370
|
+
epsilon=epsilon, alpha=alpha, cos_theta_open=cos_theta_open,
|
|
368
371
|
cos_theta=cos_theta, **kwargs)
|
|
369
372
|
cocoon_output = _shocked_cocoon_nicholl(time=time_temp, kappa=kappa_blue, mejecta=output.mejecta_blue,
|
|
370
373
|
vejecta=output.vejecta_blue, cos_theta_cocoon=cos_theta_cocoon,
|
|
371
374
|
shocked_fraction=shocked_fraction, nn=nn, tshock=tshock)
|
|
372
375
|
cocoon_photo = CocoonPhotosphere(time=time_temp, luminosity=cocoon_output.lbol,
|
|
373
376
|
tau_diff=cocoon_output.taudiff, t_thin=cocoon_output.tthin,
|
|
374
|
-
vej=output.vejecta_blue, nn=nn)
|
|
377
|
+
vej=output.vejecta_blue*ckm, nn=nn)
|
|
375
378
|
mejs = [output.mejecta_blue, output.mejecta_purple, output.mejecta_red]
|
|
376
379
|
vejs = [output.vejecta_blue, output.vejecta_purple, output.vejecta_red]
|
|
377
380
|
area_projs = [output.area_blue, output.area_blue, output.area_red]
|
|
@@ -386,26 +389,29 @@ def nicholl_bns(time, redshift, mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
386
389
|
rad_func = interp1d(time_temp, y=cocoon_photo.r_photosphere)
|
|
387
390
|
# convert to source frame time and frequency
|
|
388
391
|
frequency, time = calc_kcorrected_properties(frequency=frequency, redshift=redshift, time=time)
|
|
389
|
-
temp = temp_func(
|
|
390
|
-
photosphere = rad_func(
|
|
392
|
+
temp = temp_func(time)
|
|
393
|
+
photosphere = rad_func(time)
|
|
391
394
|
flux_density = blackbody_to_flux_density(temperature=temp, r_photosphere=photosphere,
|
|
392
395
|
dl=dl, frequency=frequency)
|
|
393
396
|
ff = flux_density.value
|
|
397
|
+
ff = np.nan_to_num(ff)
|
|
394
398
|
for x in range(3):
|
|
395
399
|
lbols = _mosfit_kilonova_one_component_lbol(time=time_temp*day_to_s, mej=mejs[x], vej=vejs[x])
|
|
396
|
-
interaction_class = AsphericalDiffusion(time=time_temp
|
|
400
|
+
interaction_class = AsphericalDiffusion(time=time_temp, dense_times=time_temp,
|
|
397
401
|
luminosity=lbols, kappa=kappas[x], kappa_gamma=kappa_gamma,
|
|
398
|
-
mej=mejs[x], vej=vejs[x], area_projection=area_projs[x],
|
|
402
|
+
mej=mejs[x], vej=vejs[x]*ckm, area_projection=area_projs[x],
|
|
399
403
|
area_reference=area_refs[x])
|
|
400
404
|
lbols = interaction_class.new_luminosity
|
|
401
|
-
|
|
402
|
-
|
|
405
|
+
lbols = np.nan_to_num(lbols)
|
|
406
|
+
photo = TemperatureFloor(time=time_temp, luminosity=lbols,
|
|
407
|
+
temperature_floor=temperature_floors[x], vej=vejs[x]*ckm)
|
|
403
408
|
temp_func = interp1d(time_temp, y=photo.photosphere_temperature)
|
|
404
409
|
rad_func = interp1d(time_temp, y=photo.r_photosphere)
|
|
405
410
|
temp = temp_func(time)
|
|
406
411
|
photosphere = rad_func(time)
|
|
407
412
|
flux_density = blackbody_to_flux_density(temperature=temp, r_photosphere=photosphere,
|
|
408
413
|
dl=dl, frequency=frequency)
|
|
414
|
+
flux_density = np.nan_to_num(flux_density)
|
|
409
415
|
units = flux_density.unit
|
|
410
416
|
ff += flux_density.value
|
|
411
417
|
ff = ff * units
|
|
@@ -420,22 +426,24 @@ def nicholl_bns(time, redshift, mass_1, mass_2, lambda_s, kappa_red, kappa_blue,
|
|
|
420
426
|
frequency=frequency[:,None]).T
|
|
421
427
|
cocoon_spectra = fmjy.to(uu.mJy).to(uu.erg / uu.cm ** 2 / uu.s / uu.Angstrom,
|
|
422
428
|
equivalencies=uu.spectral_density(wav=lambda_observer_frame * uu.Angstrom))
|
|
429
|
+
cocoon_spectra = np.nan_to_num(cocoon_spectra)
|
|
423
430
|
full_spec = cocoon_spectra.value
|
|
424
431
|
for x in range(3):
|
|
425
432
|
lbols = _mosfit_kilonova_one_component_lbol(time=time_temp*day_to_s, mej=mejs[x], vej=vejs[x])
|
|
426
|
-
interaction_class = AsphericalDiffusion(time=time_temp
|
|
433
|
+
interaction_class = AsphericalDiffusion(time=time_temp, dense_times=time_temp,
|
|
427
434
|
luminosity=lbols, kappa=kappas[x], kappa_gamma=kappa_gamma,
|
|
428
|
-
mej=mejs[x], vej=vejs[x], area_projection=area_projs[x],
|
|
435
|
+
mej=mejs[x], vej=vejs[x]*ckm, area_projection=area_projs[x],
|
|
429
436
|
area_reference=area_refs[x])
|
|
430
437
|
lbols = interaction_class.new_luminosity
|
|
431
|
-
photo = TemperatureFloor(time=time_temp
|
|
432
|
-
temperature_floor=temperature_floors[x], vej=vejs[x])
|
|
438
|
+
photo = TemperatureFloor(time=time_temp, luminosity=lbols,
|
|
439
|
+
temperature_floor=temperature_floors[x], vej=vejs[x]*ckm)
|
|
433
440
|
fmjy = blackbody_to_flux_density(temperature=photo.photosphere_temperature,
|
|
434
441
|
r_photosphere=photo.r_photosphere, dl=dl,
|
|
435
442
|
frequency=frequency[:, None])
|
|
436
443
|
fmjy = fmjy.T
|
|
437
444
|
spectra = fmjy.to(uu.mJy).to(uu.erg / uu.cm ** 2 / uu.s / uu.Angstrom,
|
|
438
445
|
equivalencies=uu.spectral_density(wav=lambda_observer_frame * uu.Angstrom))
|
|
446
|
+
spectra = np.nan_to_num(spectra)
|
|
439
447
|
units = spectra.unit
|
|
440
448
|
full_spec += spectra.value
|
|
441
449
|
|
|
@@ -459,7 +467,7 @@ def mosfit_rprocess(time, redshift, mej, vej, kappa, kappa_gamma, temperature_fl
|
|
|
459
467
|
:param time: observer frame time in days
|
|
460
468
|
:param redshift: redshift
|
|
461
469
|
:param mej: ejecta mass in solar masses of first component
|
|
462
|
-
:param vej: minimum initial velocity of first component
|
|
470
|
+
:param vej: minimum initial velocity of first component in units of c
|
|
463
471
|
:param kappa: gray opacity of first component
|
|
464
472
|
:param temperature_floor: floor temperature of first component
|
|
465
473
|
:param kappa_gamma: gamma-ray opacity
|
|
@@ -473,25 +481,26 @@ def mosfit_rprocess(time, redshift, mej, vej, kappa, kappa_gamma, temperature_fl
|
|
|
473
481
|
:param cosmology: Cosmology to use for luminosity distance calculation. Defaults to Planck18. Must be a astropy.cosmology object.
|
|
474
482
|
:return: set by output format - 'flux_density', 'magnitude', 'spectra', 'flux', 'sncosmo_source'
|
|
475
483
|
"""
|
|
484
|
+
ckm = 3e10/1e5
|
|
476
485
|
cosmology = kwargs.get('cosmology', cosmo)
|
|
477
486
|
dl = cosmology.luminosity_distance(redshift).cgs.value
|
|
478
487
|
dense_resolution = kwargs.get('dense_resolution', 300)
|
|
479
|
-
time_temp = np.geomspace(1e-2, 7e6, dense_resolution) # in source frame
|
|
488
|
+
time_temp = np.geomspace(1e-2, 7e6, dense_resolution) # in source frame in seconds
|
|
480
489
|
time_obs = time
|
|
481
490
|
lbols = _mosfit_kilonova_one_component_lbol(time=time_temp,
|
|
482
491
|
mej=mej, vej=vej)
|
|
483
|
-
interaction_class = Diffusion(time=time_temp, dense_times=time_temp, luminosity=lbols,
|
|
484
|
-
kappa=kappa, kappa_gamma=kappa_gamma, mej=mej, vej=vej)
|
|
492
|
+
interaction_class = Diffusion(time=time_temp / day_to_s, dense_times=time_temp / day_to_s, luminosity=lbols,
|
|
493
|
+
kappa=kappa, kappa_gamma=kappa_gamma, mej=mej, vej=vej*ckm)
|
|
485
494
|
lbols = interaction_class.new_luminosity
|
|
486
|
-
photo = TemperatureFloor(time=time_temp, luminosity=lbols, vej=vej,
|
|
495
|
+
photo = TemperatureFloor(time=time_temp / day_to_s, luminosity=lbols, vej=vej*ckm,
|
|
487
496
|
temperature_floor=temperature_floor)
|
|
488
497
|
|
|
489
498
|
if kwargs['output_format'] == 'flux_density':
|
|
490
|
-
time = time_obs * day_to_s
|
|
499
|
+
#time = time_obs * day_to_s
|
|
491
500
|
frequency = kwargs['frequency']
|
|
492
501
|
# interpolate properties onto observation times
|
|
493
|
-
temp_func = interp1d(time_temp, y=photo.photosphere_temperature)
|
|
494
|
-
rad_func = interp1d(time_temp, y=photo.r_photosphere)
|
|
502
|
+
temp_func = interp1d(time_temp / day_to_s, y=photo.photosphere_temperature)
|
|
503
|
+
rad_func = interp1d(time_temp / day_to_s, y=photo.r_photosphere)
|
|
495
504
|
# convert to source frame time and frequency
|
|
496
505
|
frequency, time = calc_kcorrected_properties(frequency=frequency, redshift=redshift, time=time)
|
|
497
506
|
temp = temp_func(time)
|
|
@@ -501,7 +510,7 @@ def mosfit_rprocess(time, redshift, mej, vej, kappa, kappa_gamma, temperature_fl
|
|
|
501
510
|
return flux_density.to(uu.mJy).value
|
|
502
511
|
else:
|
|
503
512
|
lambda_observer_frame = kwargs.get('lambda_array', np.geomspace(100, 60000, 200))
|
|
504
|
-
time_observer_frame = time_temp * (1. + redshift)
|
|
513
|
+
time_observer_frame = time_temp / day_to_s * (1. + redshift) # in days
|
|
505
514
|
frequency, time = calc_kcorrected_properties(frequency=lambda_to_nu(lambda_observer_frame),
|
|
506
515
|
redshift=redshift, time=time_observer_frame)
|
|
507
516
|
fmjy = blackbody_to_flux_density(temperature=photo.photosphere_temperature,
|
|
@@ -514,7 +523,7 @@ def mosfit_rprocess(time, redshift, mej, vej, kappa, kappa_gamma, temperature_fl
|
|
|
514
523
|
lambdas=lambda_observer_frame,
|
|
515
524
|
spectra=spectra)
|
|
516
525
|
else:
|
|
517
|
-
return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame
|
|
526
|
+
return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
|
|
518
527
|
spectra=spectra, lambda_array=lambda_observer_frame,
|
|
519
528
|
**kwargs)
|
|
520
529
|
|
|
@@ -530,15 +539,15 @@ def mosfit_kilonova(time, redshift, mej_1, vej_1, temperature_floor_1, kappa_1,
|
|
|
530
539
|
:param time: observer frame time in days
|
|
531
540
|
:param redshift: redshift
|
|
532
541
|
:param mej_1: ejecta mass in solar masses of first component
|
|
533
|
-
:param vej_1: minimum initial velocity of first component
|
|
542
|
+
:param vej_1: minimum initial velocity of first component in units of c
|
|
534
543
|
:param kappa_1: gray opacity of first component
|
|
535
544
|
:param temperature_floor_1: floor temperature of first component
|
|
536
545
|
:param mej_2: ejecta mass in solar masses of second component
|
|
537
|
-
:param vej_2: minimum initial velocity of second component
|
|
546
|
+
:param vej_2: minimum initial velocity of second component in units of c
|
|
538
547
|
:param temperature_floor_2: floor temperature of second component
|
|
539
548
|
:param kappa_2: gray opacity of second component
|
|
540
549
|
:param mej_3: ejecta mass in solar masses of third component
|
|
541
|
-
:param vej_3: minimum initial velocity of third component
|
|
550
|
+
:param vej_3: minimum initial velocity of third component in units of c
|
|
542
551
|
:param temperature_floor_3: floor temperature of third component
|
|
543
552
|
:param kappa_3: gray opacity of third component
|
|
544
553
|
:param kappa_gamma: gamma-ray opacity
|
|
@@ -552,17 +561,18 @@ def mosfit_kilonova(time, redshift, mej_1, vej_1, temperature_floor_1, kappa_1,
|
|
|
552
561
|
:param cosmology: Cosmology to use for luminosity distance calculation. Defaults to Planck18. Must be a astropy.cosmology object.
|
|
553
562
|
:return: set by output format - 'flux_density', 'magnitude', 'spectra', 'flux', 'sncosmo_source'
|
|
554
563
|
"""
|
|
564
|
+
ckm = 3e10/1e5
|
|
555
565
|
cosmology = kwargs.get('cosmology', cosmo)
|
|
556
566
|
dl = cosmology.luminosity_distance(redshift).cgs.value
|
|
557
567
|
dense_resolution = kwargs.get('dense_resolution', 300)
|
|
558
|
-
time_temp = np.geomspace(1e-2, 7e6, dense_resolution) # in source frame
|
|
568
|
+
time_temp = np.geomspace(1e-2, 7e6, dense_resolution) # in source frame in s
|
|
559
569
|
time_obs = time
|
|
560
570
|
mej = [mej_1, mej_2, mej_3]
|
|
561
571
|
vej = [vej_1, vej_2, vej_3]
|
|
562
572
|
temperature_floor = [temperature_floor_1, temperature_floor_2, temperature_floor_3]
|
|
563
573
|
kappa = [kappa_1, kappa_2, kappa_3]
|
|
564
574
|
if kwargs['output_format'] == 'flux_density':
|
|
565
|
-
time = time_obs * day_to_s
|
|
575
|
+
#time = time_obs * day_to_s
|
|
566
576
|
frequency = kwargs['frequency']
|
|
567
577
|
frequency, time = calc_kcorrected_properties(frequency=frequency, redshift=redshift, time=time)
|
|
568
578
|
|
|
@@ -570,13 +580,13 @@ def mosfit_kilonova(time, redshift, mej_1, vej_1, temperature_floor_1, kappa_1,
|
|
|
570
580
|
for x in range(3):
|
|
571
581
|
lbols = _mosfit_kilonova_one_component_lbol(time=time_temp,
|
|
572
582
|
mej=mej[x], vej=vej[x])
|
|
573
|
-
interaction_class = Diffusion(time=time_temp, dense_times=time_temp, luminosity=lbols,
|
|
574
|
-
kappa=kappa[x], kappa_gamma=kappa_gamma, mej=mej[x], vej=vej[x])
|
|
583
|
+
interaction_class = Diffusion(time=time_temp / day_to_s, dense_times=time_temp / day_to_s, luminosity=lbols,
|
|
584
|
+
kappa=kappa[x], kappa_gamma=kappa_gamma, mej=mej[x], vej=vej[x]*ckm)
|
|
575
585
|
lbols = interaction_class.new_luminosity
|
|
576
|
-
photo = TemperatureFloor(time=time_temp, luminosity=lbols, vej=vej[x],
|
|
586
|
+
photo = TemperatureFloor(time=time_temp / day_to_s, luminosity=lbols, vej=vej[x]*ckm,
|
|
577
587
|
temperature_floor=temperature_floor[x])
|
|
578
|
-
temp_func = interp1d(time_temp, y=photo.photosphere_temperature)
|
|
579
|
-
rad_func = interp1d(time_temp, y=photo.r_photosphere)
|
|
588
|
+
temp_func = interp1d(time_temp / day_to_s, y=photo.photosphere_temperature)
|
|
589
|
+
rad_func = interp1d(time_temp / day_to_s, y=photo.r_photosphere)
|
|
580
590
|
# convert to source frame time and frequency
|
|
581
591
|
temp = temp_func(time)
|
|
582
592
|
photosphere = rad_func(time)
|
|
@@ -588,17 +598,17 @@ def mosfit_kilonova(time, redshift, mej_1, vej_1, temperature_floor_1, kappa_1,
|
|
|
588
598
|
return ff.to(uu.mJy).value
|
|
589
599
|
else:
|
|
590
600
|
lambda_observer_frame = kwargs.get('lambda_array', np.geomspace(100, 60000, 200))
|
|
591
|
-
time_observer_frame = time_temp * (1. + redshift)
|
|
601
|
+
time_observer_frame = time_temp / day_to_s * (1. + redshift) # in days
|
|
592
602
|
frequency, time = calc_kcorrected_properties(frequency=lambda_to_nu(lambda_observer_frame),
|
|
593
603
|
redshift=redshift, time=time_observer_frame)
|
|
594
604
|
full_spec = np.zeros((len(time), len(frequency)))
|
|
595
605
|
for x in range(3):
|
|
596
606
|
lbols = _mosfit_kilonova_one_component_lbol(time=time_temp,
|
|
597
607
|
mej=mej[x], vej=vej[x])
|
|
598
|
-
interaction_class = Diffusion(time=time_temp, dense_times=time_temp, luminosity=lbols,
|
|
599
|
-
kappa=kappa[x], kappa_gamma=kappa_gamma, mej=mej[x], vej=vej[x])
|
|
608
|
+
interaction_class = Diffusion(time=time_temp / day_to_s, dense_times=time_temp / day_to_s, luminosity=lbols,
|
|
609
|
+
kappa=kappa[x], kappa_gamma=kappa_gamma, mej=mej[x], vej=vej[x]*ckm)
|
|
600
610
|
lbols = interaction_class.new_luminosity
|
|
601
|
-
photo = TemperatureFloor(time=time_temp, luminosity=lbols, vej=vej[x],
|
|
611
|
+
photo = TemperatureFloor(time=time_temp / day_to_s, luminosity=lbols, vej=vej[x]*ckm,
|
|
602
612
|
temperature_floor=temperature_floor[x])
|
|
603
613
|
fmjy = blackbody_to_flux_density(temperature=photo.photosphere_temperature,
|
|
604
614
|
r_photosphere=photo.r_photosphere, frequency=frequency[:, None], dl=dl).T
|
|
@@ -613,7 +623,7 @@ def mosfit_kilonova(time, redshift, mej_1, vej_1, temperature_floor_1, kappa_1,
|
|
|
613
623
|
lambdas=lambda_observer_frame,
|
|
614
624
|
spectra=full_spec)
|
|
615
625
|
else:
|
|
616
|
-
return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame
|
|
626
|
+
return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
|
|
617
627
|
spectra=full_spec, lambda_array=lambda_observer_frame,
|
|
618
628
|
**kwargs)
|
|
619
629
|
|
|
@@ -1424,7 +1434,7 @@ def one_component_kilonova_model(time, redshift, mej, vej, kappa, **kwargs):
|
|
|
1424
1434
|
|
|
1425
1435
|
def _calc_new_heating_rate(time, mej, electron_fraction, ejecta_velocity, **kwargs):
|
|
1426
1436
|
"""
|
|
1427
|
-
Heating rate prescription following Rosswog and Korobkin
|
|
1437
|
+
Heating rate prescription following Rosswog and Korobkin 2024
|
|
1428
1438
|
|
|
1429
1439
|
:param time: time in seconds
|
|
1430
1440
|
:param mej: ejecta mass in solar masses
|
|
@@ -1436,23 +1446,29 @@ def _calc_new_heating_rate(time, mej, electron_fraction, ejecta_velocity, **kwar
|
|
|
1436
1446
|
Default is 1.0 i.e., no perturbation.
|
|
1437
1447
|
:return: heating rate in erg/s
|
|
1438
1448
|
"""
|
|
1439
|
-
heating_terms = get_heating_terms(electron_fraction, ejecta_velocity, **kwargs)
|
|
1440
1449
|
heating_rate_perturbation = kwargs.get('heating_rate_perturbation', 1.0)
|
|
1441
1450
|
# rescale
|
|
1442
1451
|
m0 = mej * solar_mass
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1452
|
+
qdot_in = _calculate_rosswogkorobkin24_qdot(time, ejecta_velocity, electron_fraction)
|
|
1453
|
+
lum_in = qdot_in * m0
|
|
1454
|
+
return lum_in * heating_rate_perturbation
|
|
1455
|
+
|
|
1456
|
+
def _calculate_rosswogkorobkin24_qdot_formula(time_array, e0, alp, t0, sig, alp1,
|
|
1457
|
+
t1, sig1, c1, tau1, c2, tau2, c3, tau3):
|
|
1458
|
+
time = time_array
|
|
1459
|
+
c1 = np.exp(c1)
|
|
1460
|
+
c2 = np.exp(c2)
|
|
1461
|
+
c3 = np.exp(c3)
|
|
1462
|
+
tau1 = 1e3 * tau1
|
|
1463
|
+
tau2 = 1e5 * tau2
|
|
1464
|
+
tau3 = 1e5 * tau3
|
|
1465
|
+
term1 = 10. ** (e0 + 18) * (0.5 - np.arctan((time - t0) / sig) / np.pi) ** alp
|
|
1466
|
+
term2 = (0.5 + np.arctan((time - t1) / sig1) / np.pi) ** alp1
|
|
1467
|
+
term3 = c1 * np.exp(-time / tau1)
|
|
1468
|
+
term4 = c2 * np.exp(-time / tau2)
|
|
1469
|
+
term5 = c3 * np.exp(-time / tau3)
|
|
1470
|
+
lum_in = term1 * term2 + term3 + term4 + term5
|
|
1471
|
+
return lum_in
|
|
1456
1472
|
|
|
1457
1473
|
def _one_component_kilonova_rosswog_heatingrate(time, mej, vej, electron_fraction, **kwargs):
|
|
1458
1474
|
tdays = time/day_to_s
|
|
@@ -1472,7 +1488,7 @@ def _one_component_kilonova_rosswog_heatingrate(time, mej, vej, electron_fractio
|
|
|
1472
1488
|
integrand = lum_in * e_th * (time / tdiff) * np.exp(time ** 2 / tdiff ** 2)
|
|
1473
1489
|
|
|
1474
1490
|
bolometric_luminosity = np.zeros(len(time))
|
|
1475
|
-
bolometric_luminosity[1:] =
|
|
1491
|
+
bolometric_luminosity[1:] = cumulative_trapezoid(integrand, time)
|
|
1476
1492
|
bolometric_luminosity[0] = bolometric_luminosity[1]
|
|
1477
1493
|
bolometric_luminosity = bolometric_luminosity * np.exp(-time ** 2 / tdiff ** 2) / tdiff
|
|
1478
1494
|
|
|
@@ -1677,7 +1693,7 @@ def _one_component_kilonova_model(time, mej, vej, kappa, **kwargs):
|
|
|
1677
1693
|
lum_in = 4.0e18 * (m0) * (0.5 - np.arctan((time - t0) / sig) / np.pi)**1.3
|
|
1678
1694
|
integrand = lum_in * e_th * (time/tdiff) * np.exp(time**2/tdiff**2)
|
|
1679
1695
|
bolometric_luminosity = np.zeros(len(time))
|
|
1680
|
-
bolometric_luminosity[1:] =
|
|
1696
|
+
bolometric_luminosity[1:] = cumulative_trapezoid(integrand, time)
|
|
1681
1697
|
bolometric_luminosity[0] = bolometric_luminosity[1]
|
|
1682
1698
|
bolometric_luminosity = bolometric_luminosity * np.exp(-time**2/tdiff**2) / tdiff
|
|
1683
1699
|
|
|
@@ -4,7 +4,7 @@ from astropy.cosmology import Planck18 as cosmo # noqa
|
|
|
4
4
|
import scipy.special as ss
|
|
5
5
|
from collections import namedtuple
|
|
6
6
|
from scipy.interpolate import interp1d
|
|
7
|
-
from scipy.integrate import quad, cumtrapz
|
|
7
|
+
from scipy.integrate import quad, cumulative_trapezoid as cumtrapz
|
|
8
8
|
from inspect import isfunction
|
|
9
9
|
from redback.utils import logger, citation_wrapper
|
|
10
10
|
|
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
+
from redback.utils import citation_wrapper
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2009A%26A...499..653B/abstract')
|
|
5
|
+
def bazin_sne(time, aa, bb, t0, tau_rise, tau_fall, **kwargs):
|
|
6
|
+
"""
|
|
7
|
+
Bazin function for CCSN light curves
|
|
8
|
+
|
|
9
|
+
:param time: time array in arbitrary units
|
|
10
|
+
:param aa: Normalisation on the Bazin function
|
|
11
|
+
:param bb: Additive constant
|
|
12
|
+
:param t0: start time
|
|
13
|
+
:param tau_rise: exponential rise time
|
|
14
|
+
:param tau_fall: exponential fall time
|
|
15
|
+
:return: flux in units set by AA
|
|
16
|
+
"""
|
|
17
|
+
flux = aa * np.exp(-((time - t0) / tau_fall) / (1 + np.exp(-(time - t0) / tau_rise))) + bb
|
|
18
|
+
return flux
|
|
19
|
+
|
|
20
|
+
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2019ApJ...884...83V/abstract, https://ui.adsabs.harvard.edu/abs/1982ApJ...253..785A/abstract')
|
|
21
|
+
def villar_sne(time, aa, cc, t0, tau_rise, tau_fall, gamma, nu, **kwargs):
|
|
22
|
+
"""
|
|
23
|
+
Villar function for SN light curves
|
|
24
|
+
|
|
25
|
+
:param time: time array in arbitrary units
|
|
26
|
+
:param aa: normalisation on the Villar function, amplotude
|
|
27
|
+
:param cc: additive constant, baseline flux
|
|
28
|
+
:param t0: start time
|
|
29
|
+
:param tau_rise: exponential rise time
|
|
30
|
+
:param tau_fall: exponential fall time
|
|
31
|
+
:param gamma: plateau duration
|
|
32
|
+
:param nu: related to beta and between 0 an 1; nu = -beta/gamma / A
|
|
33
|
+
:param kwargs:
|
|
34
|
+
:return: flux in units set by AA
|
|
35
|
+
"""
|
|
36
|
+
mask1 = time < t0 + gamma
|
|
37
|
+
mask2 = (time >= t0 + gamma)
|
|
38
|
+
flux = np.zeros_like(time)
|
|
39
|
+
norm = cc + (aa / (1 + np.exp(-(time - t0)/tau_rise)))
|
|
40
|
+
flux[mask1] = norm[mask1] * (1 - (nu * ((time[mask1] - t0)/gamma)))
|
|
41
|
+
flux[mask2] = norm[mask2] * ((1 - nu) * np.exp(-((time[mask2] - t0 - gamma)/tau_fall)))
|
|
42
|
+
return np.concatenate((flux[mask1], flux[mask2]))
|
|
43
|
+
|
|
44
|
+
def fallback_lbol(time, logl1, tr, **kwargs):
|
|
45
|
+
"""
|
|
46
|
+
:param time: time in seconds
|
|
47
|
+
:param logl1: luminosity scale in log 10 ergs
|
|
48
|
+
:param tr: transition time for flat luminosity to power-law decay
|
|
49
|
+
:return: lbol
|
|
50
|
+
"""
|
|
51
|
+
l1 = 10**logl1
|
|
52
|
+
time = time * 86400
|
|
53
|
+
tr = tr * 86400
|
|
54
|
+
lbol = l1 * time**(-5./3.)
|
|
55
|
+
lbol[time < tr] = l1 * tr**(-5./3.)
|
|
56
|
+
return lbol
|
|
57
|
+
|
|
58
|
+
def line_spectrum(wavelength, line_amp, cont_amp, x0, **kwargs):
|
|
4
59
|
"""
|
|
5
60
|
A gaussian to add or subtract from a continuum spectrum to mimic absorption or emission lines
|
|
6
61
|
|
|
@@ -13,7 +68,7 @@ def line_spectrum(wavelength, line_amp, cont_amp, x0):
|
|
|
13
68
|
spectrum = line_amp / cont_amp * np.exp(-(wavelength - x0) ** 2. / (2 * cont_amp ** 2) )
|
|
14
69
|
return spectrum
|
|
15
70
|
|
|
16
|
-
def gaussian_rise(time, a_1, peak_time, sigma_t):
|
|
71
|
+
def gaussian_rise(time, a_1, peak_time, sigma_t, **kwargs):
|
|
17
72
|
"""
|
|
18
73
|
:param time: time array in whatver time units
|
|
19
74
|
:param a_1: gaussian rise amplitude scale
|