In [1]:
import pandas as pd
from exosyspop.populations import BinaryPopulation
from exosyspop.populations import TRILEGAL_BGBinaryPopulation
from exosyspop.populations import KeplerBinaryPopulation, PoissonPlanetPopulation
from exosyspop.populations import PopulationMixture

targets = pd.read_hdf('targets.h5')
bgstars = pd.read_hdf('bgstars.h5')

# Sanitize dtypes of targets DataFrame
for c in targets.columns:
    if targets[c].dtype == object:
        targets.loc[:,c] = targets.loc[:,c].astype(str)


import logging
rootLogger = logging.getLogger()


WARNING:root:progressbar not imported

In [2]:
#ebpop = KeplerBinaryPopulation(targets)
#bgpop = TRILEGAL_BGBinaryPopulation(targets, bgstars)
#plpop = PoissonPlanetPopulation(targets)
#pops = PopulationMixture([ebpop,bgpop,plpop])
#pops.train_trap(N=3000)
#pops.save('mixture',overwrite=True)
Output of the above looks something like this: EB: dmag regressor trained, R2=0.999513626177 EB: qR regressor trained, R2=0.999491735974 EB: Depth trained: R2=0.998175053436 EB: Duration trained: R2=0.998201581488 EB: Slope trained: R2=0.980592493379 BGEB: dmag regressor trained, R2=0.974429415002 BGEB: qR regressor trained, R2=0.803087923403 BGEB: Depth trained: R2=0.992483653949 BGEB: Duration trained: R2=0.998340561679 BGEB: Slope trained: R2=0.992107589244 Planet: Depth trained: R2=0.997409599459 Planet: Duration trained: R2=0.990374194846 Planet: Slope trained: R2=0.995512760619

In [3]:
pops = PopulationMixture.load('mixture')

In [4]:
%timeit pops.observe(regr_trap=True)


1 loops, best of 3: 830 ms per loop

In [5]:
pops.params


Out[5]:
{'N_pl': 1.0,
 'Rp_max': 20,
 'Rp_min': 0.75,
 'alpha': -1.6,
 'beta': -0.75,
 'beta_a': 0.8,
 'beta_b': 2.0,
 'fB': 0.4,
 'gamma': 0.3,
 'mu_logp': 2.3979400086720375,
 'period_max': 10000.0,
 'period_min': 1,
 'qmin': 0.1,
 'rho_20': 0.005,
 'rho_5': 0.05,
 'sig_logp': 2.3}

In [6]:
obs = pops.observe(regr_trap=True)
print(len(obs))
obs.groupby('population').count()


1803
Out[6]:
T14_pri T14_sec T23_pri T23_sec a aR b_pri b_sec b_target d_pri ... phase_sec target_mag tra trap_depth_pri_regr trap_depth_sec_regr trap_dur_pri_regr trap_dur_sec_regr trap_slope_pri_regr trap_slope_sec_regr w
population
BGEB 333 333 333 333 333 333 333 333 333 333 ... 333 333 333 237 223 237 223 237 223 333
EB 561 561 561 561 561 561 561 561 561 561 ... 561 0 561 461 442 461 442 461 442 561
Planet 909 909 909 909 909 909 909 909 909 909 ... 909 0 909 735 0 735 0 735 0 909

3 rows × 32 columns


In [7]:
obs.columns


Out[7]:
Index([u'T14_pri', u'T14_sec', u'T23_pri', u'T23_sec', u'a', u'aR', u'b_pri',
       u'b_sec', u'b_target', u'd_pri', u'd_sec', u'dataspan', u'dutycycle',
       u'ecc', u'flux_ratio', u'host', u'inc', u'k', u'n_pri', u'n_sec',
       u'occ', u'period', u'phase_sec', u'population', u'target_mag', u'tra',
       u'trap_depth_pri_regr', u'trap_depth_sec_regr', u'trap_dur_pri_regr',
       u'trap_dur_sec_regr', u'trap_slope_pri_regr', u'trap_slope_sec_regr',
       u'w'],
      dtype='object')

In [8]:
pops['BGEB'].rho_bg(10) # background stellar density at galactic latitude b=10


Out[8]:
0.023207944168063894

In [9]:
pops.set_params(rho_5=1)
pops['BGEB'].rho_bg(10)


Out[9]:
0.17099759466766973

In [10]:
obs = pops.observe(regr_trap=True)
print(len(obs))
obs.groupby('population').count()


3774
Out[10]:
T14_pri T14_sec T23_pri T23_sec a aR b_pri b_sec b_target d_pri ... phase_sec target_mag tra trap_depth_pri_regr trap_depth_sec_regr trap_dur_pri_regr trap_dur_sec_regr trap_slope_pri_regr trap_slope_sec_regr w
population
BGEB 2303 2303 2303 2303 2303 2303 2303 2303 2303 2303 ... 2303 2303 2303 1535 1551 1535 1551 1535 1551 2303
EB 527 527 527 527 527 527 527 527 527 527 ... 527 0 527 437 455 437 455 437 455 527
Planet 944 944 944 944 944 944 944 944 944 944 ... 944 0 944 773 0 773 0 773 0 944

3 rows × 32 columns


In [11]:
pops.set_params(N_pl=4)
obs = pops.observe(regr_trap=True)
print(len(obs))
obs.groupby('population').count()


6633
Out[11]:
T14_pri T14_sec T23_pri T23_sec a aR b_pri b_sec b_target d_pri ... phase_sec target_mag tra trap_depth_pri_regr trap_depth_sec_regr trap_dur_pri_regr trap_dur_sec_regr trap_slope_pri_regr trap_slope_sec_regr w
population
BGEB 2343 2343 2343 2343 2343 2343 2343 2343 2343 2343 ... 2343 2343 2343 1612 1591 1612 1591 1612 1591 2343
EB 530 530 530 530 530 530 530 530 530 530 ... 530 0 530 443 441 443 441 443 441 530
Planet 3760 3760 3760 3760 3760 3760 3760 3760 3760 3760 ... 3760 0 3760 3052 0 3052 0 3052 0 3760

3 rows × 32 columns


In [12]:
pops.set_params(fB=1.)
obs = pops.observe(regr_trap=True)
print(len(obs))
obs.groupby('population').count()


10933
Out[12]:
T14_pri T14_sec T23_pri T23_sec a aR b_pri b_sec b_target d_pri ... phase_sec target_mag tra trap_depth_pri_regr trap_depth_sec_regr trap_dur_pri_regr trap_dur_sec_regr trap_slope_pri_regr trap_slope_sec_regr w
population
BGEB 5915 5915 5915 5915 5915 5915 5915 5915 5915 5915 ... 5915 5915 5915 4030 4006 4030 4006 4030 4006 5915
EB 1287 1287 1287 1287 1287 1287 1287 1287 1287 1287 ... 1287 0 1287 1045 1045 1045 1045 1045 1045 1287
Planet 3731 3731 3731 3731 3731 3731 3731 3731 3731 3731 ... 3731 0 3731 3053 0 3053 0 3053 0 3731

3 rows × 32 columns


In [13]:
pops.reset_params()
obs = pops.observe(regr_trap=True)
print(len(obs))
obs.groupby('population').count()


1789
Out[13]:
T14_pri T14_sec T23_pri T23_sec a aR b_pri b_sec b_target d_pri ... phase_sec target_mag tra trap_depth_pri_regr trap_depth_sec_regr trap_dur_pri_regr trap_dur_sec_regr trap_slope_pri_regr trap_slope_sec_regr w
population
BGEB 314 314 314 314 314 314 314 314 314 314 ... 314 314 314 208 225 208 225 208 225 314
EB 504 504 504 504 504 504 504 504 504 504 ... 504 0 504 426 413 426 413 426 413 504
Planet 971 971 971 971 971 971 971 971 971 971 ... 971 0 971 792 0 792 0 792 0 971

3 rows × 32 columns


In [ ]: