In [49]:
from __future__ import print_function ## Force python3-like printing
%matplotlib inline

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import os
import time

import sqlite3
from sqlalchemy import create_engine

then = time.time()

opsimdbpath = os.environ.get('OPSIMDBPATH')
# opsimdbpath = "/Users/berto/data/LSST/OpSimOutputDBs/astro_lsst_01_1068_sqlite.db.gz"
print(opsimdbpath)

engine = create_engine('sqlite:///' + opsimdbpath)

conn = sqlite3.connect(opsimdbpath)

cursor = conn.cursor()
query = 'SELECT COUNT(*) FROM Summary'
cursor.execute(query)

cursor.fetchall()

now = time.time()
print("time taken = ", now - then)


/Users/berto/data/LSST/OpSimOutputDBs/minion_1016_sqlite.db
time taken =  3.8699450492858887

In [50]:
# opsimdf = pd.read_sql_query('SELECT * FROM Summary WHERE night = 1000', engine)
# opsimdf = pd.read_sql_query('SELECT * FROM Summary WHERE night < 731 AND night > 365', engine)
opsimdf = pd.read_sql_query('SELECT * FROM Summary', engine)

In [51]:
ddf = opsimdf.query('propID > 0') ## 56 is DDF
filters = np.unique(ddf["filter"])
print(filters)


['g' 'i' 'r' 'u' 'y' 'z']

In [52]:
# ddf

In [53]:
type(ddf)


Out[53]:
pandas.core.frame.DataFrame

In [54]:
import astropy.coordinates as coord
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.coordinates import ICRS, Galactic, FK4, FK5  # Low-level frames
from astropy.coordinates import Angle, Latitude, Longitude  # Angles

In [ ]:


In [55]:
fig = plt.figure(figsize=[8, 4])

fig.subplots_adjust(left = 0.01, bottom = 0.05, top = 0.85, right = 0.99, hspace=0, wspace = 0)
ax = fig.add_subplot(111, projection="aitoff")
ax.grid(True)

ax.scatter(ddf["fieldRA"].unique(), ddf["fieldDec"].unique())


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-55-a7eec1dae094> in <module>()
      5 ax.grid(True)
      6 
----> 7 ax.scatter(ddf["fieldRA"].unique(), ddf["fieldDec"].unique())

/Users/berto/anaconda2/envs/py3/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
   1890                     warnings.warn(msg % (label_namer, func.__name__),
   1891                                   RuntimeWarning, stacklevel=2)
-> 1892             return func(ax, *args, **kwargs)
   1893         pre_doc = inner.__doc__
   1894         if pre_doc is None:

/Users/berto/anaconda2/envs/py3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
   3956         y = np.ma.ravel(y)
   3957         if x.size != y.size:
-> 3958             raise ValueError("x and y must be the same size")
   3959 
   3960         if s is None:

ValueError: x and y must be the same size

In [ ]:


In [ ]: