In [1]:
from peerless.catalogs import TargetCatalog, EBCatalog
targets = TargetCatalog().df

bad = targets.mass.isnull()
targets.loc[bad, 'mass'] = targets.loc[bad, 'radius']

In [2]:
%run ../peerless/plot_setup.py

In [10]:
import numpy as np
from exosyspop.populations import PlanetPopulation, REARTH, RSUN

import astropy.constants as const
RJUP = const.R_jup.cgs

class SimplePlanetPopulation(PlanetPopulation):
    """ Simple planet population for testing purposes
    
    Every star has exactly one planet.
    All periods at a single period. 
    All radii at a single radius.
    All circular orbits.
    """
    single_period = 1*365.25
    single_R = 1*RJUP/RSUN
    
    param_names = ()
    default_params = {}
    
    def _sample_ecc(self, N):
        return np.zeros(N)
    
    def _sample_period(self, N):
        return np.ones(N)*self.single_period
    
    def _sample_Np(self, N):
        return np.ones(N)
        
    def _sample_Rp(self, N):
        return np.ones(N)*self.single_R

In [45]:
# Use an idealized population with all dutycycle=1, dataspan=1yr
targets_ideal = targets.copy()
targets_ideal.dutycycle = 1.#/3
targets_ideal.dataspan = 365.#/2

plpop = SimplePlanetPopulation(targets_ideal)
plpop._train_trap(N=1000);


Planet: Depth trained: R2=0.997533383133
Planet: Duration trained: R2=0.992470176005
Planet: Slope trained: R2=0.997980697933

In [46]:
# This is the expected number of detections: number of stars * average transit probability
p_ecl = (1./plpop.aR) * (1+plpop.radius_B/plpop.radius_A)  # R*/a corrected for grazing eclipses
n_exp = len(targets) * p_ecl.mean()
n_exp


Out[46]:
181.25221272971726

In [47]:
n_obs = [len(plpop.observe(new_orbits=True, regr_trap=True).query('n_pri > 0')) for i in range(100)]

In [48]:
%matplotlib inline
import matplotlib.pyplot as plt

plt.hist(n_obs, histtype='step', lw=3);
plt.axvline(n_exp, color='r', ls=':', lw=3)


Out[48]:
<matplotlib.lines.Line2D at 0x126823d90>

In [49]:
np.mean(n_obs)


Out[49]:
182.09999999999999

In [2]:
from peerless.catalogs import TargetCatalog, EBCatalog

In [4]:
ebs = EBCatalog()

In [7]:
ebs.df.columns


Out[7]:
Index([u'#KIC', u'period', u'period_err', u'bjd0', u'bjd0_err', u'morph',
       u'GLon', u'GLat', u'kmag', u'Teff', u'SC', u'ETV', u'Unnamed: 12'],
      dtype='object')

In [9]:
len(ebs.df.query('period > 1000'))


Out[9]:
10

In [ ]: