In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
from sqlalchemy import create_engine
import numpy as np
import pandas as pd
import seaborn as sb
import os
import healpy as hp
In [2]:
from lsst.sims.photUtils import noiseUtilities
from lsst.sims.photUtils import Bandpass, Photometry, PhotometryBase
In [3]:
engine = create_engine('sqlite:////Users/rbiswas/data/LSST/OpSimData/enigma_1189_sqlite.db')
In [4]:
Summary = pd.read_sql_table('Summary', engine)
Proposal = pd.read_sql_table('Proposal', engine)
Seeing = pd.read_sql_table('Seeing', engine)
Field = pd.read_sql_table('Field', engine)
In [5]:
Summary.drop_duplicates('expMJD', inplace=True)
In [6]:
Summary.shape, Proposal.shape, Seeing.shape, Field.shape
Out[6]:
In [7]:
Summary.columns
Out[7]:
In [8]:
# Read in LSST bandpasses.
bpdir = os.getenv("LSST_THROUGHPUTS_BASELINE")
filterlist = ('u', 'g', 'r', 'i', 'z', 'y')
lsstbp = {}
for f in filterlist:
lsstbp[f] = Bandpass()
lsstbp[f].readThroughput(os.path.join(bpdir, 'total_'+f+'.dat'))
#dt, t = dtime(t)
In [11]:
# Add gamma to dataframe
Summary['gamma'] = Summary[['filter','fiveSigmaDepth','visitExpTime']].apply(lambda x:
noiseUtilities.calcGamma(bandpass=lsstbp[x[0]], m5=x[1], expTime=x[2]),
axis=1)
In [12]:
Summary['N0sq'] = Summary['gamma'] * 10.0 **(-0.2 * Summary['fiveSigmaDepth'])
Summary['alpha'] = Summary['gamma']
In [27]:
Summary['alpha'].hist(by=Summary['filter'], histtype='step', lw=2.0, color='k', sharex=True, sharey=True)
Out[27]:
In [ ]:
fig, ax = plt.subplots(3, 2, sharex=True, sharey=True)
Summary['gamma'].hist(by=Summary['filter'], histtype='step', lw=2., color='k', normed=1, bins=20, ax=ax)
In [36]:
store = pd.HDFStore('storage.h5')
In [34]:
hdf.close()
In [40]:
print store
In [38]:
Summary.to_hdf('storage.h5', 'table')
In [41]:
store.close()
In [42]:
print store
In [190]:
fig.savefig('GammaHist.pdf')
In [43]:
!du -h storage.h5
In [160]:
type(ax)
Out[160]:
In [158]:
plt.savefig('gammaHists.pdf')
In [131]:
fs = Summary.groupby('filter')
In [132]:
fs.groups.keys()
Out[132]:
In [205]:
fig, ax = plt.subplots()
zip (fs.groups.keys(), map(lambda x: fs.get_group(x)['gamma'].hist(histtype='step', lw=2, normed=1, label=x, ax=ax), fs.groups.keys()))
ax.legend(loc='best')
ax.axvline(0.037, lw=2., color='b')
ax.axvline(0.038, lw=2., color='g')
ax.axvline(0.039, lw=2., color='r')
ax.axvline(0.039, lw=2., color='m')
ax.axvline(0.040, lw=2., color='y')
ax.axvline(0.040, lw=2., color='c')
Out[205]:
In [206]:
fig.savefig('Gamma_paperVals_hist.pdf')