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