Created
November 24, 2016 17:21
-
-
Save guillochon/5b80cebede8f51248fc9b654a8d8e4ac to your computer and use it in GitHub Desktop.
Fitting Ia data from OSC with SNCosmo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(f.read()) | |
photodat = [] | |
data = data[list(data.keys())[0]] | |
for item in data['photometry']: | |
if 'counts' not in item or ('upperlimit' in item and item['upperlimit']): | |
continue | |
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