In [1]:
import numpy as np
import pandas as pd
import os
In [2]:
import sqlite3
from sqlalchemy import create_engine
In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
In [4]:
opsimdbpath = os.environ.get('OPSIMDBPATH')
In [5]:
print(opsimdbpath)
In [6]:
engine = create_engine('sqlite:///' + opsimdbpath)
In [7]:
conn = sqlite3.connect(opsimdbpath)
In [8]:
cursor = conn.cursor()
print cursor
In [ ]:
query = 'SELECT COUNT(*) FROM Summary'
cursor.execute(query)
In [ ]:
cursor.fetchall()
In [9]:
opsimdf = pd.read_sql_query('SELECT * FROM Summary WHERE night < 1000', engine)
In [10]:
opsimdf.head()
Out[10]:
In [11]:
# Definitions of the columns are
opsimdf[['obsHistID', 'filter', 'night', 'expMJD',
'fieldID', 'fieldRA', 'ditheredRA', 'ditheredRA', 'ditheredDec',
'propID', 'fiveSigmaDepth']].head()
Out[11]:
In [12]:
opsimdf.propID.unique()
Out[12]:
In [13]:
xx = opsimdf.query('fieldID == 316')
In [14]:
xx.head()
Out[14]:
In [15]:
xx.query('propID == 54')
Out[15]:
propID
In [16]:
test = opsimdf.drop_duplicates()
In [17]:
all(test == opsimdf)
Out[17]:
In [18]:
test = opsimdf.drop_duplicates(subset='obsHistID')
In [19]:
len(test) == len(opsimdf)
Out[19]:
In [20]:
opsimdf.obsHistID.size
Out[20]:
In [21]:
opsimdf.obsHistID.unique().size
Out[21]:
In [22]:
test.obsHistID.size
Out[22]:
In [27]:
import opsimsummary as oss
In [24]:
# Read in the combined summary.
In [25]:
opsimout = oss.OpSimOutput.fromOpSimDB(opsimdbpath)
In [ ]:
help(oss.OpSimOutput)
In [ ]:
opsimDeep = oss.OpSimOutput.fromOpSimDB(opsimdbpath, subset='DDF')
In [ ]:
oss.OpSimOutput.get_allowed_subsets()
In [ ]:
odeep = oss.summarize_opsim.SummaryOpsim(opsimDeep.summary)
In [ ]:
xx = opsimout.summary.groupby('fieldID').expMJD.agg('count')
In [ ]:
fig, ax = plt.subplots()
xx.hist(histtype='step', bins=np.arange(0., 5000, 50.), ax=ax)
ax.set_xlabel('fieldID')
ax.set_ylabel('Number of visits to field during survey')
In [ ]:
#DDF
fig, ax = plt.subplots()
xx.hist(bins=np.arange(15000, 25000, 50), histtype='step')
ax.set_xlabel('fieldID')
ax.set_ylabel('Number of visits to field during survey DDF')
In [ ]:
xx[xx > 5000]
In [ ]:
# 1000 visits just in terms of exposure is 9 hrs 25 mins
fig, ax = plt.subplots()
xx = opsimout.summary.groupby(['night']).expMJD.agg('count')
xx.hist(histtype='step', bins=np.arange(0., 5000, 100.), ax=ax)
ax.set_xlabel('Number of visits in a night')
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: