In [1]:
from __future__ import print_function

import os

import numpy as np
import sncosmo
import matplotlib.pyplot as plt

%matplotlib inline

Custom model data


In [2]:
fname = sncosmo.conf.data_dir + '/models/snana/SDSS-000018.SED'
fname


Out[2]:
'/home/kyle/data/sncosmo/models/snana/SDSS-000018.SED'

In [4]:
phase, wave, flux = sncosmo.read_griddata_ascii(fname)

In [5]:
phase.shape, wave.shape


Out[5]:
((58,), (1970,))

In [6]:
flux.shape


Out[6]:
(58, 1970)

In [7]:
source = sncosmo.TimeSeriesSource(phase, wave, flux, name='mytemplate')

In [8]:
print(source)


class      : TimeSeriesSource
name       : 'mytemplate'
version    : None
phases     : [-29.86, .., 79.95] days
wavelengths: [300, .., 19990] Angstroms
parameters:
  amplitude = 1.0

In [9]:
model = sncosmo.Model(source=source)

In [10]:
print(model)


<Model at 0x7fa64fae92e8>
source:
  class      : TimeSeriesSource
  name       : 'mytemplate'
  version    : None
  phases     : [-29.86, .., 79.95] days
  wavelengths: [300, .., 19990] Angstroms
parameters:
  z         = 0.0
  t0        = 0.0
  amplitude = 1.0