analysis.models

The models module defines custom Source objects for using various supernova models with the sncosmo python package.

Available Models

Name Version Description
CMFGEN 1.02 Explosion Model for a 1.02 solar mass progenitor
CMFGEN 1.04 Explosion Model for a 1.04 solar mass progenitor
CMFGEN 1.4 Explosion Model for a 1.4 solar mass progenitor
CMFGEN 1.7 Explosion Model for a 1.7 solar mass progenitor

Usage Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sncosmo
from matplotlib import pyplot as plt

from analysis import models

# Make sncosmo aware of the sncosmo models
models.register_sources()

# Initialize a CMFGEN model where the version is the model mass
source = sncosmo.get_source('CMFGEN', version='1.04')
model = sncosmo.Model(source=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

class analysis.models.GenericSource(path, version)[source]

SNCosmo source class for a CMFGEN model

interpolated_model()[source]

Return the phase, wavelength, and flux values used for fitting

Returns the data with flux values down-sampled onto the same wavelength values for all phase values. The returned model is the same as the data used when fitting light curves.

Returns:A 1D array of phase values A 1D array of wavelength values A 2D array of flux values
original_model()[source]

Return the phase, wavelength, and flux values of the model

Returns the un-gridded model that this class is based on without any down-sampling. Flux values span different wavelength ranges for different phases.

Returns:A 1D array of phase values A 2D array of wavelength values A 2D array of flux values
analysis.models.register_sources(force=False)[source]

Register CMFGEN models with sncosmo

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