redback 1.0.1__py3-none-any.whl → 1.0.3__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.
Files changed (66) hide show
  1. redback/__init__.py +4 -0
  2. redback/constraints.py +46 -25
  3. redback/eos.py +1 -0
  4. redback/get_data/fink.py +1 -1
  5. redback/get_data/lasair.py +3 -4
  6. redback/get_data/swift.py +7 -7
  7. redback/interaction_processes.py +1 -4
  8. redback/likelihoods.py +207 -21
  9. redback/model_library.py +2 -2
  10. redback/plotting.py +10 -10
  11. redback/priors/bazin_sne.prior +5 -0
  12. redback/priors/csm_interaction.prior +6 -7
  13. redback/priors/csm_nickel.prior +3 -3
  14. redback/priors/csm_shock_and_arnett.prior +11 -0
  15. redback/priors/csm_shock_and_arnett_bolometric.prior +10 -0
  16. redback/priors/csm_shock_breakout.prior +7 -0
  17. redback/priors/nicholl_bns.prior +2 -1
  18. redback/priors/one_comp_kne_rosswog_heatingrate.prior +5 -0
  19. redback/priors/pwn.prior +7 -0
  20. redback/priors/shocked_cocoon.prior +6 -6
  21. redback/priors/sn_fallback.prior +8 -0
  22. redback/priors/stream_stream_tde.prior +10 -0
  23. redback/priors/stream_stream_tde_bolometric.prior +9 -0
  24. redback/priors/tde_analytical.prior +5 -5
  25. redback/priors/tde_analytical_bolometric.prior +6 -4
  26. redback/priors/tde_fallback.prior +9 -0
  27. redback/priors/tde_fallback_bolometric.prior +6 -0
  28. redback/priors/tde_synchrotron.prior +6 -0
  29. redback/priors/tophat_from_emulator.prior +9 -0
  30. redback/priors/two_comp_kne_rosswog_heatingrate.prior +9 -0
  31. redback/priors/two_layer_stratified_kilonova.prior +1 -1
  32. redback/priors/villar_sne.prior +7 -0
  33. redback/priors.py +12 -1
  34. redback/sed.py +194 -2
  35. redback/simulate_transients.py +71 -35
  36. redback/tables/GRBs_w_redshift.txt +430 -413
  37. redback/tables/LGRB_table.txt +70 -6
  38. redback/tables/SGRB_table.txt +139 -135
  39. redback/tables/filters.csv +14 -0
  40. redback/tables/qdot_rosswogkorobkin24.pck +0 -0
  41. redback/tables/ztf.tar.gz +0 -0
  42. redback/transient/afterglow.py +17 -7
  43. redback/transient/kilonova.py +6 -3
  44. redback/transient/prompt.py +14 -4
  45. redback/transient/supernova.py +7 -3
  46. redback/transient/tde.py +6 -3
  47. redback/transient/transient.py +29 -12
  48. redback/transient_models/afterglow_models.py +152 -146
  49. redback/transient_models/combined_models.py +69 -48
  50. redback/transient_models/extinction_models.py +6 -6
  51. redback/transient_models/general_synchrotron_models.py +518 -0
  52. redback/transient_models/integrated_flux_afterglow_models.py +2 -2
  53. redback/transient_models/kilonova_models.py +310 -61
  54. redback/transient_models/magnetar_driven_ejecta_models.py +2 -2
  55. redback/transient_models/magnetar_models.py +1 -1
  56. redback/transient_models/phenomenological_models.py +69 -1
  57. redback/transient_models/shock_powered_models.py +159 -110
  58. redback/transient_models/supernova_models.py +211 -43
  59. redback/transient_models/tde_models.py +975 -5
  60. redback/utils.py +309 -16
  61. {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/METADATA +46 -6
  62. {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/RECORD +65 -49
  63. {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/WHEEL +1 -1
  64. redback/tables/ztf_obslog.csv +0 -106649
  65. {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/LICENCE.md +0 -0
  66. {redback-1.0.1.dist-info → redback-1.0.3.dist-info}/top_level.txt +0 -0
@@ -58,8 +58,8 @@ def _ejecta_dynamics_and_interaction(time, mej, beta, ejecta_radius, kappa, n_is
58
58
 
59
59
  ni56_lum = 6.45e43
60
60
  co56_lum = 1.45e43
61
- ni56_life = 8.8 # days
62
- co56_life = 111.3 # days
61
+ ni56_life = 8.8*86400 # days
62
+ co56_life = 111.3*86400 # days
63
63
 
64
64
  for i in range(len(time)):
65
65
  beta = np.sqrt(1 - 1 / gamma ** 2)
@@ -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,74 @@
1
1
  import numpy as np
2
+ from redback.utils import citation_wrapper
2
3
 
3
- def gaussian_rise(time, a_1, peak_time, sigma_t):
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):
59
+ """
60
+ A gaussian to add or subtract from a continuum spectrum to mimic absorption or emission lines
61
+
62
+ :param wavelength: wavelength array in whatever units
63
+ :param line_amp: line amplitude scale
64
+ :param cont_amp: Continuum amplitude scale
65
+ :param x0: Position of emission line
66
+ :return: spectrum in whatever units set by line_amp
67
+ """
68
+ spectrum = line_amp / cont_amp * np.exp(-(wavelength - x0) ** 2. / (2 * cont_amp ** 2) )
69
+ return spectrum
70
+
71
+ def gaussian_rise(time, a_1, peak_time, sigma_t, **kwargs):
4
72
  """
5
73
  :param time: time array in whatver time units
6
74
  :param a_1: gaussian rise amplitude scale
@@ -1,11 +1,157 @@
1
1
  import numpy as np
2
2
  from collections import namedtuple
3
3
  from scipy import special
4
+ from scipy.interpolate import interp1d
4
5
  from redback.constants import *
5
6
  import redback.sed as sed
6
7
  from astropy.cosmology import Planck18 as cosmo # noqa
7
8
  from redback.utils import calc_kcorrected_properties, citation_wrapper, lambda_to_nu
8
9
 
10
+ @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2022ApJ...933..238M/abstract')
11
+ def _csm_shock_breakout(time, csm_mass, v_min, beta, kappa, shell_radius, shell_width_ratio, **kwargs):
12
+ """
13
+ Dense CSM shock breakout and cooling model From Margalit 2022
14
+
15
+ :param time: time in days
16
+ :param csm_mass: mass of CSM shell in g
17
+ :param v_min: minimum velocity in km/s
18
+ :param beta: velocity ratio in c (beta < 1)
19
+ :param kappa: opacity in cm^2/g
20
+ :param shell_radius: radius of shell in 10^14 cm
21
+ :param shell_width_ratio: shell width ratio (deltaR/R0)
22
+ :return: namedtuple with lbol, r_photosphere, and temperature
23
+ """
24
+ v0 = v_min * 1e5
25
+ e0 = 0.5 * csm_mass * v0**2
26
+ shell_radius *= 1e14
27
+ shell_width = shell_width_ratio * shell_radius
28
+ tdyn = shell_radius / v0
29
+ tshell = shell_width / v0
30
+ time = time * day_to_s
31
+
32
+ velocity = v0/beta
33
+
34
+ tda = (3 * kappa * csm_mass / (4 * np.pi * speed_of_light * velocity)) ** 0.5
35
+
36
+ term1 = ((tdyn + tshell + time) ** 3 - (tdyn + beta * time) ** 3) ** (2 / 3)
37
+ term2 = ((tdyn + tshell) ** 3 - tdyn ** 3) ** (1 / 3)
38
+ term3 = (1 + (1 - beta) * time / tshell) ** (
39
+ -3 * (tdyn / tda) ** 2 * ((1 - beta - beta * tshell / tdyn) ** 2) / (1 - beta) ** 3)
40
+ term4 = np.exp(-time * ((1 - beta ** 3) * time + (2 - 4 * beta * (beta + 1)) * tshell + 6 * (1 - beta ** 2) * tdyn) / (
41
+ 2 * (1 - beta) ** 2 * tda ** 2))
42
+
43
+ lbol = e0 * term1 / (tda ** 2 * (tshell + (1 - beta) * time) ** 2) * term2 * term3 * term4
44
+
45
+ volume = 4./3. * np.pi * velocity**3 * ((tdyn + tshell + time)**3 - (tdyn + beta*time)**3)
46
+ radius = velocity * (tdyn + tshell + time)
47
+ rphotosphere = radius - 2*volume/(3 * kappa * csm_mass)
48
+ teff = (lbol / (4 * np.pi * rphotosphere ** 2 * sigma_sb)) ** 0.25
49
+ output = namedtuple('output', ['lbol', 'r_photosphere', 'temperature', 'time_temp',
50
+ 'tdyn', 'tshell', 'e0', 'tda', 'velocity'])
51
+ output.lbol = lbol
52
+ output.r_photosphere = rphotosphere
53
+ output.temperature = teff
54
+ output.tdyn = tdyn
55
+ output.tshell = tshell
56
+ output.e0 = e0
57
+ output.tda = tda
58
+ output.velocity = velocity
59
+ output.time_temp = time
60
+ return output
61
+
62
+ @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2022ApJ...933..238M/abstract')
63
+ def csm_shock_breakout_bolometric(time, csm_mass, v_min, beta, kappa, shell_radius, shell_width_ratio, **kwargs):
64
+ """
65
+ Dense CSM shock breakout and cooling model From Margalit 2022
66
+
67
+ :param time: time in days in source frame
68
+ :param csm_mass: mass of CSM shell in solar masses
69
+ :param v_min: minimum velocity in km/s
70
+ :param beta: velocity ratio in c (beta < 1)
71
+ :param kappa: opacity in cm^2/g
72
+ :param shell_radius: radius of shell in 10^14 cm
73
+ :param shell_width_ratio: shell width ratio (deltaR/R0)
74
+ :param kwargs: Additional parameters required by model
75
+ :param cosmology: Cosmology to use for luminosity distance calculation. Defaults to Planck18. Must be a astropy.cosmology object.
76
+ :return: bolometric luminosity
77
+ """
78
+ csm_mass = csm_mass * solar_mass
79
+ time_temp = np.geomspace(1e-2, 200, 300) # days
80
+ outputs = _csm_shock_breakout(time_temp, v_min=v_min, beta=beta,
81
+ kappa=kappa, csm_mass=csm_mass, shell_radius=shell_radius,
82
+ shell_width_ratio=shell_width_ratio, **kwargs)
83
+ func = interp1d(time_temp, outputs.lbol, fill_value='extrapolate')
84
+ return func(time)
85
+
86
+ @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2022ApJ...933..238M/abstract')
87
+ def csm_shock_breakout(time, redshift, csm_mass, v_min, beta, kappa, shell_radius, shell_width_ratio, **kwargs):
88
+ """
89
+ Dense CSM shock breakout and cooling model From Margalit 2022
90
+
91
+ :param time: time in days in observer frame
92
+ :param redshift: redshift
93
+ :param csm_mass: mass of CSM shell in solar masses
94
+ :param v_min: minimum velocity in km/s
95
+ :param beta: velocity ratio in c (beta < 1)
96
+ :param kappa: opacity in cm^2/g
97
+ :param shell_radius: radius of shell in 10^14 cm
98
+ :param shell_width_ratio: shell width ratio (deltaR/R0)
99
+ :param kwargs: Additional parameters required by model
100
+ :param frequency: Required if output_format is 'flux_density'.
101
+ frequency to calculate - Must be same length as time array or a single number).
102
+ :param bands: Required if output_format is 'magnitude' or 'flux'.
103
+ :param output_format: 'flux_density', 'magnitude', 'spectra', 'flux', 'sncosmo_source'
104
+ :param lambda_array: Optional argument to set your desired wavelength array (in Angstroms) to evaluate the SED on.
105
+ :param cosmology: Cosmology to use for luminosity distance calculation. Defaults to Planck18. Must be a astropy.cosmology object.
106
+ :return: set by output format - 'flux_density', 'magnitude', 'spectra', 'flux', 'sncosmo_source'
107
+ :return:
108
+ """
109
+ csm_mass = csm_mass * solar_mass
110
+ cosmology = kwargs.get('cosmology', cosmo)
111
+ dl = cosmology.luminosity_distance(redshift).cgs.value
112
+ time_temp = np.geomspace(1e-2, 40, 300) #days
113
+ time_obs = time
114
+ outputs = _csm_shock_breakout(time_temp, v_min=v_min, beta=beta,
115
+ kappa=kappa, csm_mass=csm_mass, shell_radius=shell_radius,
116
+ shell_width_ratio=shell_width_ratio, **kwargs)
117
+ if kwargs['output_format'] == 'namedtuple':
118
+ return outputs
119
+ elif kwargs['output_format'] == 'flux_density':
120
+ time = time_obs
121
+ frequency = kwargs['frequency']
122
+ # interpolate properties onto observation times
123
+ temp_func = interp1d(time_temp, y=outputs.temperature)
124
+ rad_func = interp1d(time_temp, y=outputs.r_photosphere)
125
+ # convert to source frame time and frequency
126
+ frequency, time = calc_kcorrected_properties(frequency=frequency, redshift=redshift, time=time)
127
+
128
+ temp = temp_func(time)
129
+ photosphere = rad_func(time)
130
+
131
+ flux_density = sed.blackbody_to_flux_density(temperature=temp, r_photosphere=photosphere,
132
+ dl=dl, frequency=frequency)
133
+
134
+ return flux_density.to(uu.mJy).value
135
+ else:
136
+ lambda_observer_frame = kwargs.get('lambda_array', np.geomspace(100, 60000, 200))
137
+ time_observer_frame = time_temp * (1. + redshift)
138
+ frequency, time = calc_kcorrected_properties(frequency=lambda_to_nu(lambda_observer_frame),
139
+ redshift=redshift, time=time_observer_frame)
140
+ fmjy = sed.blackbody_to_flux_density(temperature=outputs.temperature,
141
+ r_photosphere=outputs.r_photosphere, frequency=frequency[:, None], dl=dl)
142
+ fmjy = fmjy.T
143
+ spectra = fmjy.to(uu.mJy).to(uu.erg / uu.cm ** 2 / uu.s / uu.Angstrom,
144
+ equivalencies=uu.spectral_density(wav=lambda_observer_frame * uu.Angstrom))
145
+ if kwargs['output_format'] == 'spectra':
146
+ return namedtuple('output', ['time', 'lambdas', 'spectra'])(time=time_observer_frame,
147
+ lambdas=lambda_observer_frame,
148
+ spectra=spectra)
149
+ else:
150
+ return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
151
+ spectra=spectra, lambda_array=lambda_observer_frame,
152
+ **kwargs)
153
+
154
+
9
155
  @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021ApJ...909..209P/abstract')
10
156
  def _shock_cooling(time, mass, radius, energy, **kwargs):
11
157
  """
@@ -22,6 +168,7 @@ def _shock_cooling(time, mass, radius, energy, **kwargs):
22
168
  delta = kwargs.get('delta',1.1)
23
169
  kk_pow = (nn - 3) * (3 - delta) / (4 * np.pi * (nn - delta))
24
170
  kappa = 0.2
171
+ mass = mass * solar_mass
25
172
  vt = (((nn - 5) * (5 - delta) / ((nn - 3) * (3 - delta))) * (2 * energy / mass))**0.5
26
173
  td = ((3 * kappa * kk_pow * mass) / ((nn - 1) * vt * speed_of_light))**0.5
27
174
 
@@ -34,18 +181,17 @@ def _shock_cooling(time, mass, radius, energy, **kwargs):
34
181
 
35
182
  tph = np.sqrt(3 * kappa * kk_pow * mass / (2 * (nn - 1) * vt * vt))
36
183
  r_photosphere_pre_td = np.power(tph / time, 2 / (nn - 1)) * vt * time
37
- r_photosphere_post_td = (np.power((delta - 1) / (nn - 1) * ((time / td) ** 2 - 1) + 1, -1 / (delta + 1))* vt * time)
38
- r_photosphere = np.zeros(len(time))
39
- r_photosphere[time < td] = r_photosphere_pre_td[time < td]
40
- r_photosphere[time >= td] = r_photosphere_post_td[time >= td]
184
+ r_photosphere_post_td = (np.power((delta - 1) / (nn - 1) * ((time / td) ** 2 - 1) + 1, -1 / (delta + 1)) * vt * time)
185
+ r_photosphere = r_photosphere_pre_td + r_photosphere_post_td
41
186
 
42
187
  sigmaT4 = lbol / (4 * np.pi * r_photosphere**2)
43
188
  temperature = np.power(sigmaT4 / sigma_sb, 0.25)
44
189
 
45
- output = namedtuple('output', ['lbol', 'r_photosphere', 'temperature'])
190
+ output = namedtuple('output', ['lbol', 'r_photosphere', 'temperature', 'td'])
46
191
  output.lbol = lbol
47
192
  output.r_photosphere = r_photosphere
48
193
  output.temperature = temperature
194
+ output.td = td
49
195
  return output
50
196
 
51
197
  @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021MNRAS.505.3016N/abstract')
@@ -138,7 +284,7 @@ def shock_cooling(time, redshift, log10_mass, log10_radius, log10_energy, **kwar
138
284
  dl=dl, frequency=frequency)
139
285
  return flux_density.to(uu.mJy).value
140
286
  else:
141
- time_temp = np.linspace(1e-4, 50, 50)
287
+ time_temp = np.linspace(1e-2, 10, 100)
142
288
  lambda_observer_frame = kwargs.get('lambda_array', np.geomspace(100, 60000, 100))
143
289
 
144
290
  time_observer_frame = time_temp
@@ -155,7 +301,7 @@ def shock_cooling(time, redshift, log10_mass, log10_radius, log10_energy, **kwar
155
301
  lambdas=lambda_observer_frame,
156
302
  spectra=spectra)
157
303
  else:
158
- return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame / day_to_s,
304
+ return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
159
305
  spectra=spectra, lambda_array=lambda_observer_frame,
160
306
  **kwargs)
161
307
 
@@ -320,110 +466,12 @@ def _tau_nu(x, nism, radius, bfield, theta, xi, p, z_cool):
320
466
  val = radius*(alphanu_thermal + alphanu_pl)
321
467
  return val
322
468
 
323
- @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021ApJ...923L..14M/abstract')
324
- def thermal_synchrotron_lnu(time, logn0, v0, logr0, eta, logepse, logepsb, xi, p, **kwargs):
325
- """
326
- :param time: time in source frame in seconds
327
- :param logn0: log10 initial ambient ism density
328
- :param v0: initial velocity in c
329
- :param logr0: log10 initial radius
330
- :param eta: deceleration slope (r = r0 * (time/t0)**eta; v = v0*(time/t0)**(eta-1))
331
- :param logepse: log10 epsilon_e; electron thermalisation efficiency
332
- :param logepsb: log10 epsilon_b; magnetic field amplification efficiency
333
- :param xi: fraction of energy carried by power law electrons
334
- :param p: electron power law slope
335
- :param kwargs: extra parameters to change physics/settings
336
- :param frequency: frequency to calculate model on - Must be same length as time array or a single number)
337
- :param wind_slope: slope for ism density scaling (nism = n0 * (r/r0)**(-wind_slope)). Default is 2
338
- :param mu: mean molecular weight, default is 0.62
339
- :param mu_e: mean molecular weight per electron, default is 1.18
340
- :return: lnu
341
- """
342
- v0 = v0 * speed_of_light
343
- r0 = 10**logr0
344
- t0 = eta * r0 / v0
345
- radius = r0 * (time / t0) ** eta
346
- velocity = v0 * (time/t0)**(eta - 1)
347
- wind_slope = kwargs.get('wind_slope',2)
348
- mu = kwargs.get('mu', 0.62)
349
- mu_e = kwargs.get('mu_e', 1.18)
350
- n0 = 10 ** logn0
351
- nism = n0 * (radius / r0) ** (-wind_slope)
352
-
353
- epsilon_T = 10**logepse
354
- epsilon_B = 10**logepsb
355
-
356
- frequency = kwargs['frequency']
357
-
358
- ne = 4.0*mu_e*nism
359
- beta = velocity/speed_of_light
360
-
361
- theta0 = epsilon_T * (9.0 * mu * proton_mass / (32.0 * mu_e * electron_mass)) * beta ** 2
362
- theta = (5.0*theta0-6.0+(25.0*theta0**2+180.0*theta0+36.0)**0.5)/30.0
363
-
364
- bfield = (9.0*np.pi*epsilon_B*nism*mu*proton_mass)**0.5*velocity
365
- # mean dynamical time:
366
- td = radius/velocity
367
-
368
- z_cool = (6.0 * np.pi * electron_mass * speed_of_light / (sigma_T * bfield ** 2 * td)) / theta
369
- normalised_frequency_denom = 3.0*theta**2*qe*bfield/(4.0*np.pi*electron_mass*speed_of_light)
370
- x = frequency / normalised_frequency_denom
371
-
372
- emissivity_pl = _emissivity_pl(x=x, nism=ne, bfield=bfield, theta=theta, xi=xi, p=p, z_cool=z_cool)
373
-
374
- emissivity_thermal = _emissivity_thermal(x=x, nism=ne, bfield=bfield, theta=theta, z_cool=z_cool)
375
-
376
- emissivity = emissivity_thermal + emissivity_pl
377
-
378
- tau = _tau_nu(x=x, nism=ne, radius=radius, bfield=bfield, theta=theta, xi=xi, p=p, z_cool=z_cool)
379
-
380
- lnu = 4.0 * np.pi ** 2 * radius ** 3 * emissivity * (1e0 - np.exp(-tau)) / tau
381
- if np.size(x) > 1:
382
- lnu[tau < 1e-10] = (4.0 * np.pi ** 2 * radius ** 3 * emissivity)[tau < 1e-10]
383
- elif tau < 1e-10:
384
- lnu = 4.0 * np.pi ** 2 * radius ** 3 * emissivity
385
- return lnu
386
-
387
- @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021ApJ...923L..14M/abstract')
388
- def thermal_synchrotron_fluxdensity(time, redshift, logn0, v0, logr0, eta, logepse, logepsb,
389
- xi, p, **kwargs):
390
- """
391
- :param time: time in observer frame in days
392
- :param redshift: redshift
393
- :param logn0: log10 initial ambient ism density
394
- :param v0: initial velocity in c
395
- :param logr0: log10 initial radius
396
- :param eta: deceleration slope (r = r0 * (time/t0)**eta; v = v0*(time/t0)**(eta-1))
397
- :param logepse: log10 epsilon_e; electron thermalisation efficiency
398
- :param logepsb: log10 epsilon_b; magnetic field amplification efficiency
399
- :param xi: fraction of energy carried by power law electrons
400
- :param p: electron power law slope
401
- :param kwargs: extra parameters to change physics/settings
402
- :param frequency: frequency to calculate model on - Must be same length as time array or a single number)
403
- :param wind_slope: slope for ism density scaling (nism = n0 * (r/r0)**(-wind_slope)). Default is 2
404
- :param mu: mean molecular weight, default is 0.62
405
- :param mu_e: mean molecular weight per electron, default is 1.18
406
- :param kwargs: extra parameters to change physics and other settings
407
- :param cosmology: Cosmology to use for luminosity distance calculation. Defaults to Planck18. Must be a astropy.cosmology object.
408
- :return: flux density
409
- """
410
- frequency = kwargs['frequency']
411
- frequency, time = calc_kcorrected_properties(frequency=frequency, redshift=redshift, time=time)
412
- new_kwargs = kwargs.copy()
413
- new_kwargs['frequency'] = frequency
414
- time = time * day_to_s
415
- cosmology = kwargs.get('cosmology', cosmo)
416
- dl = cosmology.luminosity_distance(redshift).cgs.value
417
- lnu = thermal_synchrotron_lnu(time,logn0, v0, logr0, eta, logepse, logepsb, xi, p,**new_kwargs)
418
- flux_density = lnu / (4.0 * np.pi * dl**2)
419
- return flux_density
420
-
421
469
  @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2018ApJ...855..103P/abstract')
422
470
  def _shocked_cocoon(time, mej, vej, eta, tshock, shocked_fraction, cos_theta_cocoon, kappa):
423
471
  """
424
472
  :param time: source frame time in days
425
473
  :param mej: ejecta mass in solar masses
426
- :param vej: ejecta mass in km/s
474
+ :param vej: ejecta velocity in c
427
475
  :param eta: slope for ejecta density profile
428
476
  :param tshock: shock time in seconds
429
477
  :param shocked_fraction: fraction of ejecta mass shocked
@@ -431,8 +479,9 @@ def _shocked_cocoon(time, mej, vej, eta, tshock, shocked_fraction, cos_theta_coc
431
479
  :param kappa: opacity
432
480
  :return: namedtuple with lbol, r_photosphere, and temperature
433
481
  """
434
- diff_const = solar_mass / (4*np.pi * speed_of_light * km_cgs)
435
482
  c_kms = speed_of_light / km_cgs
483
+ vej = vej * c_kms
484
+ diff_const = solar_mass / (4*np.pi * speed_of_light * km_cgs)
436
485
  rshock = tshock * speed_of_light
437
486
  shocked_mass = mej * shocked_fraction
438
487
  theta = np.arccos(cos_theta_cocoon)
@@ -479,7 +528,7 @@ def shocked_cocoon(time, redshift, mej, vej, eta, tshock, shocked_fraction, cos_
479
528
  :param time: observer frame time in days
480
529
  :param redshift: redshift
481
530
  :param mej: ejecta mass in solar masses
482
- :param vej: ejecta mass in km/s
531
+ :param vej: ejecta velocity in c
483
532
  :param eta: slope for ejecta density profile
484
533
  :param tshock: shock time in seconds
485
534
  :param shocked_fraction: fraction of ejecta mass shocked
@@ -509,7 +558,7 @@ def shocked_cocoon(time, redshift, mej, vej, eta, tshock, shocked_fraction, cos_
509
558
  return flux_density.to(uu.mJy).value
510
559
  else:
511
560
  lambda_observer_frame = kwargs.get('frequency_array', np.geomspace(100, 60000, 100))
512
- time_temp = np.linspace(1e-4, 50, 30)
561
+ time_temp = np.linspace(1e-2, 10, 100)
513
562
  time_observer_frame = time_temp
514
563
  frequency, time = calc_kcorrected_properties(frequency=lambda_to_nu(lambda_observer_frame),
515
564
  redshift=redshift, time=time_observer_frame)
@@ -526,7 +575,7 @@ def shocked_cocoon(time, redshift, mej, vej, eta, tshock, shocked_fraction, cos_
526
575
  lambdas=lambda_observer_frame,
527
576
  spectra=spectra)
528
577
  else:
529
- return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame / day_to_s,
578
+ return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
530
579
  spectra=spectra, lambda_array=lambda_observer_frame,
531
580
  **kwargs)
532
581