Skip to content

Instantly share code, notes, and snippets.

Created Nov 24, 2016
What would you like to do?
Fitting Ia data from OSC with SNCosmo
from astropy.table import Table
import sncosmo
import json
source = sncosmo.get_source('salt2', version='2.4')
model = sncosmo.Model(source=source)
with open('SNLS-05D4bm.json', 'r') as f:
data = json.loads(
photodat = []
data = data[list(data.keys())[0]]
for item in data['photometry']:
if 'counts' not in item or ('upperlimit' in item and item['upperlimit']):
photodat.append((float(item['time']), 'sdss' + item['band'].strip("'"),
float(item['counts']), float(item['e_counts']),
float(item['zeropoint']), 'bd17'))
table = Table(rows=photodat, names=('time', 'band', 'flux', 'fluxerr',
'zp', 'zpsys'))
result, fm = sncosmo.fit_lc(table, model, ['z', 't0', 'x0', 'x1', 'c'],
bounds={'z':(0.25, 0.45)})
sncosmo.plot_lc(table, model=fm, errors=result.errors)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment