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.
Files changed (40) hide show
  1. redback/__init__.py +1 -1
  2. redback/filters.py +57 -45
  3. redback/likelihoods.py +274 -6
  4. redback/model_library.py +2 -2
  5. redback/plotting.py +5 -3
  6. redback/priors/blackbody_spectrum_at_z.prior +3 -0
  7. redback/priors/bpl_cooling_envelope.prior +9 -0
  8. redback/priors/gaussianrise_cooling_envelope.prior +1 -5
  9. redback/priors/gaussianrise_cooling_envelope_bolometric.prior +1 -5
  10. redback/priors/powerlaw_plus_blackbody.prior +12 -0
  11. redback/priors/powerlaw_plus_blackbody_spectrum_at_z.prior +13 -0
  12. redback/priors/salt2.prior +6 -0
  13. redback/priors/shock_cooling_and_arnett_bolometric.prior +11 -0
  14. redback/priors/smooth_exponential_powerlaw_cooling_envelope_bolometric.prior +9 -0
  15. redback/priors/sn_nickel_fallback.prior +9 -0
  16. redback/priors/wr_bh_merger.prior +10 -0
  17. redback/priors/wr_bh_merger_bolometric.prior +8 -0
  18. redback/priors.py +14 -3
  19. redback/sed.py +185 -41
  20. redback/simulate_transients.py +13 -3
  21. redback/tables/filters.csv +260 -258
  22. redback/tables/qdot_rosswogkorobkin24.npz +0 -0
  23. redback/transient_models/afterglow_models.py +32 -16
  24. redback/transient_models/combined_models.py +16 -11
  25. redback/transient_models/extinction_models.py +310 -84
  26. redback/transient_models/gaussianprocess_models.py +1 -12
  27. redback/transient_models/kilonova_models.py +3 -3
  28. redback/transient_models/phase_models.py +97 -43
  29. redback/transient_models/phenomenological_models.py +172 -0
  30. redback/transient_models/spectral_models.py +101 -0
  31. redback/transient_models/stellar_interaction_models.py +254 -0
  32. redback/transient_models/supernova_models.py +349 -62
  33. redback/transient_models/tde_models.py +193 -54
  34. redback/utils.py +34 -7
  35. {redback-1.1.dist-info → redback-1.12.1.dist-info}/METADATA +7 -4
  36. {redback-1.1.dist-info → redback-1.12.1.dist-info}/RECORD +39 -28
  37. {redback-1.1.dist-info → redback-1.12.1.dist-info}/WHEEL +1 -1
  38. redback/tables/qdot_rosswogkorobkin24.pck +0 -0
  39. {redback-1.1.dist-info → redback-1.12.1.dist-info}/licenses/LICENCE.md +0 -0
  40. {redback-1.1.dist-info → redback-1.12.1.dist-info}/top_level.txt +0 -0
@@ -12,19 +12,29 @@ extinction_afterglow_base_models = ['tophat', 'cocoon', 'gaussian',
12
12
  'gaussiancore', 'gaussian',
13
13
  'smoothpowerlaw', 'powerlawcore',
14
14
  'tophat','tophat_from_emulator',
15
- 'kilonova_afterglow_redback', 'kilonova_afterglow_nakarpiran',
16
15
  'tophat_redback', 'gaussian_redback', 'twocomponent_redback',
17
16
  'powerlaw_redback', 'alternativepowerlaw_redback', 'doublegaussian_redback',
18
17
  'tophat_redback_refreshed', 'gaussian_redback_refreshed',
19
18
  'twocomponent_redback_refreshed','powerlaw_redback_refreshed',
20
- 'alternativepowerlaw_redback_refreshed', 'doublegaussian_redback_refreshed']
19
+ 'alternativepowerlaw_redback_refreshed', 'doublegaussian_redback_refreshed',
20
+ 'jetsimpy_tophat', 'jetsimpy_gaussian', 'jetsimpy_powerlaw']
21
21
 
22
+ extinction_general_synchrotron_models = ['pwn', 'kilonova_afterglow_redback', 'kilonova_afterglow_nakarpiran',
23
+ 'thermal_synchrotron_lnu', 'thermal_synchrotron_fluxdensity',
24
+ 'tde_synchrotron', 'synchrotron_massloss', 'synchrotron_ism',
25
+ 'synchrotron_pldensity', 'thermal_synchrotron_v2_lnu',
26
+ 'thermal_synchrotron_v2_fluxdensity']
27
+ extinction_stellar_interaction_models = ['wr_bh_merger']
22
28
  extinction_integrated_flux_afterglow_models = extinction_afterglow_base_models
29
+
23
30
  extinction_supernova_base_models = ['sn_exponential_powerlaw', 'arnett', 'shock_cooling_and_arnett',
24
31
  'basic_magnetar_powered', 'slsn', 'magnetar_nickel',
25
32
  'csm_interaction', 'csm_nickel', 'type_1a', 'type_1c',
26
33
  'general_magnetar_slsn','general_magnetar_driven_supernova', 'sn_fallback',
27
- 'csm_shock_and_arnett', 'shocked_cocoon_and_arnett', 'csm_shock_and_arnett_two_rphots']
34
+ 'sn_nickel_fallback', 'shockcooling_morag_and_arnett',
35
+ 'shockcooling_sapirandwaxman_and_arnett',
36
+ 'csm_shock_and_arnett', 'shocked_cocoon_and_arnett',
37
+ 'csm_shock_and_arnett_two_rphots', 'typeII_surrogate_sarin25']
28
38
  extinction_kilonova_base_models = ['nicholl_bns', 'mosfit_rprocess', 'mosfit_kilonova',
29
39
  'power_law_stratified_kilonova','bulla_bns_kilonova',
30
40
  'bulla_nsbh_kilonova', 'kasen_bns_kilonova','two_layer_stratified_kilonova',
@@ -32,17 +42,23 @@ extinction_kilonova_base_models = ['nicholl_bns', 'mosfit_rprocess', 'mosfit_kil
32
42
  'one_component_kilonova_model', 'one_component_ejecta_relation',
33
43
  'one_component_ejecta_relation_projection', 'two_component_bns_ejecta_relation',
34
44
  'polytrope_eos_two_component_bns', 'one_component_nsbh_ejecta_relation',
35
- 'two_component_nsbh_ejecta_relation','metzger_kilonova_model']
45
+ 'two_component_nsbh_ejecta_relation','one_comp_kne_rosswog_heatingrate',
46
+ 'two_comp_kne_rosswog_heatingrate','metzger_kilonova_model']
47
+
36
48
  extinction_tde_base_models = ['tde_analytical', 'tde_semianalytical', 'gaussianrise_cooling_envelope',
37
- 'cooling_envelope', 'bpl_cooling_envelope']
49
+ 'cooling_envelope', 'bpl_cooling_envelope', 'tde_fallback',
50
+ 'fitted', 'fitted_pldecay', 'fitted_expdecay', 'stream_stream_tde']
38
51
  extinction_magnetar_driven_base_models = ['basic_mergernova', 'general_mergernova', 'general_mergernova_thermalisation',
39
52
  'general_mergernova_evolution', 'metzger_magnetar_driven_kilonova_model',
40
53
  'general_metzger_magnetar_driven', 'general_metzger_magnetar_driven_thermalisation',
41
54
  'general_metzger_magnetar_driven_evolution']
42
- extinction_shock_powered_base_models = ['shocked_cocoon', 'shock_cooling', 'csm_shock_breakout']
55
+ extinction_shock_powered_base_models = ['shocked_cocoon', 'shock_cooling', 'csm_shock_breakout',
56
+ 'shockcooling_morag', 'shockcooling_sapirandwaxman']
43
57
 
44
58
  extinction_model_library = {'kilonova': extinction_kilonova_base_models,
45
59
  'supernova': extinction_supernova_base_models,
60
+ 'general_synchrotron': extinction_general_synchrotron_models,
61
+ 'stellar_interaction': extinction_stellar_interaction_models,
46
62
  'afterglow': extinction_afterglow_base_models,
47
63
  'tde': extinction_tde_base_models,
48
64
  'magnetar_driven': extinction_magnetar_driven_base_models,
@@ -52,7 +68,9 @@ extinction_model_library = {'kilonova': extinction_kilonova_base_models,
52
68
  model_library = {'supernova': 'supernova_models', 'afterglow': 'afterglow_models',
53
69
  'magnetar_driven': 'magnetar_driven_ejecta_models', 'tde': 'tde_models',
54
70
  'kilonova': 'kilonova_models', 'shock_powered': 'shock_powered_models',
55
- 'integrated_flux_afterglow': 'afterglow_models'}
71
+ 'integrated_flux_afterglow': 'afterglow_models',
72
+ 'stellar_interaction': 'stellar_interaction_models',
73
+ 'general_synchrotron': 'general_synchrotron_models'}
56
74
 
57
75
  def _get_correct_function(base_model, model_type=None):
58
76
  """
@@ -79,180 +97,388 @@ def _get_correct_function(base_model, model_type=None):
79
97
 
80
98
  return function
81
99
 
82
- def _perform_extinction(flux_density, angstroms, av, r_v):
100
+ def _perform_extinction(flux_density, angstroms, av_host, rv_host, av_mw=0.0, rv_mw=3.1,
101
+ host_law='fitzpatrick99', mw_law='fitzpatrick99', **kwargs):
83
102
  """
84
- :param flux_density: flux density in mjy outputted by the model
85
- :param angstroms: wavelength in angstroms
86
- :param av: absolute mag extinction
87
- :param r_v: extinction parameter
88
- :return: flux
103
+ Apply host galaxy and/or Milky Way extinction to flux density
104
+
105
+ :param flux_density: flux density in mJy outputted by the model
106
+ :param angstroms: wavelength in angstroms (observer frame)
107
+ :param av_host: V-band extinction from host galaxy in magnitudes
108
+ :param rv_host: extinction parameter for host galaxy (default 3.1)
109
+ :param av_mw: V-band extinction from Milky Way in magnitudes
110
+ :param rv_mw: extinction parameter for Milky Way (default 3.1)
111
+ :param redshift: source redshift (needed for host extinction)
112
+ :param host_law: extinction law for host galaxy
113
+ ('fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89')
114
+ :param mw_law: extinction law for Milky Way
115
+ ('fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89')
116
+ :param kwargs: additional parameters for specific extinction laws
117
+ :return: flux density with extinction applied
89
118
  """
90
- import extinction # noqa
119
+ import extinction
120
+
121
+ redshift = kwargs['redshift']
91
122
  if isinstance(angstroms, float):
92
- angstroms = np.array([angstroms])
93
- mag_extinction = extinction.fitzpatrick99(angstroms, av, r_v=r_v)
94
- if av < 10:
95
- mask= mag_extinction > 10
96
- mag_extinction[mask]=0
97
- flux_density = extinction.apply(mag_extinction, flux_density)
98
- return flux_density
99
-
100
- def _evaluate_extinction_model(time, av, model_type, **kwargs):
123
+ angstroms = np.array([angstroms])
124
+
125
+ # Available extinction laws
126
+ extinction_laws = {
127
+ 'fitzpatrick99': extinction.fitzpatrick99,
128
+ 'fm07': extinction.fm07,
129
+ 'calzetti00': extinction.calzetti00,
130
+ 'odonnell94': extinction.odonnell94,
131
+ 'ccm89': extinction.ccm89
132
+ }
133
+
134
+ # Validate extinction laws
135
+ if host_law not in extinction_laws:
136
+ raise ValueError(f"Unknown host extinction law: {host_law}. "
137
+ f"Available: {list(extinction_laws.keys())}")
138
+ if mw_law not in extinction_laws:
139
+ raise ValueError(f"Unknown MW extinction law: {mw_law}. "
140
+ f"Available: {list(extinction_laws.keys())}")
141
+
142
+ flux_extincted = flux_density.copy() if hasattr(flux_density, 'copy') else np.array(flux_density)
143
+
144
+ # Apply host galaxy extinction (in rest frame)
145
+ if av_host > 0:
146
+ # Convert observer frame to rest frame wavelengths
147
+ angstroms_rest = angstroms / (1 + redshift)
148
+
149
+ # Get host extinction law function
150
+ host_extinction_func = extinction_laws[host_law]
151
+
152
+ # Calculate extinction - handle different function signatures
153
+ try:
154
+ if host_law in ['fitzpatrick99', 'fm07', 'odonnell94', 'ccm89']:
155
+ mag_extinction_host = host_extinction_func(angstroms_rest, av_host, rv_host)
156
+ elif host_law == 'calzetti00':
157
+ # Calzetti law doesn't use R_V parameter
158
+ mag_extinction_host = host_extinction_func(angstroms_rest, av_host)
159
+ except Exception as e:
160
+ raise ValueError(f"Error applying {host_law} extinction law: {e}")
161
+
162
+ # Cap extreme extinction values
163
+ if av_host < 10:
164
+ mask = mag_extinction_host > 10
165
+ mag_extinction_host[mask] = 0
166
+
167
+ # Apply host extinction
168
+ flux_extincted = extinction.apply(mag_extinction_host, flux_extincted)
169
+
170
+ # Apply Milky Way extinction (in observer frame)
171
+ if av_mw > 0:
172
+ # MW extinction applies to observed wavelengths
173
+ mw_extinction_func = extinction_laws[mw_law]
174
+
175
+ # Calculate extinction
176
+ try:
177
+ if mw_law in ['fitzpatrick99', 'fm07', 'odonnell94', 'ccm89']:
178
+ mag_extinction_mw = mw_extinction_func(angstroms, av_mw, rv_mw)
179
+ elif mw_law == 'calzetti00':
180
+ mag_extinction_mw = mw_extinction_func(angstroms, av_mw)
181
+ except Exception as e:
182
+ raise ValueError(f"Error applying {mw_law} extinction law: {e}")
183
+
184
+ # Cap extreme extinction values
185
+ if av_mw < 10:
186
+ mask = mag_extinction_mw > 10
187
+ mag_extinction_mw[mask] = 0
188
+
189
+ # Apply MW extinction
190
+ flux_extincted = extinction.apply(mag_extinction_mw, flux_extincted)
191
+
192
+ return flux_extincted
193
+
194
+
195
+ def _evaluate_extinction_model(time, av_host, av_mw=0.0, model_type=None, **kwargs):
101
196
  """
102
- Generalised evaluate extinction function
197
+ Generalised evaluate extinction function with host and MW extinction
103
198
 
104
199
  :param time: time in days
105
- :param av: absolute mag extinction
200
+ :param av_host: V-band extinction from host galaxy in magnitudes
201
+ :param av_mw: V-band extinction from Milky Way in magnitudes
106
202
  :param model_type: None, or one of the types implemented
107
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
108
- and r_v, default is 3.1
109
- :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux' with extinction applied
203
+ :param kwargs: Must include all parameters for base_model plus:
204
+ - redshift: source redshift (required for host extinction)
205
+ - rv_host: host R_V parameter (default 3.1)
206
+ - rv_mw: MW R_V parameter (default 3.1)
207
+ - host_law: host extinction law (default 'fitzpatrick99')
208
+ - mw_law: MW extinction law (default 'fitzpatrick99')
209
+ :return: flux/magnitude with extinction applied
110
210
  """
111
211
  base_model = kwargs['base_model']
112
212
  if kwargs['base_model'] in ['thin_shell_supernova', 'homologous_expansion_supernova']:
113
213
  kwargs['base_model'] = kwargs.get('submodel', 'arnett_bolometric')
214
+
215
+ # Extract extinction parameters
216
+ rv_host = kwargs.pop('rv_host', 3.1)
217
+ rv_mw = kwargs.pop('rv_mw', 3.1)
218
+ host_law = kwargs.pop('host_law', 'fitzpatrick99')
219
+ mw_law = kwargs.pop('mw_law', 'fitzpatrick99')
220
+
114
221
  if kwargs['output_format'] == 'flux_density':
115
222
  frequency = kwargs['frequency']
116
223
  if isinstance(frequency, float):
117
224
  frequency = np.ones(len(time)) * frequency
225
+
118
226
  angstroms = redback.utils.nu_to_lambda(frequency)
227
+
119
228
  temp_kwargs = kwargs.copy()
120
229
  temp_kwargs['output_format'] = 'flux_density'
121
230
  function = _get_correct_function(base_model=base_model, model_type=model_type)
122
231
  flux_density = function(time, **temp_kwargs)
123
- r_v = kwargs.get('r_v', 3.1)
124
- flux_density = _perform_extinction(flux_density=flux_density, angstroms=angstroms, av=av, r_v=r_v)
232
+
233
+ # Apply extinction
234
+ flux_density = _perform_extinction(
235
+ flux_density=flux_density,
236
+ angstroms=angstroms,
237
+ av_host=av_host,
238
+ rv_host=rv_host,
239
+ av_mw=av_mw,
240
+ rv_mw=rv_mw,
241
+ host_law=host_law,
242
+ mw_law=mw_law,
243
+ **kwargs
244
+ )
125
245
  return flux_density
246
+
126
247
  else:
127
248
  temp_kwargs = kwargs.copy()
128
249
  temp_kwargs['output_format'] = 'spectra'
129
250
  time_obs = time
130
251
  function = _get_correct_function(base_model=base_model, model_type=model_type)
131
252
  spectra_tuple = function(time, **temp_kwargs)
253
+
132
254
  flux_density = spectra_tuple.spectra
133
255
  lambdas = spectra_tuple.lambdas
134
256
  time_observer_frame = spectra_tuple.time
135
- r_v = kwargs.get('r_v', 3.1)
136
- flux_density = _perform_extinction(flux_density=flux_density, angstroms=lambdas, av=av, r_v=r_v)
137
- return sed.get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
138
- spectra=flux_density, lambda_array=spectra_tuple.lambdas,
139
- **kwargs)
257
+
258
+ # Apply extinction
259
+ flux_density = _perform_extinction(
260
+ flux_density=flux_density,
261
+ angstroms=lambdas,
262
+ av_host=av_host,
263
+ rv_host=rv_host,
264
+ av_mw=av_mw,
265
+ rv_mw=rv_mw,
266
+ host_law=host_law,
267
+ mw_law=mw_law,
268
+ **kwargs
269
+ )
270
+
271
+ return sed.get_correct_output_format_from_spectra(
272
+ time=time_obs,
273
+ time_eval=time_observer_frame,
274
+ spectra=flux_density,
275
+ lambda_array=lambdas,
276
+ **kwargs
277
+ )
140
278
 
141
279
  @citation_wrapper('redback')
142
- def extinction_with_function(time, av, **kwargs):
280
+ def extinction_with_function(time, av_host, **kwargs):
143
281
  """
144
282
  Extinction model when using your own specified function
145
283
 
146
284
  :param time: time in observer frame in days
147
- :param av: absolute mag extinction
148
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
149
- and r_v, default is 3.1
150
- :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux' with extinction applied
285
+ :param av_host: V-band extinction from host galaxy in magnitudes
286
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
287
+ - redshift: source redshift (required)
288
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
289
+ - rv_host: host R_V parameter (default 3.1)
290
+ - rv_mw: MW R_V parameter (default 3.1)
291
+ - host_law: host extinction law (default 'fitzpatrick99')
292
+ - mw_law: MW extinction law (default 'fitzpatrick99')
293
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
294
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
151
295
  """
152
- output = _evaluate_extinction_model(time=time, av=av, model_type=None, **kwargs)
296
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type=None, **kwargs)
153
297
  return output
154
298
 
155
299
  @citation_wrapper('redback')
156
- def extinction_with_supernova_base_model(time, av, **kwargs):
300
+ def extinction_with_supernova_base_model(time, av_host, **kwargs):
157
301
  """
158
302
  Extinction with models implemented in supernova_models
159
303
 
160
304
  :param time: time in observer frame in days
161
- :param av: absolute mag extinction
162
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
163
- and r_v, default is 3.1
164
- :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux' with extinction applied
305
+ :param av_host: V-band extinction from host galaxy in magnitudes
306
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
307
+ - redshift: source redshift (required)
308
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
309
+ - rv_host: host R_V parameter (default 3.1)
310
+ - rv_mw: MW R_V parameter (default 3.1)
311
+ - host_law: host extinction law (default 'fitzpatrick99')
312
+ - mw_law: MW extinction law (default 'fitzpatrick99')
313
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
314
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
165
315
  """
166
- output = _evaluate_extinction_model(time=time, av=av, model_type='supernova', **kwargs)
316
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='supernova', **kwargs)
167
317
  return output
168
318
 
169
319
  @citation_wrapper('redback')
170
- def extinction_with_kilonova_base_model(time, av, **kwargs):
320
+ def extinction_with_kilonova_base_model(time, av_host, **kwargs):
171
321
  """
172
322
  Extinction with models implemented in kilonova_models
173
323
 
174
324
  :param time: time in observer frame in days
175
- :param av: absolute mag extinction
176
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
177
- and r_v, default is 3.1
178
- :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux' with extinction applied
325
+ :param av_host: V-band extinction from host galaxy in magnitudes
326
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
327
+ - redshift: source redshift (required)
328
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
329
+ - rv_host: host R_V parameter (default 3.1)
330
+ - rv_mw: MW R_V parameter (default 3.1)
331
+ - host_law: host extinction law (default 'fitzpatrick99')
332
+ - mw_law: MW extinction law (default 'fitzpatrick99')
333
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
334
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
179
335
  """
180
- output = _evaluate_extinction_model(time=time, av=av, model_type='kilonova', **kwargs)
336
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='kilonova', **kwargs)
181
337
  return output
182
338
 
183
339
  @citation_wrapper('redback')
184
- def extinction_with_tde_base_model(time, av, **kwargs):
340
+ def extinction_with_tde_base_model(time, av_host, **kwargs):
185
341
  """
186
342
  Extinction with models implemented in tde_models
187
343
 
188
344
  :param time: time in observer frame in days
189
- :param av: absolute mag extinction
190
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
191
- and r_v, default is 3.1
192
- :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux' with extinction applied
345
+ :param av_host: V-band extinction from host galaxy in magnitudes
346
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
347
+ - redshift: source redshift (required)
348
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
349
+ - rv_host: host R_V parameter (default 3.1)
350
+ - rv_mw: MW R_V parameter (default 3.1)
351
+ - host_law: host extinction law (default 'fitzpatrick99')
352
+ - mw_law: MW extinction law (default 'fitzpatrick99')
353
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
354
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
193
355
  """
194
- output = _evaluate_extinction_model(time=time, av=av, model_type='tde', **kwargs)
356
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='tde', **kwargs)
195
357
  return output
196
358
 
197
359
  @citation_wrapper('redback')
198
- def extinction_with_shock_powered_base_model(time, av, **kwargs):
360
+ def extinction_with_shock_powered_base_model(time, av_host, **kwargs):
199
361
  """
200
- Extinction with models implemented in tde_models
362
+ Extinction with models implemented in shock_powered_models
201
363
 
202
364
  :param time: time in observer frame in days
203
- :param av: absolute mag extinction
204
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
205
- and r_v, default is 3.1
206
- :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux' with extinction applied
365
+ :param av_host: V-band extinction from host galaxy in magnitudes
366
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
367
+ - redshift: source redshift (required)
368
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
369
+ - rv_host: host R_V parameter (default 3.1)
370
+ - rv_mw: MW R_V parameter (default 3.1)
371
+ - host_law: host extinction law (default 'fitzpatrick99')
372
+ - mw_law: MW extinction law (default 'fitzpatrick99')
373
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
374
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
207
375
  """
208
- output = _evaluate_extinction_model(time=time, av=av, model_type='shock_powered', **kwargs)
376
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='shock_powered', **kwargs)
209
377
  return output
210
378
 
211
379
  @citation_wrapper('redback')
212
- def extinction_with_magnetar_driven_base_model(time, av, **kwargs):
380
+ def extinction_with_magnetar_driven_base_model(time, av_host, **kwargs):
213
381
  """
214
382
  Extinction with models implemented in magnetar_driven_ejecta_models
215
383
 
216
384
  :param time: time in observer frame in days
217
- :param av: absolute mag extinction
218
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
219
- and r_v, default is 3.1
220
- :return: set by output format kwarg - 'flux_density', 'magnitude', 'flux' with extinction applied
385
+ :param av_host: V-band extinction from host galaxy in magnitudes
386
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
387
+ - redshift: source redshift (required)
388
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
389
+ - rv_host: host R_V parameter (default 3.1)
390
+ - rv_mw: MW R_V parameter (default 3.1)
391
+ - host_law: host extinction law (default 'fitzpatrick99')
392
+ - mw_law: MW extinction law (default 'fitzpatrick99')
393
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
394
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
395
+ """
396
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='magnetar_driven', **kwargs)
397
+ return output
398
+
399
+ @citation_wrapper('redback')
400
+ def extinction_with_stellar_interaction_base_model(time, av_host, **kwargs):
401
+ """
402
+ Extinction with models implemented in stellar_interaction_models
403
+
404
+ :param time: time in observer frame in days
405
+ :param av_host: V-band extinction from host galaxy in magnitudes
406
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
407
+ - redshift: source redshift (required)
408
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
409
+ - rv_host: host R_V parameter (default 3.1)
410
+ - rv_mw: MW R_V parameter (default 3.1)
411
+ - host_law: host extinction law (default 'fitzpatrick99')
412
+ - mw_law: MW extinction law (default 'fitzpatrick99')
413
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
414
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
221
415
  """
222
- output = _evaluate_extinction_model(time=time, av=av, model_type='magnetar_driven', **kwargs)
416
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='stellar_interaction', **kwargs)
223
417
  return output
224
418
 
419
+ @citation_wrapper('redback')
420
+ def extinction_with_general_synchrotron_base_model(time, av_host, **kwargs):
421
+ """
422
+ Extinction with models implemented in general_synchrotron_models
423
+
424
+ :param time: time in observer frame in days
425
+ :param av_host: V-band extinction from host galaxy in magnitudes
426
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
427
+ - redshift: source redshift (required)
428
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
429
+ - rv_host: host R_V parameter (default 3.1)
430
+ - rv_mw: MW R_V parameter (default 3.1)
431
+ - host_law: host extinction law (default 'fitzpatrick99')
432
+ - mw_law: MW extinction law (default 'fitzpatrick99')
433
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
434
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
435
+ """
436
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='general_synchrotron', **kwargs)
437
+ return output
225
438
 
226
439
  @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021arXiv210601556S/abstract')
227
- def extinction_with_afterglow_base_model(time, av, **kwargs):
440
+ def extinction_with_afterglow_base_model(time, av_host, **kwargs):
228
441
  """
229
442
  Extinction with models implemented in afterglow_models
230
443
 
231
444
  :param time: time in observer frame in days
232
- :param av: absolute mag extinction
233
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
234
- and r_v, default is 3.1
235
- :return: flux_density or magnitude depending on kwargs['output_format']
236
- Note that only sed varient models can take magnitude as an output
445
+ :param av_host: V-band extinction from host galaxy in magnitudes
446
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
447
+ - redshift: source redshift (required)
448
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
449
+ - rv_host: host R_V parameter (default 3.1)
450
+ - rv_mw: MW R_V parameter (default 3.1)
451
+ - host_law: host extinction law (default 'fitzpatrick99')
452
+ - mw_law: MW extinction law (default 'fitzpatrick99')
453
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
454
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
455
+ Note that only sed variant models can take magnitude as an output
237
456
  """
238
- output = _evaluate_extinction_model(time=time, av=av, model_type='afterglow', **kwargs)
457
+ output = _evaluate_extinction_model(time=time, av_host=av_host, model_type='afterglow', **kwargs)
239
458
  return output
240
459
 
241
460
  @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2021arXiv210601556S/abstract')
242
461
  def extinction_afterglow_galactic_dust_to_gas_ratio(time, lognh, factor=2.21, **kwargs):
243
462
  """
244
- Extinction with afterglow models and a dust-to-gas ratio
463
+ Extinction with afterglow models using galactic dust-to-gas ratio
245
464
 
246
465
  :param time: time in observer frame in days
247
466
  :param lognh: log10 hydrogen column density
248
- :param factor: factor to convert nh to av i.e., av = nh/factor
249
- :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model']
250
- :return: set by output format kwarg - 'flux_density', 'magnitude', 'flux' with extinction applied
467
+ :param factor: factor to convert nh to av i.e., av = nh/factor (default 2.21)
468
+ :param kwargs: Must be all the parameters required by the base_model specified using kwargs['base_model'] plus:
469
+ - redshift: source redshift (required)
470
+ - av_mw: MW V-band extinction in magnitudes (default 0.0)
471
+ - rv_host: host R_V parameter (default 3.1)
472
+ - rv_mw: MW R_V parameter (default 3.1)
473
+ - host_law: host extinction law (default 'fitzpatrick99')
474
+ - mw_law: MW extinction law (default 'fitzpatrick99')
475
+ Available extinction laws: 'fitzpatrick99', 'fm07', 'calzetti00', 'odonnell94', 'ccm89'
476
+ :return: set by kwargs['output_format'] - 'flux_density', 'magnitude', 'flux', 'spectra' with extinction applied
251
477
  """
252
478
  factor = factor * 1e21
253
479
  nh = 10 ** lognh
254
480
  av = nh / factor
255
- output = extinction_with_afterglow_base_model(time=time, av=av, **kwargs)
481
+ output = extinction_with_afterglow_base_model(time=time, av_host=av, **kwargs)
256
482
  return output
257
483
 
258
484
 
@@ -1,4 +1,3 @@
1
- import george.modeling
2
1
  from redback.transient_models import phenomenological_models as pm
3
2
 
4
3
  def calculate_flux_with_labels(time, t0, tau_rise, tau_fall, labels, **kwargs):
@@ -32,14 +31,4 @@ def calculate_flux_with_labels(time, t0, tau_rise, tau_fall, labels, **kwargs):
32
31
  # Construct the result dictionary with labels
33
32
  flux_results = {f'{label}': flux_matrix[i] for i, label in enumerate(labels)}
34
33
 
35
- return flux_results
36
-
37
- class BazinGPModel(george.modeling.Model):
38
- def __init__(self, band_labels):
39
- self.parameter_names = ['t0', 'tau_rise', 'tau_fall']
40
- self.band_labels = band_labels
41
- for label in band_labels:
42
- self.parameter_names.extend([f'a_{label}', f'b_{label}'])
43
-
44
- def get_flux(self, t):
45
- return calculate_flux_with_labels(t, **self.get_parameter_vector())
34
+ return flux_results
@@ -738,7 +738,7 @@ def bulla_bns_kilonova(time, redshift, mej_dyn, mej_disk, phi, costheta_obs, **k
738
738
  spectra = output.spectra / (4 * np.pi * dl ** 2) # to erg/s/cm^2/Angstrom
739
739
  spectra = spectra * uu.erg / (uu.s * uu.cm ** 2 * uu.Angstrom)
740
740
  time_obs = time
741
- return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame / day_to_s,
741
+ return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
742
742
  spectra=spectra, lambda_array=lambda_observer_frame,
743
743
  **kwargs)
744
744
 
@@ -791,7 +791,7 @@ def bulla_nsbh_kilonova(time, redshift, mej_dyn, mej_disk, costheta_obs, **kwarg
791
791
  spectra = output.spectra / (4 * np.pi * dl ** 2) # to erg/s/cm^2/Angstrom
792
792
  spectra = spectra * uu.erg / (uu.s * uu.cm ** 2 * uu.Angstrom)
793
793
  time_obs = time
794
- return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame / day_to_s,
794
+ return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
795
795
  spectra=spectra, lambda_array=lambda_observer_frame,
796
796
  **kwargs)
797
797
 
@@ -842,7 +842,7 @@ def kasen_bns_kilonova(time, redshift, mej, vej, chi, **kwargs):
842
842
  spectra = output.spectra / (4 * np.pi * dl ** 2) # to erg/s/cm^2/Angstrom
843
843
  spectra = spectra * uu.erg / (uu.s * uu.cm ** 2 * uu.Angstrom)
844
844
  time_obs = time
845
- return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame / day_to_s,
845
+ return get_correct_output_format_from_spectra(time=time_obs, time_eval=time_observer_frame,
846
846
  spectra=spectra, lambda_array=lambda_observer_frame,
847
847
  **kwargs)
848
848
  @citation_wrapper('https://ui.adsabs.harvard.edu/abs/2020ApJ...891..152H/abstract')