lightcurvelynx.models.sed_template_model

Model that generate the SED or bandflux of a source based on given predefined observer frame SED curves at given wavelengths.

Note: If you are interested in generating light curves from band-level curves, use the LightcurveTemplateModel in src/lightcurvelynx/models/lightcurve_template_model.py instead.

Attributes

logger

Classes

SEDTemplate

A class to hold a grid of SED data over time and wavelength, and provide

SEDTemplateModel

A model that generates either the SED or bandflux of a source based on

MultiSEDTemplateModel

A MultiSEDTemplateModel randomly selects a SED template at each evaluation

SIMSEDModel

Generate fluxes from SIMSED-formated data.

Module Contents

logger[source]
class SEDTemplate(grid_data, *, sed_data_t0=0.0, interpolation_type='linear', periodic=False, baseline=None, **kwargs)[source]

A class to hold a grid of SED data over time and wavelength, and provide interpolation capabilities. The quantities can use whichever units are desired.

wavelengths

A length W array of the wavelengths for the SED.

Type:

np.ndarray

times[source]

A length T array of the times for the SED relative to the reference epoch.

Type:

np.ndarray

interp[source]

The type of interpolation to use. One of ‘linear’ or ‘spline’.

Type:

scipy.interpolate object

period

The period of this data, if it is periodic. Default is None.

Type:

float or None

Parameters:
  • grid_data (np.ndarray) – A 2D array of shape (N x 3) containing phases, wavelengths, and fluxes.

  • sed_data_t0 (float, optional) – The reference epoch of the input SED template. This is the time stamp of the input array that will correspond to t0 in the model. Default is 0.0.

  • interpolation_type (str, optional) – The type of interpolation to use. One of ‘linear’ or ‘cubic’. Default is ‘linear’.

  • periodic (bool, optional) – Whether the SED template is periodic. Default is False.

  • baseline (np.ndarray or None, optional) – A length W array of baseline SED values for each wavelength. This is only used for non-periodic SED templates when they are not active. Default is None.

  • **kwargs (dict) – Additional keyword arguments that are ignored.

times[source]
baseline = None[source]
interp[source]
property is_periodic[source]

Whether this SED template is periodic.

classmethod from_file(file_path, **kwargs)[source]

Create a SEDTemplate from a file containing three-column data.

Parameters:
  • file_path (str or Path) – The path to the file containing the SED data.

  • **kwargs (dict) – Additional keyword arguments to pass to the SEDTemplate constructor.

Returns:

The created SEDTemplate instance.

Return type:

SEDTemplate

classmethod from_components(times, wavelengths, sed_values, **kwargs)[source]

Create a SEDTemplate from separate time, wavelength, and SED value arrays. This is a convenience method that packs the data into (and then later unpacks the data from) the required three-column format.

Parameters:
  • times (np.ndarray) – A length T array of times.

  • wavelengths (np.ndarray) – A length W array of wavelengths.

  • sed_values (np.ndarray) – A 2D array of shape (T x W) containing the SED values.

  • **kwargs (dict) – Additional keyword arguments to pass to the SEDTemplate constructor.

evaluate_sed(times, wavelengths)[source]

Evaluate the SED at the given times and wavelengths.

Parameters:
  • times (np.ndarray) – A length T array of times (in the given units) at which to evaluate the SED (relative to t0).

  • wavelengths (np.ndarray) – A length W array of wavelengths (in the given units) at which to evaluate the SED.

Returns:

sed_values – A (T x W) matrix of SED values (in the given units) at the given times and wavelengths.

Return type:

np.ndarray

class SEDTemplateModel(template, *, sed_data_t0=None, interpolation_type='linear', periodic=False, baseline=None, **kwargs)[source]

Bases: lightcurvelynx.models.physical_model.SEDModel

A model that generates either the SED or bandflux of a source based on SED values at given times and wavelengths.

SEDTemplateModel supports both periodic and non-periodic data. If the template is not periodic then the given values will be interpolated during the time range of the template. Values outside the time range (before and after) will be set to the baseline value for that wavelength (0.0 by default).

Parameterized values include:

  • dec - The object’s declination in degrees.

  • ra - The object’s right ascension in degrees.

  • t0 - The t0 of the zero phase (if applicable), date.

Note

If you are interested in generating light curves from band-level curves, use the LightcurveTemplateModel in src/lightcurvelynx/models/lightcurve_template_model.py instead.

template

The data for the SED, including the times and bandfluxes in each filter.

Type:

SEDTemplate

Parameters:
  • template (numpy.ndarray or SEDTemplate) –

    The SED template information can be passed as either:

    1. a SEDTemplate instance, or

    2. a numpy array of shape (T, 3) array where the first column is phase (in days), the second column is wavelength (in Angstroms), and the third column is the SED value (in nJy).

  • sed_data_t0 (float or None, optional) – The reference epoch of the input template. This is the time stamp of the input array that will correspond to t0 in the model. This is only required if the template is passed as a numpy array. Default is None.

  • interpolation_type (str, optional) – The type of interpolation to use. One of ‘linear’ or ‘cubic’. Default is ‘linear’.

  • periodic (bool, optional) – Whether the template is periodic. Default is False.

  • baseline (np.ndarray or None, optional) – A length W array of baseline SED values for each wavelength. This is only used for non-periodic templates when they are not active. Default is None.

classmethod from_file(file_path, **kwargs)[source]

Create a SEDTemplateModel from a file containing three-column data.

Parameters:
  • file_path (str or Path) – The path to the file containing the SED data.

  • **kwargs (dict) – Additional keyword arguments to pass to the SEDTemplateModel constructor.

Returns:

The created SEDTemplateModel instance.

Return type:

SEDTemplateModel

property times[source]

The times of the template data (in days).

property wavelengths[source]

The wavelengths of the template data (in Angstroms).

compute_sed(times, wavelengths, graph_state)[source]

Draw effect-free observer frame flux densities.

Parameters:
  • times (numpy.ndarray) – A length T array of observer frame timestamps in MJD.

  • wavelengths (numpy.ndarray, optional) – A length N array of observer frame wavelengths (in angstroms).

  • graph_state (GraphState) – An object mapping graph parameters to their values.

Returns:

flux_density – A length T x N matrix of observer frame SED values (in nJy).

Return type:

numpy.ndarray

class MultiSEDTemplateModel(templates, *, weights=None, **kwargs)[source]

Bases: lightcurvelynx.models.physical_model.SEDModel

A MultiSEDTemplateModel randomly selects a SED template at each evaluation computes the flux from that source at given times and wavelengths.

MultiSEDTemplateModel supports both periodic and non-periodic templates. See the SEDTemplate documentation for details on how each template is handled.

Parameterized values include:

  • dec - The object’s declination in degrees.

  • ra - The object’s right ascension in degrees.

  • t0 - The t0 of the zero phase (if applicable), date.

templates[source]

The data for the templates, such as the times and bandfluxes in each filter.

Type:

list of SEDTemplate

Parameters:
  • templates (list of SEDTemplate) – The data for the templates, such as the times and bandfluxes in each filter.

  • weights (numpy.ndarray, optional) – A length N array indicating the relative weight from which to select a template at random. If None, all templates will be weighted equally.

templates[source]
__len__()[source]

Get the number of SED templates.

compute_sed(times, wavelengths, graph_state)[source]

Draw effect-free observer frame flux densities.

Parameters:
  • times (numpy.ndarray) – A length T array of observer frame timestamps in MJD.

  • wavelengths (numpy.ndarray, optional) – A length N array of observer frame wavelengths (in angstroms).

  • graph_state (GraphState) – An object mapping graph parameters to their values.

Returns:

flux_density – A length T x N matrix of observer frame SED values (in nJy). These are generated from non-overlapping box-shaped SED basis functions for each filter and scaled by the light curve values.

Return type:

numpy.ndarray

class SIMSEDModel(templates, flux_scale=1.0, **kwargs)[source]

Bases: MultiSEDTemplateModel

Generate fluxes from SIMSED-formated data.

Parameterized values include:

  • dec - The object’s declination in degrees.

  • distance - The object’s luminosity distance in pc.

  • ra - The object’s right ascension in degrees.

  • t0 - The t0 of the zero phase (if applicable), date.

templates[source]

The data for the templates, such as the times and bandfluxes in each filter.

Type:

list of SEDTemplate

flux_scale[source]

A scale factor to apply to all fluxes read from the SIMSED data files.

Type:

float

flux_scale = 1.0[source]
classmethod from_dir(simsed_dir, **kwargs)[source]

Read SNANA-formatted data from a directory and create a SIMSEDModel.

Parameters:
  • simsed_dir (str or Path) – The directory containing the SIMSED-formatted data files.

  • **kwargs (dict) – Additional keyword arguments to pass to the SIMSEDModel constructor.

Returns:

The created SIMSEDModel instance.

Return type:

SIMSEDModel

compute_sed(times, wavelengths, graph_state)[source]

Draw effect-free observer frame flux densities.

Parameters:
  • times (numpy.ndarray) – A length T array of observer frame timestamps in MJD.

  • wavelengths (numpy.ndarray, optional) – A length N array of observer frame wavelengths (in angstroms).

  • graph_state (GraphState) – An object mapping graph parameters to their values.

Returns:

flux_density – A length T x N matrix of observer frame SED values (in nJy).

Return type:

numpy.ndarray