Classification of Peculiar Supernovae

With the discovery of the accelerating expansion of the universe, type Ia supernovae (SNe Ia) have been used increasingly to determine cosmological parameters. The use of SNe Ia as cosmological probes relies on the fact that SN Ia luminosities at the time of maximum are not only bright but also have low intrinsic scatter. However, SNe are in-fact a highly heterogeneous collection of objects spanning a diverse collection of subtypes.

One approach to this challenge is to identify SNe subtypes based on their light-curve properties. In Gonzalez-Gaitan et al. 2014 (G14) a photometric identification technique was introduced for discriminating SN 1991bg-like objects in photometric samples. Using several low-redshift samples from the literature, it was demonstrated that this method is not only capable of identifying dim, fast-declining SNe, but can also identify other peculiar transients such as SNe Iax-like, SN 2006bt-like, and super-Chandrasekhar SNe Ia.

In Perrefort et al. 2020 we apply a modified version of the same classification technique to the SDSS Supernova Survey. This documentation is provided as a technical reference for the published work, and serves as a complete project writeup for all programmatic aspects of the project. The Project Notes section documents the project from a scientific perspective. It it provided to ensure reproducibility of the results and to clarify various design decisions. The API Reference documents how to use the project’s code base along with various technical clarifications.

Source Code and Repository Structure

Source code for this project can be found online via GitHub. We provide summaries below for key files in the project repository:

project parent
├── config_files/
├── docs/
├── notebooks/
├── phot_class/
├── results/
├── tests/
│
├── README.md
├── environment.yml
├── run_pipeline.py
├── run_pipeline.sh
├── run_salt2.py
└── setup.py
File Description
config_files/ Files specifying fitting arguments and priors for different models/surveys.
docs/ The project documentation’s source code (what you’re reading right now).
notebooks/ Notebooks that inspect results of the classification pipeline. These contain mostly plotting code.
phot_class/ The python package containing all of the logic for fitting and classifying light curves.
results/ Classification results returned from the phot_class package. This directory can be re-generated by running run_pipeline.sh
tests/ Tests for the phot_class package.
README.md Github Landing document pointing readers to the online documentation.
environment.yml Installation requirements for phot_class.
run_pipeline.py A command line interface for running the phot_class package.
run_pipeline.sh Runs the command line interface for various combinations of arguments
run_salt2.py Runs salt2 fits for each SDSS target.
setup.py Installation script for the phot_class package.

Classification Scheme (Background)

We here discuss the photometric classification technique presented in González-Gaitán et al. 2014 (G14) that this project is based on.

Important

G14 relies on the SiFTO light-curve fitter. We here instead apply the sncosmo package. In their default setup, these two packages are very different, but we intentionally implement sncosmo in a way that mimics the SiFTO approach. See the Implementation section for more details.

Background

Despite being surprisingly homogeneous, type Ia Supernovae (SNe Ia) are in fact a heterogeneous collection of events who’s variety is well parameterized by empirical descriptions such as stretch and color. Although prevalent theories attribute supernova explosions as being the thermonuclear runaway of an exploding CO white dwarf, modeling efforts have seen little progress in providing a definitive explanation. The goal of classification is to provide a framework from which we can further build and explore theoretical explanations.

Sub-types of Type Ia SNe include:

  • SN 1991T-like (Filippenko+ 1992a; Phillips+ 1992; Maza+ 1994)
  • SN 1991bg-like (Filippenko+ 1992b; Leibundgut+ 1993; Hamuy+ 1994)
  • 2002cx-like SNe or “SNe Iax” (e.g. Li+ 2003; Foley+ 2013)
  • super-Chandrasekhar mass candidates (e.g. Howell+ 2006; Scalzo+ 2012)
  • SN 2000cx-like (Li+ 2001; Candia+ 2003; Silverman+ 2013a)
  • SN 2006bt-like (Foley+ 2010b)
  • SNe Ia with possible circumstellar material (CSM) interactions (Hamuy 2003; Dilday+ 2012; Silverman+ 2013b)
  • Ca-rich SNe (Perets+ 2010, 2011b; Valenti+ 2013a; Kasliwal+ 2012)

Note

See Gal-Yam 2017 for a comprehensive discussion.

We are primarily focused on the identification of SN 1991-bg like objects (91bgs). These tend to be around 1.1 mag fainter and decline notably faster than normal Ia’s. Their redder colors and more prevalent Ti lines also indicate that they are cooler. Since 91bgs are cooler, the recombination of Fe III to Fe II also occurs sooner causing the peak brightness in the redder bands to happen sooner than in the bluer bands.

González-Gaitán et al. 2014 (G14) puts forth a classification technique by which 91bg and a few other peculiar SNe can be identified (described below). This approach is compared against existing approaches (SNID and GELATO2) and found to be in good agreement.

The Original Data Set

G14 focuses on low-redshift SN samples (z < 0.1). In addition to a few targets picked from the literature, the data is primarily taken from:

  • The Caĺan/Tololo survey (Hamuy et al. 1996a)
  • The Carnegie Supernova Project (CSP)
  • The Center for Astrophysics (CfA) (Hicken et al. 2009, 2012)
  • The Lick Observatory Supernova Search (Ganeshalingam et al. 2010)

No initial cuts are applied to the data.

The General Approach

91bg’s can be photometrically distinguished from normal Ia’s by the morphology of their light-curve - particularly in then redder bands (as described above). To identify 91bg like objects, the photometry for each target is first split into the red and blue bands as separated by 5500 angstroms in the rest frame. Both data sets are then fit using two light-curve models: one representing normal Ia’s and one representing 91bg’s. Using the resulting chi-squared values, targets are classified based on their position in the following phase space:

\[x \def \chi^2_{blue}(Ia) - \chi^2_{blue}(91bg) y \def \chi^2_{red}(Ia) - \chi^2_{red}(91bg)\]

By construction of the above coordinates, we expect 91bg’s to fall in the upper right (first) quadrant while type Ia’s should fall in the lower left (third) quadrant.

In principle there is no physical reason why the quadrants should be separated by intersecting lines at \((0, 0)\). To determine where in this phase space we should draw the boundaries separating each classification, we use whatever boundaries are found to maximize the figure of merit (FOM) which is given by:

\[FOM = \frac{N_{true}}{N_{total}} \times \frac{N_{true}}{N_{true} + N_{false}}\]

Where each term is defined as the following:

  • \(N_{total}\) is the total number of objects with a given type (i.e. the “truth”)
  • \(N_{true}\) is the number object correctly classified as a given type
  • \(N_{false}\) is the number of objects falsely classified a given type

Here “a given type” refers to 91bg-like.

The added work of fitting red and blue bands independently could be avoided and a chi-squared for all bands could be used. Although this works, it does not work as well since there may be some normal SNe with lower stretch or redder colors. It is also possible to use a simple cut on the fitted color and/or stretch values (using either the normal or 91bg template). However, this suffers from a similar problem where highly reddened, normal Ia’s at low stretch would look like Ia’s.

Some Additional Details

  • The normal Ia template used in G14 is the Hsiao+ 2007 template
  • The 91bg template is the Nugent+ 2002 template
  • Data cuts were implemented as follows:
    1. Exclude targets without observations in at least two filters, each with at least one data point between -15 and 0 days and one between 0 and 25 days.
    2. Data past 85 days was ignored
    3. If observations are available in duplicate filters (e.g. the same filter from different surveys) the filter with the most data points is used.

Implementation

We here discuss various implementation details related to how we fit and classify light-curves. This includes the tools we use and how they are applied.

Light-Curve Fitters

Light-curve fitters are an extremely common tool used in supernova analyses, particularly in cosmological studies. Perhaps not surprisingly, there exist a multitude of available fitting routines each with its own unique goals, approaches, and implementations. It is important to distinguish between the different options offered by each light curve fitter.

The photometric classification scheme that our project is based on was originally implemented with SiFTO. We have chosen to instead work with SNCosmo so that we can use a different set of models. We here outline the approach of both fitters and how they work.

SiFTO (Conley et al. 2008)

Important

SiFTO is not used at any stage of our analysis. We consider it here because understanding it is necessary for completeness.

SiFTO is an empirical light-curve fitter that is similar to SALT2 in the sense that it uses magnitude, light curve shape (i.e. stretch), and color to fit supernovae. However, it varies distinctly in approach from SALT2 by using band-specific stretch and color parameters as opposed to a set of global, light-curve specific parameters.

Stretch: The shape of the SiFTO model is described by a single stretch parameter measured in the rest-frame B-band. However, the model applies this stretch value differently in each observed filter. The functional form of this application depends both on the B-band stretch value and the effective wavelength of the bandpass.

Color: SiFTO does not incorporate a dedicated color term, but instead allows the scale factor of the template to vary independently for each band. The resulting colors can be combined to form a single color parameter afterwords, however, this calculation is performed when using fit results to estimate distance and not as part of the fit itself.

When trained on the same data sets, the results of SiFTO are consistent with SALT2, although the scatter in the SiFTO results is lower. Perhaps not surprisingly, when the band-specific SiFTO parameters are generalized to a single “stretch” and “color” value, there is a strong correlation between the two model parameters. This correlation is roughly linear for stretch, but is better described by a third-order polynomial for color.

We note the following warning from Conley+ 2008:

Warning

“SiFTO is designed for use with modern, well-measured SN data sets, and is not suited for the analysis of poorly sampled light curves. Specifically, if the number of observations in a filter in the range -20 to 40 rest-frame days relative to B maximum is less than about 3, then the fit in that filter may not be reliable. This proviso only applies to historical SN Ia samples – even at the highest redshifts, current observations are of high enough quality that this is not a problem. Our approach is not well suited to the rest-frame near-IR (I or redder), where a stretch-like prescription does not work well.”

SNCosmo (sncosmo.readthedocs.io)

sncosmo is a Python package built for supernova cosmology. At it’s core, the package is designed so users can customize their analysis with purpose built models, filters, minimization routines, etc.. There are a number of built in minimization routines that can be used to fit light-curves. However, all of the built in routines are designed to simultaneously fit multiple band-passes - a very different approach to SiFTO.

There is no single set of parameters used by sncosmo. Generally, the parameters are determined by the model that is being fit. Additional parameters can also be added to any model to represent external effects like extinction. These effects can be implemented at either the rest or observed frame.

Models

We consider multiple light curve models in our analysis, including SALT2, a modified version of the Hsiao model, and a custom 91bg model.

SALT2 (Guy et al. 2007)

SALT2 is intended to fit light curves while accounting for intrinsic variations in the supernova population. The original SALT model used the spectral sequence of Nugent et al. 2002 in conjunction with the parameters phase, wavelength, and stretch. SALT2 takes a similar approach but with several improvements, among which include the use of spectroscopic data in the training sample. In addition to improving the model’s resolution, this allows k-corrections to be handled in a consistent way for both photometric and spectroscopic observations.

The SALT2 model is similar to a principal component decomposition times an overall color law \(CL(\lambda)\).

\[F = x_0 \times [M_0(\text{phase}, \lambda) + x_1 \times M_1(\text{phase}, \lambda) + \dots] \times e^{c \times CL(\lambda)}\]

