redback 1.1__py3-none-any.whl → 1.12.1__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/filters.py +57 -45
- redback/likelihoods.py +274 -6
- redback/model_library.py +2 -2
- redback/plotting.py +5 -3
- redback/priors/blackbody_spectrum_at_z.prior +3 -0
- redback/priors/bpl_cooling_envelope.prior +9 -0
- redback/priors/gaussianrise_cooling_envelope.prior +1 -5
- redback/priors/gaussianrise_cooling_envelope_bolometric.prior +1 -5
- redback/priors/powerlaw_plus_blackbody.prior +12 -0
- redback/priors/powerlaw_plus_blackbody_spectrum_at_z.prior +13 -0
- redback/priors/salt2.prior +6 -0
- redback/priors/shock_cooling_and_arnett_bolometric.prior +11 -0
- redback/priors/smooth_exponential_powerlaw_cooling_envelope_bolometric.prior +9 -0
- redback/priors/sn_nickel_fallback.prior +9 -0
- redback/priors/wr_bh_merger.prior +10 -0
- redback/priors/wr_bh_merger_bolometric.prior +8 -0
- redback/priors.py +14 -3
- redback/sed.py +185 -41
- redback/simulate_transients.py +13 -3
- redback/tables/filters.csv +260 -258
- redback/tables/qdot_rosswogkorobkin24.npz +0 -0
- redback/transient_models/afterglow_models.py +32 -16
- redback/transient_models/combined_models.py +16 -11
- redback/transient_models/extinction_models.py +310 -84
- redback/transient_models/gaussianprocess_models.py +1 -12
- redback/transient_models/kilonova_models.py +3 -3
- redback/transient_models/phase_models.py +97 -43
- redback/transient_models/phenomenological_models.py +172 -0
- redback/transient_models/spectral_models.py +101 -0
- redback/transient_models/stellar_interaction_models.py +254 -0
- redback/transient_models/supernova_models.py +349 -62
- redback/transient_models/tde_models.py +193 -54
- redback/utils.py +34 -7
- {redback-1.1.dist-info → redback-1.12.1.dist-info}/METADATA +7 -4
- {redback-1.1.dist-info → redback-1.12.1.dist-info}/RECORD +39 -28
- {redback-1.1.dist-info → redback-1.12.1.dist-info}/WHEEL +1 -1
- redback/tables/qdot_rosswogkorobkin24.pck +0 -0
- {redback-1.1.dist-info → redback-1.12.1.dist-info}/licenses/LICENCE.md +0 -0
- {redback-1.1.dist-info → redback-1.12.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from collections import namedtuple
|
|
3
|
+
import redback.interaction_processes as ip
|
|
4
|
+
import redback.sed as sed
|
|
5
|
+
import redback.photosphere as photosphere
|
|
6
|
+
from astropy.cosmology import Planck18 as cosmo
|
|
7
|
+
from redback.utils import calc_kcorrected_properties, citation_wrapper, lambda_to_nu
|
|
8
|
+
from redback.constants import *
|
|
9
|
+
from scipy.interpolate import interp1d
|
|
10
|
+
|
|
11
|
+
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2022ApJ...932...84M')
|
|
12
|
+
def _wr_bh_merger(time, M_star, M_bh, M_fast, M_pre, v_fast, v_slow, alpha, eta, theta, phi_0, kappa_s, kappa_f, kappa_x, N, **kwargs):
|
|
13
|
+
"""
|
|
14
|
+
Parameters:
|
|
15
|
+
:param time: time in source frame in seconds
|
|
16
|
+
:param M_star: Mass of the Wolf-Rayet star in solar masses
|
|
17
|
+
:param M_bh: Mass of the black hole in solar masses
|
|
18
|
+
:param M_fast: Mass of the fast component in solar masses
|
|
19
|
+
:param M_pre: Mass of the pre-merger CSM in solar masses
|
|
20
|
+
:param v_fast: Velocity of the fast component in units of c
|
|
21
|
+
:param v_slow: Velocity of the slow component in km/s
|
|
22
|
+
:param alpha: Viscosity parameter
|
|
23
|
+
:param eta: Efficiency of conversion of accretion energy to radiation
|
|
24
|
+
:param theta: Disk aspect ratio
|
|
25
|
+
:param phi_0: Solid angle of the slow component
|
|
26
|
+
:param kappa_s: Opacity of the slow component
|
|
27
|
+
:param kappa_f: Opacity of the fast component
|
|
28
|
+
:param kappa_x: Opacity of the x-ray component
|
|
29
|
+
:param N: Number of pre-merger orbits
|
|
30
|
+
:param kwargs: Additional parameters
|
|
31
|
+
"""
|
|
32
|
+
# Calculate constants
|
|
33
|
+
M_acc = M_acc = 0.05 * (M_bh/10.0)**0.6 * (M_star/10.0)**0.65
|
|
34
|
+
M_slow = M_star - M_fast - M_acc
|
|
35
|
+
|
|
36
|
+
t_visc = 0.55 * day_to_s * (alpha / 0.1)**-1 * (M_star / 10.0)**0.87 * (M_bh / 10.0)**-0.5 * (theta / 0.33)**-2.0
|
|
37
|
+
L_acc0 = 1.6e44 * (M_bh / 10.0)**0.03 * (M_star / 10.0)**1.63 * (eta / 1e-2) * (alpha / 0.1)**-1.1 * (theta / 0.33)**-2.3
|
|
38
|
+
L_acc_tvisc = L_acc0 * (t_visc / (3.0 * day_to_s))**-2.1 * np.exp(-1)
|
|
39
|
+
vesc_trun = 9e13 * (N / 100) * (M_star / 10.0)**0.58
|
|
40
|
+
|
|
41
|
+
# Time-dependent properties
|
|
42
|
+
mask = time < t_visc
|
|
43
|
+
e_slow = 0.5 * (M_slow * solar_mass) * (v_slow * km_cgs)**2
|
|
44
|
+
e_fast = ((1.0 - v_fast**2)**-0.5 - 1.0) * (M_fast * solar_mass) * speed_of_light**2.0
|
|
45
|
+
|
|
46
|
+
rad_slow = v_slow * km_cgs * time
|
|
47
|
+
t_diff_slow = (M_slow * solar_mass) * kappa_s / (4.0 * np.pi * rad_slow * speed_of_light)
|
|
48
|
+
t_lc_slow = rad_slow / speed_of_light
|
|
49
|
+
|
|
50
|
+
rad_fast = v_fast * speed_of_light * time
|
|
51
|
+
t_diff_fast = (M_fast * solar_mass) * kappa_f / (4.0 * np.pi * rad_fast * speed_of_light)
|
|
52
|
+
t_lc_fast = rad_fast / speed_of_light
|
|
53
|
+
tau_x = kappa_x * (M_fast * solar_mass) / (4.0 * np.pi * rad_fast**2)
|
|
54
|
+
|
|
55
|
+
L_sh = 0.5 * (M_pre * solar_mass) * (v_slow * km_cgs)**3 / (vesc_trun) * np.exp(-v_slow * km_cgs * time / vesc_trun)
|
|
56
|
+
L_acc = L_acc0 * (time / (3.0 * day_to_s))**-2.1 * np.exp(-(time / t_visc)**0.28)
|
|
57
|
+
L_acc[mask] = L_acc_tvisc
|
|
58
|
+
L_acc_th = phi_0 * (1 - np.exp(-tau_x)) * L_acc + phi_0 * L_acc
|
|
59
|
+
L_x = phi_0 * np.exp(-tau_x) * L_acc
|
|
60
|
+
|
|
61
|
+
# Initialize arrays
|
|
62
|
+
energy_fast = [e_fast]
|
|
63
|
+
energy_slow = [e_slow]
|
|
64
|
+
L_opt_sh = []
|
|
65
|
+
L_opt_rep = []
|
|
66
|
+
|
|
67
|
+
for i in range(len(time)):
|
|
68
|
+
if i > 0:
|
|
69
|
+
dt = time[i] - time[i - 1]
|
|
70
|
+
de_slow_dt = -e_slow / time[i] - lum_opt_sh + L_sh[i]
|
|
71
|
+
de_fast_dt = -e_fast / time[i] - lum_opt_rep + L_acc_th[i]
|
|
72
|
+
e_slow += de_slow_dt * dt
|
|
73
|
+
if e_slow < 0:
|
|
74
|
+
e_slow = 0
|
|
75
|
+
e_fast += de_fast_dt * dt
|
|
76
|
+
if e_fast < 0:
|
|
77
|
+
e_fast = 0
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
lum_opt_sh = e_slow / (t_lc_slow[i] + t_diff_slow[i])
|
|
81
|
+
lum_opt_rep = e_fast / (t_lc_fast[i] + t_diff_fast[i])
|
|
82
|
+
L_opt_sh.append(lum_opt_sh)
|
|
83
|
+
L_opt_rep.append(lum_opt_rep)
|
|
84
|
+
energy_fast.append(e_fast)
|
|
85
|
+
energy_slow.append(e_slow)
|
|
86
|
+
|
|
87
|
+
dynamics_output = namedtuple('dynamics_output', ['time', 'energy_fast', 'energy_slow', 'rad_fast', 'rad_slow',
|
|
88
|
+
'reprocessed_luminosity', 'shock_powered_luminosity', 'optical_luminosity',
|
|
89
|
+
'x_ray_luminosity', 'accretion_luminosity', 'erad_opt_total'])
|
|
90
|
+
|
|
91
|
+
dynamics_output.time = time
|
|
92
|
+
dynamics_output.energy_fast = energy_fast
|
|
93
|
+
dynamics_output.energy_slow = energy_slow
|
|
94
|
+
dynamics_output.rad_fast = rad_fast
|
|
95
|
+
dynamics_output.rad_slow = rad_slow
|
|
96
|
+
dynamics_output.reprocessed_luminosity = L_opt_rep
|
|
97
|
+
dynamics_output.shock_powered_luminosity = L_opt_sh
|
|
98
|
+
dynamics_output.optical_luminosity = np.array(L_opt_rep) + np.array(L_opt_sh)
|
|
99
|
+
dynamics_output.x_ray_luminosity = L_x
|
|
100
|
+
dynamics_output.accretion_luminosity = L_acc
|
|
101
|
+
dynamics_output.erad_opt_total = np.trapz(np.array(L_opt_sh) + np.array(L_opt_sh), x=time)
|
|
102
|
+
return dynamics_output
|
|
103
|
+
|
|
104
|
+
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2022ApJ...932...84M')
|
|
105
|
+
def wr_bh_merger_bolometric(time, M_star, M_bh, M_fast, M_pre, v_fast, v_slow, alpha, eta, **kwargs):
|
|
106
|
+
"""
|
|
107
|
+
Parameters:
|
|
108
|
+
:param time: time in source frame in days
|
|
109
|
+
:param M_star: Mass of the Wolf-Rayet star in solar masses
|
|
110
|
+
:param M_bh: Mass of the black hole in solar masses
|
|
111
|
+
:param M_fast: Mass of the fast component in solar masses
|
|
112
|
+
:param M_pre: Mass of the pre-merger CSM in solar masses
|
|
113
|
+
:param v_fast: Velocity of the fast component in units of c
|
|
114
|
+
:param v_slow: Velocity of the slow component in km/s
|
|
115
|
+
:param alpha: Viscosity parameter
|
|
116
|
+
:param eta: Efficiency of conversion of accretion energy to radiation
|
|
117
|
+
:param kwargs: Additional parameters
|
|
118
|
+
:param output_format: whether to output dynamics or bolometric luminosity
|
|
119
|
+
:param theta: Disk aspect ratio
|
|
120
|
+
:param phi_0: Solid angle of the slow component
|
|
121
|
+
:param kappa_s: Opacity of the slow component
|
|
122
|
+
:param kappa_f: Opacity of the fast component
|
|
123
|
+
:param kappa_x: Opacity of the x-ray component
|
|
124
|
+
:param N: Number of pre-merger orbits
|
|
125
|
+
:return: bolometric luminosity or dynamics output
|
|
126
|
+
"""
|
|
127
|
+
theta = kwargs.get('theta', 0.33)
|
|
128
|
+
phi_0 = kwargs.get('phi_0', 0.5)
|
|
129
|
+
kappa_s = kwargs.get('kappa_s', 0.03)
|
|
130
|
+
kappa_f = kwargs.get('kappa_f', 0.2)
|
|
131
|
+
kappa_x = kwargs.get('kappa_x', 0.4)
|
|
132
|
+
N = kwargs.get('N', 30)
|
|
133
|
+
|
|
134
|
+
time_temp = np.geomspace(1e0, 1e8, 2000)
|
|
135
|
+
dynamics_output = _wr_bh_merger(time_temp, M_star, M_bh, M_fast, M_pre, v_fast, v_slow, alpha, eta, theta, phi_0, kappa_s, kappa_f, kappa_x, N, **kwargs)
|
|
136
|
+
lbol_func = interp1d(time_temp, y=dynamics_output.optical_luminosity)
|
|
137
|
+
time = time * day_to_s
|
|
138
|
+
lbol = lbol_func(time)
|
|
139
|
+
if kwargs['output_format'] == 'dynamics_output':
|
|
140
|
+
return dynamics_output
|
|
141
|
+
else:
|
|
142
|
+
return lbol
|
|
143
|
+
|
|
144
|
+
@citation_wrapper('https://ui.adsabs.harvard.edu/abs/2022ApJ...932...84M')
|
|
145
|
+
def wr_bh_merger(time, redshift, M_star, M_bh, M_fast, M_pre, v_fast, v_slow, alpha, eta, **kwargs):
|
|
146
|
+
"""
|
|
147
|
+
Parameters:
|
|
148
|
+
:param time: time in source frame in days
|
|
149
|
+
:param redshift: redshift
|
|
150
|
+
:param M_star: Mass of the Wolf-Rayet star in solar masses
|
|
151
|
+
:param M_bh: Mass of the black hole in solar masses
|
|
152
|
+
:param M_fast: Mass of the fast component in solar masses
|
|
153
|
+
:param M_pre: Mass of the pre-merger CSM in solar masses
|
|
154
|
+
:param v_fast: Velocity of the fast component in units of c
|
|
155
|
+
:param v_slow: Velocity of the slow component in km/s
|
|
156
|
+
:param alpha: Viscosity parameter
|
|
157
|
+
:param eta: Efficiency of conversion of accretion energy to radiation
|
|
158
|
+
:param kwargs: Additional parameters - Must be all the kwargs required by the specific photosphere, sed methods used
|
|
159
|
+
e.g., for TemperatureFloor: vej (km/s) and temperature_floor
|
|
160
|
+
:param theta: Disk aspect ratio
|
|
161
|
+
:param phi_0: Solid angle of the slow component
|
|
162
|
+
:param kappa_s: Opacity of the slow component
|
|
163
|
+
:param kappa_f: Opacity of the fast component
|
|
164
|
+
:param kappa_x: Opacity of the x-ray component
|
|
165
|
+
:param N: Number of pre-merger orbits
|
|
166
|
+
:param photosphere: Default is TemperatureFloor.
|
|
167
|
+
kwargs must have vej or relevant parameters if using different photosphere model
|
|
168
|
+
:param frequency: Required if output_format is 'flux_density'.
|
|
169
|
+
frequency to calculate - Must be same length as time array or a single number).
|
|
170
|
+
:param bands: Required if output_format is 'magnitude' or 'flux'.
|
|
171
|
+
:param output_format: 'flux_density', 'magnitude', 'spectra', 'flux', 'sncosmo_source'
|
|
172
|
+
:param lambda_array: Optional argument to set your desired wavelength array (in Angstroms) to evaluate the SED on.
|
|
173
|
+
:param cosmology: Cosmology to use for luminosity distance calculation. Defaults to Planck18. Must be a astropy.cosmology object.
|
|
174
|
+
:return: set by output format - 'flux_density', 'magnitude', 'dynamics_output', 'spectra', 'flux', 'sncosmo_source'
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
theta = kwargs.get('theta', 0.33)
|
|
178
|
+
phi_0 = kwargs.get('phi_0', 0.5)
|
|
179
|
+
kappa_s = kwargs.get('kappa_s', 0.03)
|
|
180
|
+
kappa_f = kwargs.get('kappa_f', 0.2)
|
|
181
|
+
kappa_x = kwargs.get('kappa_x', 0.4)
|
|
182
|
+
N = kwargs.get('N', 30)
|
|
183
|
+
kwargs['photosphere'] = kwargs.get("photosphere", photosphere.TemperatureFloor)
|
|
184
|
+
kwargs['sed'] = kwargs.get("sed", sed.Blackbody)
|
|
185
|
+
cosmology = kwargs.get('cosmology', cosmo)
|
|
186
|
+
dl = cosmology.luminosity_distance(redshift).cgs.value
|
|
187
|
+
|
|
188
|
+
time_temp = np.geomspace(1e0, 1e8, 2000)
|
|
189
|
+
if kwargs['output_format'] == 'flux_density':
|
|
190
|
+
frequency = kwargs['frequency']
|
|
191
|
+
frequency, time = calc_kcorrected_properties(frequency=frequency, redshift=redshift, time=time)
|
|
192
|
+
output = _wr_bh_merger(time_temp, M_star, M_bh, M_fast, M_pre, v_fast, v_slow, alpha, eta, theta, phi_0, kappa_s, kappa_f, kappa_x, N, **kwargs)
|
|
193
|
+
photo_fast = kwargs['photosphere'](time=time_temp/day_to_s, luminosity=np.array(output.reprocessed_luminosity), vej = v_fast * speed_of_light / km_cgs, **kwargs)
|
|
194
|
+
photo_slow = kwargs['photosphere'](time=time_temp/day_to_s, luminosity=np.array(output.shock_powered_luminosity), vej = v_slow, **kwargs)
|
|
195
|
+
temp_func_fast = interp1d(time_temp/day_to_s, y=photo_fast.photosphere_temperature)
|
|
196
|
+
temp_func_slow = interp1d(time_temp/day_to_s, y=photo_slow.photosphere_temperature)
|
|
197
|
+
rad_func_fast = interp1d(time_temp/day_to_s, y=photo_fast.r_photosphere)
|
|
198
|
+
rad_func_slow = interp1d(time_temp/day_to_s, y=photo_slow.r_photosphere)
|
|
199
|
+
temp_fast = temp_func_fast(time)
|
|
200
|
+
temp_slow = temp_func_slow(time)
|
|
201
|
+
rad_fast = rad_func_fast(time)
|
|
202
|
+
rad_slow = rad_func_slow(time)
|
|
203
|
+
sed_fast = kwargs['sed'](temperature=temp_fast, r_photosphere=rad_fast,
|
|
204
|
+
frequency=frequency, luminosity_distance=dl)
|
|
205
|
+
sed_slow = kwargs['sed'](temperature=temp_slow, r_photosphere=rad_slow,
|
|
206
|
+
frequency=frequency, luminosity_distance=dl)
|
|
207
|
+
flux_density = sed_fast.flux_density + sed_slow.flux_density
|
|
208
|
+
return flux_density.to(uu.mJy).value
|
|
209
|
+
|
|
210
|
+
else:
|
|
211
|
+
time_obs = time
|
|
212
|
+
lambda_observer_frame = kwargs.get('lambda_array', np.geomspace(500, 60000, 200))
|
|
213
|
+
time_temp = np.geomspace(1e0, 1e8, 2000)
|
|
214
|
+
time_observer_frame = time_temp * (1. + redshift)
|
|
215
|
+
frequency, time = calc_kcorrected_properties(frequency=lambda_to_nu(lambda_observer_frame),
|
|
216
|
+
redshift=redshift, time=time_observer_frame)
|
|
217
|
+
output = _wr_bh_merger(time_temp, M_star, M_bh, M_fast, M_pre, v_fast, v_slow, alpha, eta, theta, phi_0, kappa_s, kappa_f, kappa_x, N, **kwargs)
|
|
218
|
+
photo_fast = kwargs['photosphere'](time=time_temp/day_to_s, luminosity=np.array(output.reprocessed_luminosity), vej = v_fast * speed_of_light / km_cgs, **kwargs)
|
|
219
|
+
photo_slow = kwargs['photosphere'](time=time_temp/day_to_s, luminosity=np.array(output.shock_powered_luminosity), vej = v_slow, **kwargs)
|
|
220
|
+
if kwargs['output_format'] == 'dynamics_output':
|
|
221
|
+
dynamics_output = namedtuple('dynamics_output', ['time', 'temperature_fast', 'temperature_slow','r_photosphere_fast',
|
|
222
|
+
'r_photosphere_slow','energy_fast','energy_slow','optical_luminosity',
|
|
223
|
+
'reprocessed_luminosity','shock_powered_luminosity','x_ray_luminosity',
|
|
224
|
+
'accretion_luminosity','erad_opt_total'])
|
|
225
|
+
dynamics_output.time = output.time
|
|
226
|
+
dynamics_output.temperature_fast = photo_fast.photosphere_temperature
|
|
227
|
+
dynamics_output.temperature_slow = photo_slow.photosphere_temperature
|
|
228
|
+
dynamics_output.r_photosphere_fast = photo_fast.r_photosphere
|
|
229
|
+
dynamics_output.r_photosphere_slow = photo_slow.r_photosphere
|
|
230
|
+
dynamics_output.energy_fast = output.energy_fast
|
|
231
|
+
dynamics_output.energy_slow = output.energy_slow
|
|
232
|
+
dynamics_output.optical_luminosity = output.optical_luminosity
|
|
233
|
+
dynamics_output.reprocessed_luminosity = output.reprocessed_luminosity
|
|
234
|
+
dynamics_output.shock_powered_luminosity = output.shock_powered_luminosity
|
|
235
|
+
dynamics_output.x_ray_luminosity = output.x_ray_luminosity
|
|
236
|
+
dynamics_output.accretion_luminosity = output.accretion_luminosity
|
|
237
|
+
dynamics_output.erad_opt_total = output.erad_opt_total
|
|
238
|
+
return dynamics_output
|
|
239
|
+
sed_fast = kwargs['sed'](temperature=photo_fast.photosphere_temperature, r_photosphere=photo_fast.r_photosphere,
|
|
240
|
+
frequency=frequency[:,None], luminosity_distance=dl)
|
|
241
|
+
sed_slow = kwargs['sed'](temperature=photo_slow.photosphere_temperature, r_photosphere=photo_slow.r_photosphere,
|
|
242
|
+
frequency=frequency[:,None], luminosity_distance=dl)
|
|
243
|
+
fmjy = sed_fast.flux_density + sed_slow.flux_density
|
|
244
|
+
fmjy = fmjy.T
|
|
245
|
+
spectra = fmjy.to(uu.mJy).to(uu.erg / uu.cm ** 2 / uu.s / uu.Angstrom,
|
|
246
|
+
equivalencies=uu.spectral_density(wav=lambda_observer_frame * uu.Angstrom))
|
|
247
|
+
if kwargs['output_format'] == 'spectra':
|
|
248
|
+
return namedtuple('output', ['time', 'lambdas', 'spectra'])(time=time_observer_frame,
|
|
249
|
+
lambdas=lambda_observer_frame,
|
|
250
|
+
spectra=spectra)
|
|
251
|
+
else:
|
|
252
|
+
return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame/day_to_s,
|
|
253
|
+
spectra=spectra, lambda_array=lambda_observer_frame,
|
|
254
|
+
**kwargs)
|