In [1]:
import os
import numpy as np
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()


/usr/local/manual/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))

In [2]:
import astropy.io.fits as fits
from astropy.table import Table
# import sncosmo
# import analyzeSN as ans

In [3]:
oldDir = '/Users/rbiswas/Downloads/ENIGMA_LSSTDEEP_Y1'
newDir = '/Users/rbiswas/Downloads/ENIGMA_LSSTDEEP_Y1_2016/'
newDir2 = '/Users/rbiswas/data/SNDATA/SIM/ENIGMA_LSSTDEEP_Y1D_2016/'

In [12]:
fname = os.path.join(oldDir, 'LSST_Ia_HEAD.FITS')
hdulist = fits.open(fname)
data = hdulist[1].data
fname = os.path.join(newDir, 'LSST_Ia_HEAD.FITS')
head1 = pd.DataFrame(data)
hdulist = fits.open(fname)
data = hdulist[1].data
head2 = pd.DataFrame(data)
fname = os.path.join(newDir2, 'LSST_Ia_HEAD.FITS')
hdulist = fits.open(fname)
data = hdulist[1].data
head3 = pd.DataFrame(data)

In [13]:
head1.columns


Out[13]:
Index([u'SNID', u'IAUC', u'FAKE', u'RA', u'DECL', u'PIXSIZE', u'NXPIX',
       u'NYPIX', u'SNTYPE', u'NOBS', u'PTROBS_MIN', u'PTROBS_MAX', u'MWEBV',
       u'MWEBV_ERR', u'REDSHIFT_HELIO', u'REDSHIFT_HELIO_ERR',
       u'REDSHIFT_FINAL', u'REDSHIFT_FINAL_ERR', u'HOSTGAL_OBJID',
       u'HOSTGAL_PHOTOZ', u'HOSTGAL_PHOTOZ_ERR', u'HOSTGAL_SPECZ',
       u'HOSTGAL_SPECZ_ERR', u'HOSTGAL_SNSEP', u'HOSTGAL_LOGMASS',
       u'HOSTGAL_LOGMASS_ERR', u'HOSTGAL_MAG_u', u'HOSTGAL_MAG_g',
       u'HOSTGAL_MAG_r', u'HOSTGAL_MAG_i', u'HOSTGAL_MAG_z', u'HOSTGAL_MAG_Y',
       u'HOSTGAL_SB_FLUXCAL_u', u'HOSTGAL_SB_FLUXCAL_g',
       u'HOSTGAL_SB_FLUXCAL_r', u'HOSTGAL_SB_FLUXCAL_i',
       u'HOSTGAL_SB_FLUXCAL_z', u'HOSTGAL_SB_FLUXCAL_Y', u'PEAKMJD',
       u'SEARCH_TYPE', u'SIM_MODEL_NAME', u'SIM_MODEL_INDEX',
       u'SIM_TYPE_INDEX', u'SIM_TYPE_NAME', u'SIM_NON1a', u'SIM_LIBID',
       u'SIM_SEARCHEFF_MASK', u'SIM_REDSHIFT_HELIO', u'SIM_REDSHIFT_CMB',
       u'SIM_VPEC', u'SIM_DLMU', u'SIM_RA', u'SIM_DECL', u'SIM_MWEBV',
       u'SIM_PEAKMJD', u'SIM_SALT2x0', u'SIM_SALT2x1', u'SIM_SALT2c',
       u'SIM_SALT2mB', u'SIM_SALT2alpha', u'SIM_SALT2beta', u'SIM_PEAKMAG_u',
       u'SIM_PEAKMAG_g', u'SIM_PEAKMAG_r', u'SIM_PEAKMAG_i', u'SIM_PEAKMAG_z',
       u'SIM_PEAKMAG_Y', u'SIM_EXPOSURE_u', u'SIM_EXPOSURE_g',
       u'SIM_EXPOSURE_r', u'SIM_EXPOSURE_i', u'SIM_EXPOSURE_z',
       u'SIM_EXPOSURE_Y', u'SIM_GALFRAC_u', u'SIM_GALFRAC_g', u'SIM_GALFRAC_r',
       u'SIM_GALFRAC_i', u'SIM_GALFRAC_z', u'SIM_GALFRAC_Y'],
      dtype='object')

In [14]:
print(head1.SIM_PEAKMJD.max(),
head3.SIM_PEAKMJD.max())


(49754.879, 52989.988)

In [16]:
fig, ax = plt.subplots(2,2, figsize=(12,8))
ax[0, 0].scatter(head1.RA, head1.DECL)
_ = ax[0, 1].hist(head1.REDSHIFT_FINAL, bins=np.arange(0., 1.4, 0.1), histtype='step', lw=2, alpha=1.)
bins, edges, num  = ax[1, 0].hist(head1.SIM_PEAKMJD, bins=50, histtype='step', lw=2., alpha=1.)
_ = ax[1, 0].hist(head3.SIM_PEAKMJD, bins=50, histtype='step', lw=2., alpha=1., color='b')
_ = ax[1, 1].plot(head1.REDSHIFT_FINAL, head1.SIM_DLMU, '.')
ax[0, 0].scatter(head2.RA, head2.DECL, marker='+', color='r' )
_ = ax[0, 1].hist(head2.REDSHIFT_FINAL, bins=np.arange(0., 1.4, 0.1), histtype='step', lw=2, alpha=1., color='r', ls='dashed')
_ = ax[1, 0].hist(head2.SIM_PEAKMJD, bins=50, histtype='step', lw=2., alpha=1., color='r',ls='dashed')
_ = ax[1, 1].plot(head2.REDSHIFT_FINAL, head2.SIM_DLMU, '.', color='r')
#_ = ax[1, 0].hist(head2.SIM_PEAKMJD, bins=np.arange(49330, 49700., 10.), histtype='step', lw=2., alpha=1., color='r',ls='dashed')



In [ ]:


In [ ]:


In [10]:
fig, ax  = plt.subplots()
head1.hist('NOBS', bins=np.arange(0, 150, 1), histtype='step', lw=2., alpha=1., ax=ax)
head2.hist('NOBS', bins=np.arange(0, 150, 1), histtype='step', lw=2., alpha=1., ax=ax, **{'color':'r', 'ls':'dashed'})
#fi
# ax.hist(head1['NOBS'], bins=np.arange(0, 400, 5), )


Out[10]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x118019250>], dtype=object)

In [8]:
fig, ax = plt.subplots(1,3, figsize=(15, 8))
sns.jointplot(head1.SIM_SALT2x1, head1.SIM_SALT2c, kind='kde')
sns.jointplot(head1.SIM_SALT2x1, head1.SIM_SALT2mB - head1.SIM_DLMU, kind='kde')
sns.jointplot(head1.SIM_SALT2c, head1.SIM_SALT2mB - head1.SIM_DLMU, kind='kde')


/usr/local/manual/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:892: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))
Out[8]:
<seaborn.axisgrid.JointGrid at 0x117f3bf90>

Phot Files


In [9]:
fname = os.path.join(oldDir, 'LSST_Ia_PHOT.FITS')
data = Table.read(fname)
phot1 = data.to_pandas()
phot1.FLT = phot1.FLT.apply(lambda x: x.strip())
phot1 = phot1.query('FLT != "-"')
fname = os.path.join(newDir, 'LSST_Ia_PHOT.FITS')
data = Table.read(fname)
phot2 = data.to_pandas()
phot2.FLT = phot2.FLT.apply(lambda x: x.strip())
phot2 = phot2.query('FLT != "-"')

In [10]:
fig, ax = plt.subplots(2, 3)
_ = phot1.query('MAG > 15 and MAG < 50').hist('MAG', by='FLT', bins=np.arange(18, 40, 2), ax=ax,
                                          **{'histtype':'step', 
                                                                                         'normed':True, 
                                                                                         'lw':2,
                                                                                         #'ls': 'dashed',
                                                                                         'color':'k',
                                                                                          'alpha':1})
#ax[0,0].hist(phot1.query('FLT == "g "').MAG)
_ = phot2.query('MAG > 15 and MAG < 50').hist('MAG', by='FLT', bins=np.arange(18, 40, 2),ax=ax,
                                                                                        **{'histtype':'step', 
                                                                                         'normed':True, 
                                                                                         'lw':2,
                                                                                         'ls':'dashed',
                                                                                         'color':'r',
                                                                                          'alpha':1})
for axs in ax[-1]:
    axs.set_xlabel('MAG')



In [11]:
fig, ax = plt.subplots(2, 3)
_ = phot1.query('MAG > 15 and MAG < 50').hist('MAGERR', by='FLT', bins=np.arange(0., 2., 0.1), ax=ax,
                                          **{'histtype':'step', 
                                                                                         'normed':True, 
                                                                                         'lw':2,
                                                                                          #'log':True,
                                                                                         #'ls': 'dashed',
                                                                                         'color':'k',
                                                                                          'alpha':1})
#ax[0,0].hist(phot1.query('FLT == "g "').MAG)
_ = phot2.query('MAG > 15 and MAG < 50').hist('MAGERR', by='FLT', bins=np.arange(0., 2., 0.1),ax=ax,
                                                                                        **{'histtype':'step', 
                                                                                         'normed':True,
                                                                                          #'log':True,
                                                                                         'lw':2,
                                                                                         'ls':'dashed',
                                                                                         'color':'r',
                                                                                          'alpha':1})
for axs in ax[-1]:
    axs.set_xlabel('MAGERR')



In [12]:
fig, ax = plt.subplots(2, 3)
_ = phot1.query('MAG > 15 and MAG < 50').hist('MAGERR', by='FLT', bins=np.arange(0., 2., 0.1), ax=ax,
                                          **{'histtype':'step', 
                                                                                         'normed':True, 
                                                                                         'lw':2,
                                                                                          #'log':True,
                                                                                         #'ls': 'dashed',
                                                                                         'color':'k',
                                                                                          'alpha':1})
#ax[0,0].hist(phot1.query('FLT == "g "').MAG)
_ = phot2.query('MAG > 15 and MAG < 50').hist('MAGERR', by='FLT', bins=np.arange(0., 2., 0.1),ax=ax,
                                                                                        **{'histtype':'step', 
                                                                                         'normed':True,
                                                                                          #'log':True,
                                                                                         'lw':2,
                                                                                         'ls':'dashed',
                                                                                         'color':'r',
                                                                                          'alpha':1})
for axs in ax[-1]:
    axs.set_xlabel('MAGERR')



In [13]:
phot1['SNR'] = phot1['FLUXCAL'] / phot1['FLUXCALERR']
phot2['SNR'] = phot2['FLUXCAL'] / phot2['FLUXCALERR']

In [14]:
fig, ax = plt.subplots(2, 3)
_ = phot1.query('SNR >=0.').hist('SNR', by='FLT', ax=ax, 
                             **{'histtype':'step', 'lw':2, 'color':'k', 'alpha':1., 'bins':np.arange(0., 50., 1)})
_ = phot2.query('SNR >=0.').hist('SNR', by='FLT', ax=ax, 
                             **{'histtype':'step', 'lw':2, 'color':'r', 'ls':'dashed',
                                'alpha':1., 'bins':np.arange(0., 50., 1)})

for axs in ax:
    for axl in axs:
        _ = axl.set_xlim(0., 10.)