In [1]:
import numpy as np
In [2]:
import snsims
import healpy as hp
In [3]:
from astropy.cosmology import Planck15 as cosmo
In [4]:
import sncosmo
In [5]:
zdist = snsims.PowerLawRates(rng=np.random.RandomState(1),
fieldArea=9.6,
surveyDuration=10.,
zbinEdges=np.arange(0.10001, 1.1, 0.1))
In [6]:
zdist.zSamples
Out[6]:
In [7]:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("whitegrid")
In [8]:
sp = snsims.SimpleSALTDist(numSN=len(zdist.zSamples), zSamples=zdist.zSamples, rng=np.random.RandomState(8))
In [9]:
sp.paramSamples.head()
Out[9]:
In [10]:
mB = np.zeros(len(sp.paramSamples))
In [11]:
model = sncosmo.Model('salt2')
for ind, row in sp.paramSamples.iterrows():
model.set(**dict(z=row['z'], x1=row['x1'], c=row['c'], x0=row['x0']))
mB[ind] = model.source_peakabsmag('bessellB', 'ab')
In [12]:
sp.paramSamples['mBessellB'] = mB
In [13]:
gmm_dist = snsims.GMM_SALT2Params(numSN=len(zdist.zSamples),
zSamples=zdist.zSamples,
rng=np.random.RandomState(8))
In [14]:
gp = gmm_dist.paramSamples
In [15]:
gmm_dist.zSamples
Out[15]:
In [16]:
sp.paramSamples.mBessellB.describe()
Out[16]:
In [17]:
gp.mB.describe()
Out[17]:
In [18]:
fig, ax = plt.subplots(1, 3)
sns.distplot(sp.paramSamples.mBessellB, rug=False, hist_kws=dict(histtype='step', alpha=1, lw=0.5), color='r', ax=ax[0])
sns.distplot(gp.mB, rug=False, hist_kws=dict(histtype='step', alpha=1, lw=0.5), color='k', ax=ax[0], label='')
sns.distplot(sp.paramSamples.x1, rug=False, hist_kws=dict(histtype='step', alpha=1, lw=0.5), color='r', ax=ax[1])
sns.distplot(gp.x1, rug=False, hist_kws=dict(histtype='step', alpha=1, lw=0.5), color='k', ax=ax[1])
sns.distplot(sp.paramSamples.c, rug=False, hist_kws=dict(histtype='step', alpha=1, lw=0.5), color='r')
sns.distplot(gp.c, rug=False, hist_kws=dict(histtype='step', alpha=1, lw=0.5), color='k')
plt.legend()
In [20]:
sns.pairplot(gp[['mB', 'x1', 'c', 'z']], kind='scatter')
Out[20]:
In [52]:
sns.pairplot(sp.paramSamples[['mBessellB', 'x1', 'c', 'z']], kind='scatter')
Out[52]:
In [23]:
import sncosmo
model = sncosmo.Model(source='salt2')
In [24]:
model.set(z=0.5, x1=0., c=0.)
In [27]:
model.set_source_peakabsmag(-19.0, 'bessellB', 'ab')
In [28]:
print model
In [29]:
model.source.peakmag('bessellB', 'ab')
Out[29]:
In [30]:
from astropy.cosmology import FlatLambdaCDM
In [31]:
cosmo = FlatLambdaCDM(H0=69.3, Om0=0.286)
In [35]:
cosmo.distmod(z=0.5).value -19.0
Out[35]:
In [ ]:
In [13]:
zbin_edges = np.arange(0.1, 1.01, 0.1)
diff_volume = cosmo.comoving_volume(zbin_edges[1:]) - cosmo.comoving_volume(zbin_edges[:-1])
print diff_volume
In [14]:
fig_subs, axs = plt.subplots(3)
axs[0].plot(zvals, zdist.snRate(zvals), 'or')
axs[1].plot(zvals, diff_volume , 'or')
axs[2].plot(zvals, diff_volume * zdist.snRate(zvals)*10.0/40000. / 365.0, 'or')
axs[2].set_xlabel('z')
axs[0].set_ylabel('rate')
axs[1].set_ylabel('comoving vol')
axs[2].set_ylabel('vol X skyfrac X time')
Out[14]:
In [29]:
zdist = snsims.PowerLawRates(rng=np.random.RandomState(1),
fieldArea=18000.,
surveyDuration=10.,
zbinEdges=np.arange(0.010001, 0.901, 0.1))
In [16]:
zdist.zSampleSize().sum() /1.0e6
Out[16]:
In [ ]:
In [22]:
fig, ax = plt.subplots()
_ = ax.hist(zdist.zSamples, bins=np.arange(0.001, 1.4, 0.05), histtype='step', lw=2., alpha=1.)
In [ ]:
arcmin = 1.0 / 60.
In [24]:
zdist = snsims.PowerLawRates(rng=np.random.RandomState(1),
fieldArea=10.,
surveyDuration=10.,
zbinEdges=np.arange(0.010001, 0.901, 0.05))
In [28]:
np.array(map(np.float, zdist.numSN())) /5.
Out[28]:
In [20]:
np.pi * (1.0 / 12.)**2
Out[20]:
In [21]:
10.0 / 200.
Out[21]:
In [ ]: