target.timeserie#

This module defines TSTransient and MultiTemplateTSTransient classes, enabling simulation of transients from any sncosmo time-series source, including multi-template populations.

class skysurvey.target.timeserie.TSTransient(template=None, magabs=None, *args, **kwargs)[source]#

Bases: Transient

TimeSerie Transient.

This model will generate a Transient object from any TimeSerieSource model from sncosmo. [see list](https://sncosmo.readthedocs.io/en/stable/source-list.html)

Parameters:
  • template (str, sncosmo.Source, sncosmo.Model, skysurvey.Template) –

    the sncosmo TimeSeriesSource, you can provide:

    • str: the name, e.g. “v19-2013ge-corr”

    • sncosmo.Source: a loaded sncosmo.Source

    • sncosmo.Model: a loaded sncosmo.Model

      this is eventually converted into a generic skysurvey.Template.

    Default is None.

  • magabs (list) –

    define the absolute magnitude parameters. Could be 2 or 3 values:

    • len(magabs)==2 => drawn from normal distribution:

      loc, scale = magabs

    • len(magabs)==3 => drawn from asymetric normal distribution:

      loc, scale_low, scale_high = magabs

      Default is None.

  • _RATE (float, optional) – The rate of the TimeSerie Transient. The default is 0.001.

  • _MAGABS (float, optional) – The absolute magnitude. The default is None.

  • _MODEL (dict, optional) –

    The model to use. The default is a dictionary with the following keys:

    • redshift: The redshift of the TimeSerie Transient.

    • t0: The time of maximum of the TimeSerie Transient.

    • magabs: The absolute magnitude of the TimeSerie Transient.

    • magobs: The observed magnitude of the TimeSerie Transient.

    • radec: The ra and dec of the TimeSerie Transient.

Examples

>>> snii = TSTransient.from_draw("snana-2004fe", 4000)
>>> _ = snii.show_lightcurve(["ztfg","ztfr"], index=10, in_mag=True)
classmethod from_sncosmo(template, rate=None, model=None, magabs=None, **kwargs)[source]#

Loads an instance from a sncosmo TimeSeriesSource source. (see https://sncosmo.readthedocs.io/en/stable/source-list.html#list-of-built-in-sources)

Parameters:
  • template (str, sncosmo.Source, sncosmo.Model, skysurvey.Template) –

    the sncosmo TimeSeriesSource, you can provide:

    • str: the name, e.g. “v19-2013ge-corr”

    • sncosmo.Source: a loaded sncosmo.Source

    • sncosmo.Model: a loaded sncosmo.Model

    This is eventually converted into a generic skysurvey.Template.

  • rate (float, func) – the transient rate, can be either: - float: assumed volumetric rate - func: function of redshift rate(z)

  • model (dict) – provide the model graph structure on how transient parameters are drawn.

  • magabs (list) –

    define the absolute magnitude parameters. Could be 2 or 3 values:

    • len(magabs)==2 => drawn from normal distribution:

      loc, scale = magabs

    • len(magabs)==3 => drawn from asymetric normal distribution:

      loc, scale_low, scale_high = magabs

Returns:

loaded instance.

Return type:

instance

See also

from_draw: load an instance and draw the transient parameters

set_magabs(magabs)[source]#

Update the model for the loc and scale of the absolute magnitude distribution.

Parameters:

magabs (list) –

define the absolute magnitude parameters. Could be 2 or 3 values:

  • len(magabs)==2 => drawn from normal distribution:

    loc, scale = magabs

  • len(magabs)==3 => drawn from asymetric normal distribution:

    loc, scale_low, scale_high = magabs

class skysurvey.target.timeserie.MultiTemplateTSTransient(template=None, magabs=None, *args, **kwargs)[source]#

Bases: TSTransient

A class to model time-series transient drawn from multiple templates simultaneously.

Parameters:
  • template (str, sncosmo.Source, sncosmo.Model, skysurvey.Template) –

    the sncosmo TimeSeriesSource, you can provide:

    • str: the name, e.g. “v19-2013ge-corr”

    • sncosmo.Source: a loaded sncosmo.Source

    • sncosmo.Model: a loaded sncosmo.Model

      this is eventually converted into a generic skysurvey.Template.

    Default is None.

  • magabs (list) –

    define the absolute magnitude parameters. Could be 2 or 3 values:

    • len(magabs)==2 => drawn from normal distribution:

      loc, scale = magabs

    • len(magabs)==3 => drawn from asymetric normal distribution:

      loc, scale_low, scale_high = magabs

      Default is None.

as_targets()[source]#

Convert the collection in a list of same-template targets.

set_template(template, force_uniquetype=True)[source]#

Set a collection of templates.

Parameters:
  • template (str, list of str, or list of sncosmo sources) – One or more sncosmo TimeSeriesSource templates.

  • force_uniquetype (bool, optional) – If True, raise an error if templates are of different types. Default is True.

set_rate(rate)[source]#

Set the transient rate.

Parameters:

rate (float, func or list of) – func: a function that takes as input an array or redshift “z” float: number of targets per Gpc3. could be a list.

draw_redshift(zmax, zmin=0, zstep=0.0001, size=None, rate=None, **kwargs)[source]#

Draw redshifts based on the rate (see get_rate()).

Parameters:
  • zmax (float) – Maximum redshift.

  • zmin (float, optional) – Minimum redshift. Default is 0.

  • zstep (float, optional) – Redshift step. Default is 1e-4.

  • size (int, optional) – Number of redshifts to draw. Default is None.

  • rate (float or callable, optional) – The transient rate. If None, self.rate is used. Default is None.

Returns:

The drawn redshifts.

Return type:

array

get_template(index=None, as_model=False, data=None, set_magabs=False, **kwargs)[source]#

Get a template (sncosmo.Model).

Parameters:
  • index (int, optional) – Index of a target (see self.data.index) to set the template parameters to that of the target. If None, the default sncosmo.Model parameters will be used. By default None.

  • as_model (bool, optional) – should this return the sncosmo.Model (True) or the skysurvey.Template (for info sncosmo.Model => skysurvey.Template.sncosmo_model)

  • data (pandas.DataFrame, None, optional) – which data should be used to set the parameter of the template. Ignored if index is None.

  • set_magabs (bool, optional) – should the peal magnitude of the template be set to magabs ?

  • **kwargs – Goes to self.template.get() and passed to sncosmo.Model.

Returns:

An instance of the template (or its associated sncosmo.Model). (see as_model)

Return type:

skysurvey.Template or sncosmo.Model

draw_template(size=None, redshift=None, rng=None)[source]#

Draw a template name for each transient, weighted by their rates.

If all templates share the same rate, templates are drawn uniformly. Otherwise, templates are drawn proportionally to their rates at the given redshifts.

Parameters:
  • size (int, optional) – Number of templates to draw. Overridden by len(redshift) if redshift is provided. Default is None.

  • redshift (array, optional) – Redshifts at which to evaluate the rates. Default is None.

  • rng (None, int, or (Bit)Generator, optional) – Seed for the random number generator. Default is None.

Returns:

Template names, one per transient.

Return type:

array

property model#

The model of the transient

property has_multirates#

Whether templates have different rates from one another.