Here \(x_i\) are the components of the model, \(c\) is a color term, \(M_0\) represents the average spectral template, and the remaining \(M_i\) describe the variability of the supernova population. At the time it’s inception, the data available did not have a sufficiently high sampling to perform a full principle component analysis. Furthermore, it was determined during the training of the model that the terms for \(i>1\) could not be well constrained.

A total of 176 supernovae were used in the SALT2 training set, Eeach having at least two light-curves in different filters. The initial training value for \(M_0\) was chosen to be the original SALT model with a stretch of 1. \(M_1\) was chosen as the difference between \(M_0\) and SALT with a stretch of 1.1.

Guy et al. 2007 outlines three potential use cases for SALT2 or its potential successors:

  1. The classification of type Ia supernovae via a chi-squared cutoff
  2. The photometric estimation of redshifts
  3. Inspection of the intrinsic variability of supernovae by improving the data set to allow more terms in the principle component analysis. In doing so one could look for correlations between supernova properties and parameter values.
Custom Hsiao-like Model (Hsiao et al. 2007)

The Hsiao model has a similar light-curve profile to that of SALT2, but has several major differences. First, the model is trained on a more diverse set of SNe than the SALT2 model. This makes it a better representation of spectroscopically normal SNe Ia since it includes more of that subtype’s intrinsic diversity. It also covers a much broader phase and wavelength range, allowing us to fit using a larger subset of the measured photometry.

The Hsiao model built in to sncosmo also only has three parameters: z, t0, and amplitude. We add an additional “stretch” parameter called x1 for convenience. This parameter is used to stretch the light-curve phase as

\[\text{stretched phase} = \frac{\text{phase}}{1 - x1}\]

We intrinsically bound \(-.5 \leq x1 \leq .5\) within the model.

Custom sn1991bg-like Model (Nugent et al. 2002)

The 91bg model used for this project is based on the 91bg template from Nugent et al. 2002 but is extended into the ultra-violet. This model was originally formatted for use with the FORTRAN package SNANA. Care was taken to ensure the model was ported correctly into Python and that the predicted fluxes, parameter covariances, etc. are the same.

The model works by interpolating from a grid of SED templates covering 7 stretch and 5 color values. The ranges and relations of color and stretch were obtained by using SiFTO to fit the template to multiple 91bg light-curves at low-z.

The full phase range of the 91bg template extends from -18 to 100 days. When comparing this model against other models (e.g. via a chi-squared value) it is sometimes beneficial to limit the phase range of our model to more closely resemble what it is being compared to. For this reason the model has been specifically programmed so that the template can be arbitrarily limited in phase space at instantiation.

Fitting and Classification

We implement and compare two approaches to fitting and classifying light-curves. In one approach we fit each bandpass independently to mimic the behavior of SiFTO. In the second approach, we fit blue and red observations sep[eratly but as collective sets.

Method 1: Band-by-Band Fitting
  1. The Milky Way extinction is determined for each target using the Schlegel, Finkbeiner & Davis (1998) dust map and the Fitzpatrik 99 extinction law. This value is never varied in any fit, and is fixed to the given value. We can also optionally set the extinction to zero.
  2. Each light curve is fit using both models and all available band passes. At this step t0, amplitude, x1, and c are always varied. z is only varied if it is not specified by a prior (i.e. if it is not available from a from the data release - photometrically or spectroscopically). Results from this fit are used to determine the characteristic parameters for the given light-curve (The values one might publish in a summary table).
  3. Each bandpass is fit independently using both models. Here, z and t0 are fixed to the value determined when fitting all bands simultaneously.
  4. Any fits that fail are dropped from our sample.
  5. The band-passes are separated into the rest-frame blue and red (blue/redward of 5500 Angstroms.)
  6. The chi-squared values from the band-by-band fits are summed for each model in both the red and blue bandpasses. These values are used to determine the position of each target on the classification plot (see the Classification Scheme (Background) section).
Method 2: Collective Fitting

0-1. The first two steps in this approach are the same as the first method.

  1. Using the redshift determined in step 1, the observations are broken up into two sets. Observations in a bandpass with a rest frame effective wavelength less than 5500 Angstroms are called “blue”. Remaining observations are called “red”.
  2. The blue and red observations are fit independently of one another. As in the previous method, both z and t0 are fixed to the value determined in step 1.
  3. The chi-squared value from the blue and red fits are used to determine the position of each target on the classification plot

Data

We primarily consider observations from the Sloan Digital Sky Survey (SDSS) Supernova Survey. However, during our investigations we also occasionally considered data from the Dark Energy Survey (DES) Year 3 Cosmology release (SN3YR), and the third data release of the Carnegie Supernova Project (CSP DR3). We note that just because a data set is considered here or elsewhere in our preliminary exploration, it is not guaranteed to be used in the published work.

We rely on the sndata python package for programmatic access to each of these data sets. In principle, the pipeline we have built should extend trivially to any data set ported into sndata. Some notes are included below for each data set. These are included for use by developers, and should not be considered a formal reference.

Note

For more information on sndata see the official documentation

The SDSS-II SN Survey Data (Sako et al. 2018)

The SDSS-II SN Survey was implemented as an extension to the original SDSS and comprised of three, three-month campaigns in Fall 2005, 2006, and 2007. The data release contains 10,258 total sources: 1,988 objects classified as SN Ia, 2,049 SN II, 3 SLSN, 78 objects classified as either SN Ib or Ic, and 4,131 sources that are either variable or AGNs. Additionally, there are 2,009 targets with light curves that were deemed too sparse or noisy to provide a classification.

Out of the total target list, dedicated spectroscopic observations are only available for 626 SN, resulting in 499 SN Ia (about 43%) being spectroscopically confirmed. All objects were observed in two or more filters and visually inspected to ensure they were not artifacts. SNe in the sample were found to span a redshift range of 0.05 < z < 0.4 (Frieman et al. 2008).

Each target in the sample is assigned one of the following classifications:
  • Unknown: The light curve was too sparse and/or noisy to make a useful classification.
  • Variable: The source was observed in more than one observing season (and hence is not a supernova).
  • AGN: An optical spectrum was identified as having features associated with an active galaxy.
  • SNII, SNIbc (either Ib or Ic), SNIa: - SN classifications without prefixes are based on a spectrum (including a few non-SDSS spectra) - A prefix “p” indicates the redshift is unknown and that the identification was made with photometric data only - A prefix “z” indicates that a redshift is measured from its candidate host galaxy and the classification uses that redshift as a prior.
  • SN Ia?: classification is based on a spectrum that suggests a SN Ia but is inconclusive.

Some SN candidates have associated notes indicating targets that may have peculiar features or candidates where the classification was obtained by other groups. Although the survey did not perform a systematic search for peculiar features, likely peculiar features were noted if found.

The photometric flags are given in Table 4 and are as follows:
  • 1 - SN typing based on spectra obtained by groups outside SDSS. The spectra used for typing are not included in the data release.
  • 2 - Peculiar type Ia SN possibly similar to sn91bg
  • 3 - Peculiar type Ia SN possibly similar to sn00cx
  • 4 - Peculiar type Ia SN possibly similar to sn02ci
  • 5 - Peculiar type Ia SN possibly similar to sn02cx

Light curve fits are performed using PSNID, SALT2, and MLCS2k2. Published fits use the SALT2 model as implemented in SNANA version 10.31b and the spectral templates and color law reported in Guy et al. (2010, G10). Fits were performed using the Doi et al. 2010 SDSS filter response curves. These are available online [here](http://www.ioa.s.u-tokyo.ac.jp/~doi/sdss/SDSSresponse.html). The following cuts were applied to the photometric data.

  • Only data with a photometric flag less than 1024 is used for the fit. A full overview of the flag values is provided in Holtzman et al. 2008.
  • Epochs earlier than 15 days or later than 45 days in the rest frame are ignored. 152 epochs in 105 SN were also ignored after being visually classified as outliers.

Important

SDSS measures magnitudes using the inverse hyperbolic sine magnitude system. These differ from the standard AB system by an additive constant found in Table 7. The fluxes in the online files have already been converted to the AB system and are given in Micro-Janskies.

Installation

This project uses the phot_class package which is a custom analysis pipeline that is not available via a package manager. Source code can be downloaded to your local machine from GitHub or by using git:

git clone https://github.com/mwvgroup/Photometric-Classification

To ensure reproducibility and reduce the potential for programmatic errors, it is recommended to work within a conda environment. The necessary installation dependencies for creating this environment have been specified in a configuration file for convenience:

conda env create --name phot_class --file Photometric-Classification/environment.yml

The phot_class can then be installed as follows:

# Activate the conda environment
conda activate phot_class

python Photometric-Classification/setup.py install --user

# Optionally, you can then deactivate the conda environment when finished
conda deactivate

The Command Line Interface

The phot_class package can be accessed either from within a Python environment or via the command line using run_pipeline.py. We here outline how to use the command line interface. For working from within an environment, see the API documentation.

See run_pipeline.sh for a complete list of commands that were run as part of our analysis. In principle, all light curve fits considered by this project can be reproduced by running bash run_pipeline.sh.

Important

bash run_pipeline.sh includes a mix of commands that can vary dramatically in runtime and redundancy. You probably only want to run a subset of commands (if any since the results are cached in the project repository).

Creating a Config File

Note

Pre-made config files are available in the project’s repository.

Using the command line interface requires creating a configuration file. Config files are used to define priors and keyword arguments used when fitting each light-curve. Files should be saved in yaml format and follow the template below. Notice that priors and keyword arguments are specified for both the custom hsiao_x1 and sn91bg models defined in the project’s analysis pipeline.

Specifying Priors

Valid prior values for both models include z, t0, amplitude, x1, and mwebv. The sn91bg model also has an additional c parameter. It is important to understand how these parameters are handled by the pipeline:

  • When fitting all bands simultaneously, t0, amplitude, x1, and c are always varied. z is only varied if it is not specified by the prior.
  • When fitting bands independently, only amplitude, x1, and c are varied. z and t0 are fixed to the value determined when fitting all bands simultaneously.
  • mwebv is never varied in any fit, and is fixed to the given value. If no value is given, the default value is 0.

See the Fitting and Classification section for more information on how the pipeline handles light-curve fitting.

Specifying Kwargs

Valid keyword arguments depend slightly on the fitting function that is being used, but are overwhelmingly uniform across the available functions. Each fitting function is a simple wrapper around an sncosmo minimization routine (the wrapping is just to avoid an argument mutation bug in sncosmo). For more information on the available fitting routines, see phot_class.fit_func_wraps.

Running the Analysis

Arguments for the command line interface are as follows:

usage: run_pipeline.py [-h] -s SURVEY -r RELEASE [-f FIT_FUNC] [-m METHOD]
                       [-c CONFIG] -o OUT_DIR
Named Arguments
-s, --survey The name of the survey to analyze. This should be the name of a survey in the sndata package (e.g. csp).
-r, --release The name of the survey’s data release. This should also match the sndata package (e.g. dr3).
-f, --fit_func

The name of the fitting routine to use (simple_fit, nest_fit, mcmc_fit).

Default: “simple_fit”

-m, --method

Whether to fit bands independently (‘band’) or as red and blue sets (‘collective’)

Default: “band”

-c, --config Path of the yaml config file.
-o, --out_dir Directory to write output files to.

Notebooks

Although the phot_class package houses the core logic of our analysis, the visualization and interaction with results from the package is performed using Jupyter Notebooks. Notebooks also contain commentary on the analysis process, making them good a good place to build familiarity with the analysis pipeline. Descriptions of each notebook and what they discuss are provided below. Online interactive versions are provided for each notebook via BinderHub. To launch a BinderHub server click here.

Note

Please note that the BinderHub server might take a while to initialize and may require patience. Refreshing the page may help somewhat.

Notebook Description
classification.ipynb Applies photometric classifications to all supernovae.
classifying_single_target.ipynb Demonstrates the classification technique of Gonzalez-Gaitan+ 14 on a single supernova.
creating_config_files.ipynb Creates config files for CSP, DES, and SDSS.
Data Cuts Inspects SDSS targets and applys quality cuts on observed light-curves
fit_inspection.ipynb Inspects fit results for individual light curves.
fitting_method_comparison.ipynb Comparison of classification results when using band-by-band vs. collective fitting.
fom_optimization.ipynb Determines optimal classification boundaries by optimizing the FOM parameter.
iminuit_vs_emcee.ipynb A simple comparison of the fit_lc and mcmc_lc minimization routines.
inspecting_91bg_model.ipynb Demonstrates the properties of the 91bg model we use for classification.
salt2_fit_results.ipynb Minimal investigation of fit results from the Salt2 model.
sdss_redshift_distribution.ipynb Plots of redshift distributions for the SNe data set.
sncosmo_chisq_bug.ipynb Outlines a bug in the calculation of chi-squared in SNCosmo and demonstrates that our results do not suffer from this bug.
snid_classifications.ipynb Exploration of spectroscopic classifications for SDSS supernovae.

phot_class (Package Overview)

The phot_class package applies the photometric fitting technique from González-Gaitan et al. 2014 to identify peculiar Type Ia Supernovae (SNe Ia). It provides multiple light curve fitting routines, various utilities for parsing and manipulating data, and functions for tabulating fitting and classification results for an entire photometric survey. For usage examples, please see the individual documentation of each module.

Modules

Module Name Description
classification Tabulates light-curve fits for a given survey and determines the corresponding classification coordinates.
fit_func_wraps Provides wrapped versions of sncosmo minimization routines to address bugs.
fitting Runs a series of fits on individual light-curves and tabulates the results.
fom Calculates the Figure of Merit (FOM) parameter.
models Defines custom Source classes for modeling supernovae with sncosmo.
simulation Simulates light-curves using sncosmo.
spectra tabulates the properties of spectral features.
utils A collection of general utilities.

phot_class.models

The models module defines custom Source classes for modeling supernovae with sncosmo.

Available Model Versions

There are multiple versions of a SN 1991bg-like model included in this package. For information on how each version determines the flux for a given set of parameters, see the documentation for the given source class. A modified version of the Hsiao model is also available, which is the same as sncosmo’s built in hsiao model (version 3.0) but with an added stretch parameter.

Name Version Description
sn91bg ‘salt2_phase’ (Default) 1991bg model restricted to a phase similar to Salt 2.4 (extends from -18 to 50 days).
sn91bg ‘hsiao_phase’ 1991bg model restricted to a phase similar to Hsiao 3.0 (extends from -18 to 85 days).
sn91bg ‘full_phase’ 1991bg model extending over to full available phase range (-18 to 100 days).
hsiao_x1 ‘3.0.x1’ The same as sncosmo’s built in hsiao model (version 3.0) but with an added stretch parameter and limited to -18 to 85 days.

Usage Example

>>> import sncosmo
>>> from matplotlib import pyplot as plt
>>>
>>> from phot_class import models
>>>
>>> # Make sncosmo aware of the 1991bg models
>>> models.register_sources()
>>>
>>> # Initialize a model
>>> source = sncosmo.get_source('sn91bg', version='phase_limited')
>>> model = sncosmo.Model(source=source)
>>>
>>> # Get more information on how the source determines flux
>>> print(help(source))
>>>
>>> # run the fit
>>> data = sncosmo.load_example_data()
>>> result, fitted_model = sncosmo.fit_lc(
>>>     data, model,
>>>     ['z', 't0', 'x0'],  # parameters of model to vary
>>>     bounds={'z':(0.3, 0.7)})  # bounds on parameters (if any)
>>>
>>> # Plot results
>>> fig = sncosmo.plot_lc(data, model=fitted_model, errors=result.errors)
>>> plt.show()

Function Documentation

phot_class.models.register_sources(force=False)[source]

Register custom models with SNCosmo

See the documentation of the parent module for more information on the available models.

Parameters:force (bool) – Whether to overwrite an already registered source

phot_class.fit_func_wraps

The fit_funcs module provides wrappers that combine the the various minimization routines from sncosmo. Importantly, the fitting functions in this module guarantee that arguments will not be mutated, which is not true for sncosmo in general (at least for sncosmo 2.0.0 and earlier).

Usage Example

>>> import sncosmo
>>> from matplotlib import pyplot as plt
>>>
>>> from phot_class import fit_func_wraps
>>>
>>> model = sncosmo.Model('salt2')
>>> data = sncosmo.load_example_data()
>>>
>>> # Here you can use the functions simple_fit, nest_fit, or mcmc_fit
>>> result, fitted_model = fit_func_wraps.simple_fit(
>>>     data, model,
>>>     ['z', 't0', 'x0', 'x1', 'c'],  # parameters of model to vary
>>>     bounds={'z':(0.3, 0.7)})  # bounds on parameters (if any)
>>>
>>> # Plot results
>>> fig = sncosmo.plot_lc(data, model=fitted_model, errors=result.errors)
>>> plt.show()

Function Documentation

phot_class.fit_func_wraps.mcmc_fit(data, model, vparam_names, **kwargs)[source]

Fit light curves Monte Carlo sampling

Parameters:
  • data (Table) – Table of photometric data
  • model (Model) – The model to fit
  • vparam_names (iterable) – Model parameters to vary
  • other parameters for sncosmo.mcmc_lc (Any) –
Returns:

  • A dictionary like object with fit results
  • A fitted Model instance

phot_class.fit_func_wraps.nest_fit(data, model, vparam_names, **kwargs)[source]

Fit light curves using nested sampling

Parameters:
  • data (Table) – Table of photometric data
  • model (Model) – The model to fit
  • vparam_names (iterable) – Model parameters to vary
  • other parameters for sncosmo.nest_lc (Any) –
Returns:

  • A dictionary like object with fit results
  • A fitted Model instance

phot_class.fit_func_wraps.simple_fit(data, model, vparam_names, **kwargs)[source]

Fit light curves using the basic fit_lc functionality in sncosmo

Parameters:
  • data (Table) – Table of photometric data
  • model (Model) – The model to fit
  • vparam_names (iterable) – Model parameters to vary
  • other parameters for sncosmo.fit_lc (Any) –
Returns:

  • A dictionary like object with fit results
  • A fitted Model instance

phot_class.fitting

The fitting module runs a series of fits on individual light-curves and tabulates the results. This includes the ability to fit each bandpass independently (like in SiFTO) or to fit restframe blue/red band passes os separate, collective sets.

Function Documentation

phot_class.fitting.create_empty_table(parameters, **kwargs)[source]

Create an empty table for storing fit results

Columns:
  • obj_id
  • band
  • source
  • pre_max
  • post_max
  • num_params
  • *parameters
  • *parameters + _err
  • chisq
  • ndof
  • b_max
  • delta_15
  • message
Parameters:
  • parameters (iter) – List of parameter names to add columns for
  • arguments to pass astropy.Table (Any) –
Returns:

A masked astropy Table

phot_class.fitting.fit_results_to_dict(data, obj_id, band_set, results, fitted_model)[source]

Format sncosmo fit results so they can be appended to an astropy table

See the create_empty_table function for information on the assumed table format.

Parameters:
  • data (Table) – The data used in the fit
  • obj_id (str) – The id of the object that was fit
  • band_set (str) – The name of the band set (‘all’, ‘blue’, ‘red’)
  • results (Result) – Fitting results returned by sncosmo
  • fitted_model (Model) – A fitted sncosmo model
Returns:

Fit results as a dictionary

phot_class.fitting.run_band_fits(obj_id, data, fit_func, priors_hs=None, priors_bg=None, kwargs_hs=None, kwargs_bg=None, show_plots=False)[source]

Run light curve fits on a given target using the Hsiao and 91bg model

Fits are run using both the hsiao_x1 and sn91bg models for all available bands and then for each band individually.

Varied parameters include z, t0, amplitude, x1, and c. If the z is specified in the priors for both models, it is not varied in any fit. The parameters t0 and z are not varied in the individual band fits.

Parameters:
  • obj_id (str) – Id of the object being fitted
  • data (Table) – Table of photometric data
  • fit_func (func) – Function to use to run fits (eg. fit_funcs.fit_lc)
  • priors_hs (dict) – Priors to use when fitting hsiao
  • priors_bg (dict) – Priors to use when fitting sn91bg
  • kwargs_hs (dict) – Kwargs to pass fit_func when fitting salt2
  • kwargs_bg (dict) – Kwargs to pass fit_func when fitting sn91bg
  • show_plots (bool) – Plot and display each individual fit
Returns:

A table with results each model / dataset combination

phot_class.fitting.run_collective_fits(obj_id, data, fit_func, band_names, lambda_eff, priors_hs=None, priors_bg=None, kwargs_hs=None, kwargs_bg=None, show_plots=False)[source]

Run light curve fits on a given target using the Hsiao and 91bg model

Parameters:
  • obj_id (str) – Id of the object being fitted
  • data (Table) – Table of photometric data
  • fit_func (func) – Function to use to run fits (eg. fit_funcs.fit_lc)
  • band_names (list) – Name of bands included in data_iter
  • lambda_eff (list) – Effective wavelength for bands in band_names
  • priors_hs (dict) – Priors to use when fitting hsiao
  • priors_bg (dict) – Priors to use when fitting sn91bg
  • kwargs_hs (dict) – Kwargs to pass fit_func when fitting salt2
  • kwargs_bg (dict) – Kwargs to pass fit_func when fitting sn91bg
  • show_plots (bool) – Plot and display each individual fit
Returns:

A table with results each model / dataset combination

phot_class.classification

The classification module tabulates light-curve fits for a given survey and determines the corresponding classification coordinates:

\[x = \chi^2_{blue}(Ia) - \chi^2_{blue}(91bg)\]
\[y = \chi^2_{red}(Ia) - \chi^2_{red}(91bg)\]

Function Documentation

phot_class.classification.classify_targets(fits_table, band_names=None, lambda_eff=None, out_path=None)[source]

Tabulate fitting coordinates for SNe based on their fit results

See the create_empty_table function for the assumed input table format. If band_names or lambda_eff are not given, they are taken from fits_table.meta. Any targets having one or more fits with the string ‘failed’ in the message are skipped (case insensitive).

Parameters:
  • fits_table (Table) – A table of fit results
  • band_names (list) – List of band names used when fitting
  • lambda_eff (list) – The effective wavelength of each band in angstroms
  • out_path (str) – Optionally write results to file
Returns:

An astropy table of fitting coordinates

phot_class.classification.tabulate_fit_results(data_iter, band_names, lambda_eff, fit_func, fitting_method='band', config=None, out_path=None)[source]

Tabulate fit results for a collection of data tables

Results already written to out_path are skipped.

Parameters:
  • data_iter (iter) – Iterable of photometric data for different SN
  • band_names (list) – Name of bands included in data_iter
  • lambda_eff (list) – Effective wavelength for bands in band_names
  • fit_func (func) – Function to use to run fits
  • config (dict) – Specifies priors / kwargs for fitting each model
  • out_path (str) – Optionally cache results to file
Returns:

An astropy table with fit results

phot_class.fom

The fom module calculates the Figure of Merit (FOM) parameter defined as:

\[FOM = \frac{N_{true}}{N_{total}} \times \frac{N_{true}}{N_{true} + N_{false}}\]

where \(N_{true}\) is the number of objects correctly classified as a given type, \(N_{false}\) is the number of objects falsely classified as the given type, and \(N_{total}\) is the total number of objects with that type.

This module specifically focuses on classification techniques that classify targets based on their (x, y) position in some two dimensional phase space. Functions are provided for calculating the FOM according to multiple classification schemes:

Function Classification Scheme
rectangular Uses a pair of rectangular axes to classify targets in the upper right quadrant as a given type.
vertical Classifies targets with an x coordinate greater than some value as a given type.
horizontal Classifies targets with a y coordinate greater than some value as a given type.
linear Classifies targets above a linear boundary y = mx + b as a given type.
diagonal Classifies targets above a diagonal boundary y = x + b as a given type. Note the difference in slope between this option and the linear option.

Alternatively, the fom method can be used to calculate the FOM for a set of predetermined classifications, independent of the chosen classification technique (i.e. using the results of an already run classification).

Usage Example

>>> from phot_class.fom import fom
>>>
>>> # The true "spectroscopic" classification of an object
>>> truth = ['normal', 'normal', 'normal', '91bg', '91bg']
>>>
>>> # The result of some classification piepline
>>> classifications = ['normal', 'normal', '91bg', 'normal', '91bg']
>>>
>>> # Classify the FOM for the "91bg" type
>>> bg_fom = fom(truth, classifications, '91bg')
>>>
>>> # Classify the FOM for the "normal" type
>>> normal_fom = fom(truth, classifications, 'normal')

Function Documentation

phot_class.fom.diagonal(truth, x, y, b, check_type)[source]

Calculate the figure of merit using a diagonal lower bound: y = -x + b

Expected classifications are “normal” or “91bg” (case insensitive). All other classifications are ignored.

Parameters:
  • truth (ndarray) – Array of classifications to take as truth
  • x (ndarray) – The classification x coordinate
  • y (ndarray) – The classification y coordinate
  • b (float) – The y-intercept of the boundary
  • check_type (str) – The classification to calculate the FOM for
Returns:

The figure of merit value

phot_class.fom.fom(truth, classification, check_type)[source]

Calculate the figure of merit for a given set of classifications

Parameters:
  • truth (ndarray) – The true classifications
  • classification (ndarray) – The assigned classifications
  • check_type (str) – The classification to calculate the FOM for
Returns:

(n_true / n_total_type) * (n_true / (n_true + n_false))

phot_class.fom.horizontal(truth, x, x_cutoff, check_type)[source]

Calculate the figure of merit using a vertical lower boundary (i.e. using only the x coordinate)

Parameters:
  • truth (ndarray) – Array of classifications to take as truth
  • x (ndarray) – The classification x coordinate
  • x_cutoff (float) – The x boundary to use for separating 91bg / normal
  • check_type (str) – The classification to calculate the FOM for
Returns:

The figure of merit value

phot_class.fom.linear(truth, x, y, m, b, check_type)[source]

Calculate the figure of merit using a diagonal lower bound: y = mx + b

Parameters:
  • truth (ndarray) – Array of classifications to take as truth
  • x (ndarray) – The classification x coordinate
  • y (ndarray) – The classification y coordinate
  • m (float) – The slope of the boundary
  • b (float) – The y-intercept of the boundary
  • check_type (str) – The classification to calculate the FOM for
Returns:

The figure of merit value

phot_class.fom.rectangular(truth, x, y, x_cutoff, y_cutoff, check_type)[source]

Calculate the figure of merit using a pair of rectangular lower bounds

Parameters:
  • truth (ndarray) – Array of classifications (str) to take as truth
  • x (ndarray) – The classification x coordinate
  • y (ndarray) – The classification y coordinate
  • x_cutoff (float) – The x boundary to use for separating 91bg / normal
  • y_cutoff (float) – The y boundary to use for separating 91bg / normal
  • check_type (str) – The classification to calculate the FOM for
Returns:

The figure of merit value

phot_class.fom.vertical(truth, y, y_cutoff, check_type)[source]

Calculate the figure of merit using a horizontal lower boundary (i.e. using only the y coordinate)

Expected classifications are “normal” or “91bg” (case insensitive). All other classifications are ignored.

Parameters:
  • truth (ndarray) – Array of classifications to take as truth
  • y (ndarray) – The classification y coordinate
  • y_cutoff (float) – The y boundary to use for separating 91bg / normal
  • check_type (str) – The classification to calculate the FOM for
Returns:

The figure of merit value

phot_class.simulation

Generates light-curves using sncosmo and write models results to file.

Usage Example

>>> from phot_class import simulation
>>>
>>> # Average 91bg stretch and color determined using SIFTO
>>> print(simulation.avg_stretch)
>>> print(simulation.avg_color)
>>>
>>> # Stretch and color covariance determined using SIFTO
>>> print(simulation.covariance)
>>>
>>> # Return random array 5 stretch and color values for 91bg SNe
>>> stretch_array, color_array = bg_stretch_color(5)
>>>
>>> # Simulate parameters for 91bg SNe
>>> param_dicts = simulation.sim_bg_params(zmin=0, zmax=1, tmin=100, tmax=1000)
>>>
>>> # Generate light curves in SDSS band passes
>>> import sncosmo
>>> from phot_class import models
>>>
>>> models.register_sources()
>>> model = sncosmo.Model('sn91bg')
>>> phase_range = (-50, 50)
>>> light_curves = generate_lc(model, phase_range, param_dicts)

Function Documentation

phot_class.simulation.bg_stretch_color(size, avg_color=0.557, avg_stretch=0.975, covariance=((0.009216, -0.0110263), (-0.0110263, 0.030624999999999996)), min_stretch=0.65, max_stretch=1.25, min_color=0, max_color=1)[source]

Return random arrays for 91bg stretch and color

Parameters:
  • size (int) – Number of stretches / colors to return
  • avg_color (float) – Average color value
  • avg_stretch (float) – Average stretch value
  • covariance (float) – Covariance matrix for stretch / color
  • min_stretch (float) – Minimum stretch to return
  • max_stretch (float) – Maximum stretch to return
  • min_color (float) – Minimum color to return
  • max_color (float) – Maximum color to return
Returns:

An array of stretch values An array of color values

phot_class.simulation.sim_bg_params(zmin, zmax, tmin, tmax, area=1.0, ratefunc=None, cosmo=None, **kwargs)[source]

Simulate parameters for “observed” 91bg light curves

Parameters:
  • zmin (float) – Minimum redshift value
  • zmax (float) – Maximum redshift value
  • tmin (float) – Minimum observation time in days
  • tmax (float) – Maximum observation time in days
  • area (float) – Sky area in deg2 to simulate. Determines number of SNe.
  • ratefunc (callable) – A callable that accepts a single float (redshift) and returns the comoving volumetric rate at each redshift in units of yr^-1 Mpc^-3. The default is a function that returns 1.e-4.
  • cosmo (Cosmology) – The cosmology used to determine volume. The default is a FlatLambdaCDM cosmology with Om0=0.3, H0=70.0.
  • other kwargs for bg_stretch_color except size (Any) –
Returns:

A list of dictionaries with model parameters for each light-curve

phot_class.simulation.generate_lc(model, phase_range, model_params)[source]

Generate light curves in SDSS band passes

This is a very simple simulation that assumes observations are performed simultaneously at each epoch with a gain of one and zero sky noise. Simulations use SDSS band-passes

Parameters:
  • model (Model) – The model to be used
  • phase_range (tuple) – Phase range to simulate light-curves over
  • model_params (list) – List of model parameters for each light-curve

phot_class.utils

A collection of general utilities used across the parent package.

phot_class.utils.calc_model_chisq(data, result, model)[source]

Calculate the chi-squared for a given data table and model

Chi-squareds are calculated using parameter values from model. Degrees of freedom are calculated using the number of varied parameters specified is the result object.

Parameters:
  • data (Table) – An sncosmo input table
  • model (Model) – An sncosmo Model
  • result (Result) – sncosmo fitting result
Returns:

The un-normalized chi-squared The number of data points used in the calculation

phot_class.utils.classification_filter_factory(classifications, ftype='exclude')[source]
Returns function to determine whether data should be skipped/kept in an
iterator based on its classification

The function returned by this factory has signature returned_function(table: astropy.Table) -> boolean. The boolean indicates whether the data should kept (i.e. not skipped). The class of each object is determined from table.meta['classification']. If there is no ‘classification’ key in the meta data, the return is True.

Parameters:
  • classifications (list[str]) – A list of classifications to allow
  • ftype (str) – ‘exclude’ or ‘include’ the given classes
Returns:

A filter function for sndata

phot_class.utils.parse_config_dict(obj_id, config_dict)[source]

Return the priors and kwargs for a given object from a config file

Parameters:
  • obj_id (str) – The object id in the dictionary
  • config_dict (dict) – A dictionary with data from a config file
Returns:

  • A dictionary with object priors for the hsiao_x1 model
  • A dictionary of fitting kwargs for the hsiao_x1 model
  • A dictionary with object priors for the sn91bg model
  • A dictionary of fitting kwargs for the sn91bg model

phot_class.utils.split_bands(bands, lambda_eff, redshift=0)[source]

Split band-passes into collections of blue and red bands

Blue bands have an rest frame effective wavelength < 5500 Ang. Red bands have a rest frame effective wavelength >= 5500 Ang.

Parameters:
  • bands (array[str]) – Name of band-passes
  • lambda_eff (array[float]) – Effective wavelength of band-passes
  • redshift (float) – The redshift of the rest frame
Returns:

An array of blue filter names An array of red filter names

phot_class.utils.split_data(data_table, band_names, lambda_eff, z, cutoff=700)[source]

Split a data table into blue and red data (by rest frame)

Wavelengths are expected to be in angstroms. Split data by keeping filters that are red-ward or blue-ward of 5500 Ang. If the closest rest frame filter for an observation is more than cutoff angstroms away, drop the observation.

Parameters:
  • data_table (Table) – An SNCosmo input table with column ‘band’
  • band_names (iter) – List of all bands available in the survey
  • lambda_eff (iter) – The effective wavelength of each band in band_names
  • z (float) – The redshift of the observed target
  • cutoff (float) – The cutoff distance for dropping an observation
Returns:

A SNCosmo input table with only blue bands A SNCosmo input table with only red bands

class phot_class.utils.timeout(seconds=1, error_message='Timeout')[source]

A timeout context manager