lightcurvelynx.models.bayesn
Classes
A bayesian model for supernova type Ia |
Module Contents
- class BayesnModel(theta=None, Av=None, Rv=None, t0=0.0, Amplitude=1.0, M20_path_or_url='https://github.com/bayesn/bayesn-model-files/raw/refs/heads/main/BAYESN.M20/', W0_filename='W0.txt', W1_filename='W1.txt', l_knots_filename='l_knots.txt', tau_knots_filename='tau_knots.txt', hsiao_path_or_url='https://github.com/bayesn/bayesn/raw/refs/heads/main/bayesn/data/hsiao.h5', **kwargs)[source]
Bases:
lightcurvelynx.models.physical_model.SEDModel,citation_compass.CiteClassA bayesian model for supernova type Ia
The model is defined in (Mandel et al 2022) as:
flux(time, wave) = H_grid * 10 ** (-0.4 * W_grid) * 10 ** (-0.4 * (distmod _ m_abs))
This class is based on the bayesian implementation at: https://github.com/bayesn/bayesn/blob/main/bayesn/bayesn_model.py
Parameterized values include:
ra - The object’s right ascension in degrees. [from BasePhysicalModel]
dec - The object’s declination in degrees. [from BasePhysicalModel]
redshift - The object’s redshift. [from BasePhysicalModel]
t0 - The t0 of the zero phase, date. [from BasePhysicalModel]
Amplitude - The fixed normalisation factor for distance modulus. [from Amplitude class]
theta - The bayeSN theta parameter.
Av - The bayeSN Av parameter.
Rv - The bayeSN Rv parameter.
References
BayeSN: Mandel S., 2020 - https://arxiv.org/pdf/2008.07538
M20 model: Mandel et al. 2022 (MNRAS 510, 3, 3939-3966)
T21 model: Thorp et al. 2021 (MNRAS 508, 3, 4310-4331) - currently unused
W22 model: Ward et al. 2023 (ApJ 956, 2, 111) - currently unused
Hsiao spectral template: Hsiao E. Y., 2009 - https://arxiv.org/abs/1503.02293
- _hsiao_phase
The phase for hsiao template.
- Type:
numpy.ndarray
- _hsiao_wave
The wavelengths for hsiao template.
- Type:
numpy.ndarray
- _hsiao_flux
The baseline mean intrinsic SED provided by hsiao template.
- Type:
numpy.ndarray
- Parameters:
theta (parameter) – The bayeSN theta parameter.
Av (parameter) – The bayeSN Av parameter. Set of host extinction values for each SN.
Rv (parameter) – The bayeSN Rv parameter. Rv value for host extinction.
Amplitude (parameter) – The distance modulus (m - M) Normalized to have a absolute magnitude of -19.5
_M20_model_path (str) – The path for the M20 model file directory from the bayesian model Default: “bayesn-model-files/BAYESN.M20”
W0_filename (str) – The file name of the W0 matrix. Default: “W0.txt”
W1_filename (str) – The file name of the W1 matrix. Default: “W1.txt”
l_knots_filename – The file name of the knot values of wavelegnths for interpolation Default: “l_knots.txt”
tau_knots_filename (str) – The file name of the knot values of times for interpolation Default: “tau_knots.txt”
hsiao_path_or_url (str) – The path for the hsiao model template file directory. Default: “bayesn-model-files/hsiao.h5”
**kwargs (dict, optional) – Any additional keyword arguments.
- minphase(**kwargs)[source]
Get the minimum supported rest-frame 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 minimum supported rest-frame 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
- compute_invkd(x)[source]
Compute the operator matrix K^{-1}D to get second derivatives for natural cubic spline.
- Parameters:
x ((n,) array_like) – Knot positions (non-uniform, strictly increasing).
- Returns:
invKD – Matrix such that M = invKD @ y gives second derivatives of y.
- Return type:
(n, n) ndarray
- natural_cubic_spline_basis_matrix_from_invkd(x, xq_array, invKD)[source]
Compute basis matrix J for multiple query points using precomputed second derivative matrix.
- Parameters:
x ((n,) array_like) – Knot positions.
xq_array ((m,) array_like) – Query points.
invKD ((n, n) array_like) – Precomputed matrix such that second_derivatives = invKD @ y.
- Returns:
J – Basis matrix. Each row J[i, :] is the spline basis vector for xq_array[i].
- Return type:
(m, n) ndarray
- compute_second_derivatives_1d(x, y)[source]
Compute natural cubic spline second derivatives (M) for 1D input.
- Parameters:
x ((n,) array_like) – Knot positions.
y ((n,) array_like) – Values at knots.
- Returns:
M – Second derivatives at knots.
- Return type:
(n,) ndarray
- compute_2d_second_derivatives(x, y, z)[source]
Compute second derivatives in both x and y directions for 2D natural cubic spline.
- Parameters:
x ((n,) array_like) – Knot positions in x.
y ((m,) array_like) – Knot positions in y.
z ((n, m) array_like) – Function values on 2D grid.
- Returns:
Mx ((n, m) ndarray) – Second derivatives with respect to x.
My ((n, m) ndarray) – Second derivatives with respect to y.
- evaluate_natural_spline_2d_vectorized(x, y, z, Mx, My, xq, yq)[source]
Vectorized 2D natural cubic spline evaluation using second derivatives.
- Parameters:
x ((n,) array_like) – Knot positions in x.
y ((m,) array_like) – Knot positions in y.
z ((n, m) array_like) – Function values on 2D grid.
Mx ((n, m) array_like) – Second derivatives w.r.t. x.
My ((n, m) array_like) – Second derivatives w.r.t. y.
xq ((p,) array_like) – Query positions in x.
yq ((q,) array_like) – Query positions in y.
- Returns:
Zq – Interpolated 2D surface values.
- Return type:
(p, q) ndarray
- evaluate_2d_cubic_spline(x, y, z, xq, yq)[source]
Evaluate 2D natural cubic spline at given query points with auto second derivative computation.
- Parameters:
x ((n,) array_like) – Knot positions in x direction.
y ((m,) array_like) – Knot positions in y direction.
z ((n, m) array_like) – Function values at grid points.
xq ((p,) array_like) – Query points in x.
yq ((q,) array_like) – Query points in y.
- Returns:
Zq – Interpolated values at query grid.
- Return type:
(p, q) ndarray
- compute_sed(times, wavelengths, graph_state, **kwargs)[source]
Draw effect-free observations for this object.
- Parameters:
times (numpy.ndarray) – A length T array of rest frame timestamps in MJD.
wavelengths (numpy.ndarray, optional) – A length N array of rest frame 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