In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from skyrandoms import random_radec
from astroML.correlation import uniform_sphere
from skyrandoms import SkyRandomsDatabase

In [2]:
npoints = int(1e7)
ralim = [20,50]
declim = [-1, 45]
ra1, dec1 = uniform_sphere(ralim, declim, size=npoints)
ra, dec = random_radec(npoints, ra_lim=ralim, dec_lim=declim)

bins = 200
fig, axes = plt.subplots(1, 2, figsize=(12,4))
axes[0].hist(ra, bins=bins, histtype='step')
axes[0].hist(ra1, bins=bins, histtype='step')
axes[1].hist(dec, bins=bins, histtype='step')
axes[1].hist(dec1, bins=bins, histtype='step');



In [3]:
db = SkyRandomsDatabase(db_fn='../local_data/skyrandoms.db', overwrite=True)

In [4]:
%time
db.add_random_batch(density=2)


CPU times: user 3 µs, sys: 1 µs, total: 4 µs
Wall time: 8.11 µs

In [5]:
db.get_last_id()


Out[5]:
82506

In [6]:
db.get_last_id()/db.area


Out[6]:
2.0000018786811684