lightcurvelynx.models.redback_models
Wrappers for the models defined in redback.
https://github.com/nikhil-sarin/redback https://redback.readthedocs.io/en/latest/
Classes
A wrapper for redback models. The user must provide the redback model function (or |
Module Contents
- class RedbackWrapperModel(source, *, priors=None, parameters=None, phase_bounds=None, wave_bounds=(None, None), time_extrapolation=None, **kwargs)[source]
Bases:
lightcurvelynx.models.physical_model.SEDModel,citation_compass.CiteClassA wrapper for redback models. The user must provide the redback model function (or the name of the model in the redback library), the parameter values to use for that model, and the valid phase bounds for that model.
Parameterized values include:
dec - The object’s declination in degrees. [from BasePhysicalModel]
distance - The object’s luminosity distance in pc. [from BasePhysicalModel]
ra - The object’s right ascension in degrees. [from BasePhysicalModel]
redshift - The object’s redshift. [from BasePhysicalModel]
t0 - The t0 of the zero phase, date. [from BasePhysicalModel]
Additional parameterized values are used for specific redback models.
References
redback - https://ui.adsabs.harvard.edu/abs/2024MNRAS.531.1203S/abstract
Individual models might require citation. See references in the redback documentation.
- source
The underlying source function that maps time + wavelength to flux.
- Type:
function
- source_name
The name used to set the source.
- Type:
str
- Parameters:
source (str or function) – The name of the redback model function used to generate the SEDs or the actual function itself.
priors (dict, bilby.prior.PriorDict, or BilbyPriorNode, optional) – The redback model’s Bilby priors.
parameters (dict, optional) – A dictionary of parameter setters to pass to the source function.
phase_bounds (tuple of (float, float), required) – A tuple of (min_phase, max_phase) in days to set the phase bounds for the model. This is required because redback models are only defined for certain phase ranges, and we want to make sure we are not evaluating the model at invalid points. For most redback’s explosion-based models, the valid phase_bound range would be (1.e-3, None). Users should consult with the redback team for valid phase_bound values Defaults to None which raises an error.
wave_bounds (tuple of (float, float), optional) – A tuple of (min_wave, max_wave) in angstroms to set the wavelength bounds for the model. If not provided, the code will try to infer the bounds from the model result. However this is not always possible and may lead to evaluating the model at invalid points. Default: (None, None) which corresponds to (-inf, inf).
time_extrapolation (tuple of Extrapolation, optional) – The extrapolation method to use for times outside the model’s bounds. If nothing is provided, then the code adds zero padding.
**kwargs (dict, optional) – Any additional keyword arguments.
Note
You can automatically extract the priors for a model (in the correct format) using redback’s get_priors() function and passing the name of the model as the model argument: priors = get_priors(model=”one_component_kilonova_model”)
- minwave(graph_state=None)[source]
Get the minimum wavelength of the model.
- Parameters:
graph_state (GraphState, optional) – An object mapping graph parameters to their values. Not used for this model.
- Returns:
minwave – The minimum wavelength of the model (in angstroms) or None if the model does not have a defined minimum wavelength.
- Return type:
float or None
- maxwave(graph_state=None)[source]
Get the maximum wavelength of the model.
- Parameters:
graph_state (GraphState, optional) – An object mapping graph parameters to their values. Not used for this model.
- Returns:
maxwave – The maximum wavelength of the model (in angstroms) or None if the model does not have a defined maximum wavelength.
- Return type:
float or None
- minphase(**kwargs)[source]
Get the minimum supported phase of the model in days.
- Parameters:
**kwargs (dict) – Additional keyword arguments, not used in this method.
- Returns:
minphase – The minimum phase of the model (in days) or None if the model does not have a defined minimum phase.
- Return type:
float or None
- maxphase(**kwargs)[source]
Get the maximum supported phase of the model in days.
- Parameters:
**kwargs (dict) – Additional keyword arguments, not used in this method.
- Returns:
maximum – The maximum phase of the model (in days) or None if the model does not have a defined maximum phase.
- Return type:
float or None
- compute_sed_with_extrapolation(times, wavelengths, graph_state, **kwargs)[source]
Draw effect-free observations for this object, extrapolating to times and wavelengths where the model is not defined.
We override this method because the extrapolation bounds will depend on the materialized RedbackTimeSeriesSource object, so we need to do the precomputation to get that object. We will cache the object so we don’t perform the computation twice.
- Parameters:
times (numpy.ndarray) – A length T array of rest frame timestamps.
wavelengths (numpy.ndarray, optional) – A length N array of wavelengths (in angstroms).
graph_state (GraphState) – An object mapping graph parameters to their values.
**kwargs (dict, optional) – Any additional keyword arguments.
- Returns:
flux_density – A length T x N matrix of SED values (in nJy).
- Return type:
numpy.ndarray
- compute_sed(times, wavelengths, graph_state=None, **kwargs)[source]
Draw effect-free observations for this object.
- Parameters:
times (numpy.ndarray) – A length T array of rest frame timestamps (MJD).
wavelengths (numpy.ndarray, optional) – A length N array of wavelengths (in angstroms).
graph_state (GraphState) – An object mapping graph parameters to their values.
**kwargs (dict, optional) – Any additional keyword arguments.
- Returns:
flux_density – A length T x N matrix of SED values (in nJy).
- Return type:
numpy.ndarray