Demonstrate the use of OpSimOutput

This demo notebook demonstrates the following:

  • recommended way of reading in from an OpSim database
  • zeroDDFdither = True or False options

In [4]:
import opsimsummary as oss

In [1]:
from opsimsummary import OpSimOutput

In [25]:
import os

We use a small opsim output package for demonstration that is shipped with the package.


In [10]:
opsimdb = os.path.join(oss.__path__[0], 'example_data', 'enigma_1189_micro.db')

In [ ]:


In [12]:
opsout = OpSimOutput.fromOpSimDB(opsimdb, subset='unique_all')


 reading from database sqlite:////Users/rbiswas/.local/lib/python2.7/site-packages/opsimsummary/example_data/enigma_1189_micro.db
/usr/local/miniconda/lib/python2.7/site-packages/pandas/core/indexing.py:476: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s

In [1]:
opsout.propIDDict


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-3b9686fd3d0a> in <module>()
----> 1 opsout.propIDDict

NameError: name 'opsout' is not defined

In [14]:
opsout.summary['ditherInRA'] = opsout.summary.ditheredRA -opsout.summary.fieldRA
opsout.summary['ditherInDec'] = opsout.summary.ditheredDec -opsout.summary.fieldDec

In [16]:
opsout.summary.query('propID == 366').ditherInRA.unique()


Out[16]:
array([ 0.])

In [17]:
opsout.summary.query('propID == 366').ditherInDec.unique()


Out[17]:
array([ 0.])

In [18]:
opsout.summary.query('propID == 364').ditherInRA.unique()


Out[18]:
array([-0.00693527, -0.00671326, -0.00669524, ..., -0.01606634,
       -0.01629516, -0.01603056])

In [19]:
opsout.summary.query('propID == 364').ditherInDec.unique()


Out[19]:
array([-0.003306, -0.003306, -0.003306, -0.003306, -0.003306, -0.003306,
       -0.003306, -0.003306, -0.003306, -0.003306, -0.003306,  0.      ,
       -0.006613, -0.006613, -0.006613, -0.006613, -0.006613, -0.006613,
       -0.006613, -0.006613, -0.006613, -0.006613, -0.006613, -0.006613,
       -0.009919, -0.009919, -0.009919, -0.009919, -0.009919, -0.009919,
       -0.009919, -0.009919,  0.006613,  0.006613,  0.006613,  0.006613,
        0.006613,  0.006613,  0.006613,  0.006613,  0.006613,  0.006613,
        0.006613,  0.003306,  0.003306,  0.003306,  0.003306,  0.003306,
        0.003306,  0.003306,  0.003306,  0.003306,  0.003306,  0.003306,
        0.009919,  0.009919,  0.009919,  0.009919,  0.009919,  0.009919,
        0.009919,  0.009919,  0.009919,  0.006613, -0.026451, -0.019838,
       -0.019838, -0.019838, -0.019838, -0.019838, -0.019838, -0.019838,
       -0.019838, -0.023145, -0.023145, -0.023145, -0.023145, -0.023145,
       -0.023145, -0.023145, -0.023145, -0.023145, -0.023145, -0.023145,
       -0.016532, -0.016532, -0.016532, -0.016532, -0.016532, -0.016532,
       -0.016532, -0.016532, -0.016532, -0.016532, -0.026451, -0.026451,
       -0.026451, -0.026451, -0.026451, -0.026451, -0.026451, -0.026451,
       -0.026451, -0.009919, -0.013226, -0.013226, -0.013226, -0.013226,
       -0.013226, -0.013226, -0.013226, -0.013226, -0.013226, -0.016532])

In [20]:
opsout_likemaf = OpSimOutput.fromOpSimDB(opsimdb, subset='unique_all', zeroDDFDithers=False)


 reading from database sqlite:////Users/rbiswas/.local/lib/python2.7/site-packages/opsimsummary/example_data/enigma_1189_micro.db

In [21]:
opsout_likemaf.summary['ditherInRA'] = opsout_likemaf.summary.ditheredRA -opsout_likemaf.summary.fieldRA
opsout_likemaf.summary['ditherInDec'] = opsout_likemaf.summary.ditheredDec -opsout_likemaf.summary.fieldDec

In [24]:
opsout_likemaf.summary.query('propID == 366').ditherInRA.unique()


Out[24]:
array([ -2.48464412e-02,   4.08704610e-02,  -4.30196047e-03,
        -1.27552534e-02,  -1.07549012e-02,   6.27501093e+00,
        -9.58279400e-03,  -6.45294071e-03,  -5.74967640e-03,
         8.60392095e-03,   1.14993528e-02,   6.26956134e+00,
         0.00000000e+00,  -4.67670351e-02,   6.25321402e+00,
        -2.10811428e-02,  -3.22635768e-02,   6.26411176e+00,
        -2.97622578e-02,  -1.34159116e-02,  -1.93588221e-02,
        -1.72490292e-02,  -2.12587556e-02,  -1.50568617e-02,
         6.25866217e+00,  -3.82657601e-02,  -1.29058814e-02,
         1.50568617e-02,   5.74967640e-03,   2.15098024e-03,
         4.30196047e-03,   2.58106361e-02,   1.72078419e-02,
         3.01125966e-02,  -2.79616163e-02,   2.67577829e-02,
         2.29977017e-02,   3.44145570e-02,  -2.87473781e-02,
         3.06639369e-02,   2.15098024e-02,  -2.36596558e-02,
        -2.49142605e-02])

In [ ]: