In [1]:
# Obtain the OpSim summary in a dataFrame

In [1]:
import pandas as pd
import numpy as np
import opsimsummary as oss
import os

In [11]:
pkgDir = os.path.split(oss.__file__)[0]
dbname = os.path.join(pkgDir, 'example_data', 'enigma_1189_micro.db')

In [16]:
!du -h $dbname


 27M	/Users/rbiswas/.local/lib/python2.7/site-packages/opsimsummary/example_data/enigma_1189_micro.db

In [4]:
from sqlalchemy import create_engine

In [17]:
engine = create_engine('sqlite:///' + dbname)

In [21]:
df = pd.read_sql_query('SELECT * FROM Summary WHERE PropID is 364' , con=engine, index_col='obsHistID')

In [22]:
df.head()


Out[22]:
sessionID propID fieldID fieldRA fieldDec filter expDate expMJD night visitTime ... moonBright darkBright rawSeeing wind humidity slewDist slewTime fiveSigmaDepth ditheredRA ditheredDec
obsHistID
171077 1189 364 2123 3.502578 -0.203741 z 18745559 49569.962492 217 34.0 ... 0.0 90.575602 1.395861 0.0 0.0 2.729285 0.000000 21.402429 3.486983 -0.230192
171078 1189 364 2109 3.556282 -0.208795 z 18745598 49569.962940 217 34.0 ... 0.0 88.780090 1.395861 0.0 0.0 0.052807 4.701006 21.420436 3.540671 -0.235246
171079 1189 364 2103 3.609762 -0.213110 z 18745636 49569.963388 217 34.0 ... 0.0 87.241597 1.395861 0.0 0.0 0.052469 4.665852 21.435982 3.594137 -0.239561
171080 1189 364 2082 3.663150 -0.216431 z 18745675 49569.963837 217 34.0 ... 0.0 85.930303 1.395861 0.0 0.0 0.052268 4.820142 21.449321 3.647513 -0.242882
171081 1189 364 1947 3.690123 -0.263957 z 18745714 49569.964286 217 34.0 ... 0.0 84.412797 1.395861 0.0 0.0 0.054263 4.841302 21.464869 3.674303 -0.290408

5 rows × 44 columns


In [23]:
h = oss.HealPixelizedOpSim(opsimDF=df)

In [24]:
h.doPreCalcs()

In [25]:
h.obsHistIdsForTile(0)


Out[25]:
array([172110, 175948, 175949, ..., 269958, 269959, 269960])

In [27]:
def inhids(lst):
    return 9 in lst

In [28]:
all(h.opsimdf.obsHistID[h.opsimdf.hids.apply(inhids).values].values == h.obsHistIdsForTile(9))


Out[28]:
True