The LightCurve class is a class which enables repeating simple calculations that are often used for light curves:
TODO :
In [20]:
import snsims
In [21]:
import sncosmo
In [22]:
%matplotlib inline
In [23]:
import matplotlib.pyplot as plt
In [9]:
import seaborn as sns
sns.set()
We will consider data that is used as an example in SNCosmo, and look at the LightCurve
functionality on this.
In [5]:
data = sncosmo.load_example_data()
model = sncosmo.Model(source='salt2')
In [7]:
model.set(**data.meta)
In [8]:
print model
In [10]:
fig = sncosmo.plot_lc(data, model=model, color='k')
In [11]:
lc = snsims.LightCurve(data.to_pandas())
In [12]:
lc.lightCurve
Out[12]:
In [13]:
newdata = data.to_pandas()
In [14]:
newdata.columns
Out[14]:
In [15]:
newdata.rename(columns={'time': 'expMJD'}, inplace=True)
In [16]:
newdata
Out[16]:
In [17]:
newlc = snsims.LightCurve(newdata)
In [18]:
newlc.columnAliases
Out[18]:
In [19]:
newlc._lightCurve.columns
Out[19]:
In [19]:
snsims.aliasDictionary(newlc._lightCurve.columns, newlc.columnAliases)
Out[19]:
In [20]:
snsims.aliasDictionary(data.columns, newlc.columnAliases)
Out[20]:
In [21]:
newlc.lightCurve
Out[21]:
In [22]:
sncosmo.plot_lc(newlc.snCosmoLC(), model, color='k')
Out[22]:
In [32]:
lc.coaddedLC(coaddTimes=10.)
Out[32]:
In [33]:
lcc = lc.lightCurve.copy()
In [34]:
grouped = lcc.groupby(['band'])
In [35]:
import numpy as np
In [36]:
grouped.agg({'mjd':np.mean, 'band': 'count'})
Out[36]:
In [27]:
sncosmo.plot_lc(lc.snCosmoLC(coaddTimes=10., mjdBefore=1.), model, color='k')
Out[27]:
In [28]:
lc.lightCurve.query('band == "sdssg"')
Out[28]:
In [29]:
all(lc.coaddedLC(coaddTimes=None) == lc.lightCurve)
Out[29]:
In [30]:
lc.coaddedLC(coaddTimes=20., mjdBefore=1)
Out[30]:
In [31]:
lc.coaddedLC(coaddTimes=20., mjdBefore=1).reset_index('band', inplace=True)
In [4]:
12* 256 * 256 /2 * 5/ 1000
Out[4]:
In [5]:
12* 256 * 256 /2 / 1e6
Out[5]:
In [6]:
8 * 200 * 5
Out[6]:
In [8]:
9216 /60. / 218.
Out[8]:
In [10]:
import analyzeSN as ans
In [11]:
import sncosmo
In [14]:
sncosmo.get_bandpass('lsst_g')
Out[14]:
In [ ]: