In [33]:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
sns.set()
In [2]:
opSimVisits = pd.read_csv('/Users/rbiswas/doc/projects/LSST/Twinkles/code/SN_sims/SelectedKrakenVisits.csv',
index_col='obsHistID')
In [3]:
opSimVisits.head()
Out[3]:
In [36]:
surveyStartDate = 59580
In [4]:
krakenObs = pd.read_csv('krakenvists_twinkles.csv', index_col='obsHistID')
In [5]:
krakenObs.head()
Out[5]:
In [7]:
krakenObs['fsD'] = opSimVisits['fiveSigmaDepth']
In [9]:
sncols = [x for x in krakenObs.columns if x.startswith('mag_')]
HSNR_sn = [x for x in sncols if (krakenObs[x] - krakenObs['fsD']).min() < 0.]
In [10]:
print len(HSNR_sn), len(sncols)
In [19]:
HsnrID = [int(x.split('_')[1]) for x in HSNR_sn]
In [12]:
twinklesSN = pd.read_csv('kraken_sim.csv', index_col='snid')
In [17]:
twinklesSN.index
Out[17]:
In [122]:
sns.set_context('notebook')
In [110]:
fig, ax = plt.subplots(1, 3, **{'figsize': (15, 5)})
sns.distplot(twinklesSN.ix[HsnrID, 'redshift'], rug=False, kde=False,
hist_kws={'histtype':'step', 'alpha':1, 'color':'k', 'lw':2}, ax=ax[0])
ax[0].set_ylabel('Num SN with at least one obs with SNR >5')
t0hist = sns.distplot(twinklesSN.ix[HsnrID, 't0'] + surveyStartDate, rug=False, kde=False, bins=10,
hist_kws={'histtype':'step', 'alpha':1, 'color':'k', 'lw':2}, ax=ax[1])
t0hist.axhline(np.mean(np.histogram(twinklesSN.ix[HsnrID, 't0'] + surveyStartDate, bins=10)[0]), linestyle='dashed')
t0hist.figure.autofmt_xdate()
#sns.jointplot(x=twinklesSN.ix[HsnrID]['snra'], y=twinklesSN.ix[HsnrID]['sndec'], kind="hex", color="k", ax=ax[2]);
ax[2].hexbin(twinklesSN.ix[HsnrID]['snra'], twinklesSN.ix[HsnrID]['sndec'])
ax[2].set_xlabel('ra (deg)')
ax[2].set_ylabel('dec (deg)')
Out[110]:
In [169]:
fig, ax = plt.subplots(1, 4, **{'figsize':(20, 4)})
sns.distplot(twinklesSN.ix[HsnrID, 'c'], hist_kws={'histtype':'step', 'lw':2, 'color':'k', 'alpha':1},
rug=False, ax=ax[0], norm_hist=True, kde=False, label='selected')
sns.distplot(twinklesSN.c, hist_kws={'histtype':'step', 'lw':2, 'color':'r', 'alpha':1}, rug=False, ax=ax[0],
norm_hist=True, kde=False, label='truth')
sns.distplot(twinklesSN.ix[HsnrID, 'x1'], hist_kws={'histtype':'step', 'lw':2, 'color':'k', 'alpha':1},
rug=False, ax=ax[1], norm_hist=True, kde=False)
sns.distplot(twinklesSN.x1, hist_kws={'histtype':'step', 'lw':2, 'color':'r', 'alpha':1}, rug=False, ax=ax[1],
norm_hist=True, kde=False)
sns.distplot(twinklesSN.ix[HsnrID, 'M'], hist_kws={'histtype':'step', 'lw':2, 'color':'k', 'alpha':1},
rug=False, ax=ax[3], kde=False, norm_hist=True)
sns.distplot(twinklesSN.M, hist_kws={'histtype':'step', 'lw':2, 'color':'r', 'alpha':1}, rug=False, ax=ax[3],
kde=False, norm_hist=True)
sns.distplot(twinklesSN.ix[HsnrID, 'mB'], hist_kws={'histtype':'step', 'lw':2, 'color':'k', 'alpha':1},
rug=False, ax=ax[2], kde=False, norm_hist=True)
sns.distplot(twinklesSN.mB, hist_kws={'histtype':'step', 'lw':2, 'color':'r', 'alpha':1}, rug=False, ax=ax[2],
kde=False, norm_hist=True)
ax[0].legend(loc='best')
Out[169]:
In [123]:
mycols = ['fsD'] + HSNR_sn
In [172]:
obsvals = krakenObs[mycols].copy(deep=True)
In [173]:
for col in HSNR_sn:
obsvals[col] = np.where(obsvals[col] - obsvals['fsD'] < 0, 1, 0)
In [215]:
sns.set_context('talk')
In [216]:
fig, ax = plt.subplots()
_ = ax.hist(obsvals[HSNR_sn].sum(axis=1).values, cumulative=-1,
histtype='step', lw=2., alpha=1., bins=np.arange(0,1200,50), color='k')
ax.set_xlabel("NumDetections = Number of 5 sigma SN on an image")
#ax.set_yscale('log')
_ = ax.set_ylabel("Number of images with detections < NumDetections ")
_ = ax.set_title('Note: Cumulative Plot')
In [ ]:
fig
In [213]:
fig.savefig('NumberOfDetections.png')
In [187]:
obsvals[HSNR_sn].sum(axis=1).values
Out[187]:
In [128]:
obsvals = obsvals[HSNR_sn]
In [171]:
np.where(obsvals[HSNR_sn[-1]] - obsvals['fsD'] < 0 , 1, 0).sum()
Out[171]:
In [157]:
twinklesSN.ix[HsnrID,'redshift']
Out[157]:
In [158]:
krakenObs[['night', HSNR_sn[-1]]]
Out[158]:
In [135]:
HSNR_sn[0]
Out[135]:
In [ ]:
In [165]:
sns.jointplot(x=twinklesSN.ix[HsnrID, 'c'], y=twinklesSN.ix[HsnrID, 'mB'],kind='kde')
sns.jointplot(x=twinklesSN.ix[HsnrID, 'x1'], y=twinklesSN.ix[HsnrID, 'mB'],kind='kde')
Out[165]:
In [130]:
obsvals.mag_6000000563900.sum()
Out[130]: