In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
# import seaborn as sns
# sns.set()
In [2]:
import sncosmo
In [3]:
import analyzeSN as ans
This should work with all the supernovae in the simulation, but to make this example quick, let us just load the first one and represent the collection of SN.
In [6]:
# location is relative or absolute path to the file
sne = ans.snanaSims.SnanaSims.fromSNANAfileroot('snana_fits', location=ans.example_data, n=1)
Pick out the very first SN and reformat it to look the way sncosmo expects SN to look
In [7]:
sn = ans.snanaSims.SnanaSims.reformat_SNANASN(sne.snList[0])
Make sure SNCosmo can understand band names
In [8]:
ans.snanaSims.SnanaSims.matchSNANAbandnamesinregistry()
We can look at the information in the light curve, or at the metadata
In [9]:
sn[:5]
Out[9]:
In [10]:
sn.meta
Out[10]:
Instantiate a model and fit Supernovae to it. Since this is a very short demonstration for how to use the SNANA simulations rather than how to use SNCosmo correctly, we will stick to basics. A few points to note that are being ignored, even though I remember them (there are probably others that I cannot remember right away :) :
In [11]:
model = sncosmo.Model(source='salt2-extended')
In [12]:
model.set(z=sn.meta['REDSHIFT_FINAL'])
fit_results, fit_model = sncosmo.fit_lc(sn, model, vparam_names=['t0', 'x0', 'x1', 'c'])
In [13]:
print fit_model
In [14]:
fig = sncosmo.plot_lc(sn, model=fit_model, band=['u', 'g', 'r', 'i', 'z', 'Y'], zp=25., zpsys='ab')
In [16]:
sncosmo.chisq(sn, fit_model)/ fit_results.ndof
Out[16]: