In [1]:
import pandas as pd
from exosyspop.populations import TRILEGAL_BGBinaryPopulation

targets = pd.read_hdf('targets.h5')
bgstars = pd.read_hdf('bgstars.h5').query('m_ini > 0.11')

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

pop = TRILEGAL_BGBinaryPopulation(targets, bgstars)

import logging
rootLogger = logging.getLogger()


WARNING:root:Deprecation Warning: 'triangle' has been renamed to 'corner'. This shim should continue to work but you should use 'import corner' in new code. https://github.com/dfm/corner.py
WARNING:root:PyMultiNest not available; only emcee fits will be possible.
WARNING:root:progressbar not imported

In [2]:
pop = TRILEGAL_BGBinaryPopulation(targets.sample(1000), bgstars.sample(1000), fB=1)

In [3]:
rB = pop.radius_B


BGEB: dmag regressor trained, R2=0.911817563285
BGEB: qR regressor trained, R2=0.76634227607

In [4]:
rootLogger.setLevel(logging.INFO)
pop._train_trap(N=200);
rootLogger.setLevel(logging.DEBUG)


BGEB: Depth trained: R2=0.997155648551
BGEB: Duration trained: R2=0.992380949106
BGEB: Slope trained: R2=0.989042134265

In [5]:
obs = pop.observe(regr_trap=True)

In [6]:
pop.save('test', overwrite=True)

In [7]:
import cPickle as pickle
pickle.dump(pop, open('test.pkl', 'wb'))

In [8]:
pop = pickle.load(open('test.pkl', 'rb'))

In [9]:
print(pop.params['fB'])
pop._generate_binaries()
pop.params['fB']


DEBUG:root:Setting params {}.
DEBUG:root:old params = None
DEBUG:root:Generating binary companions for 863 stars...
1
Out[9]:
1

In [10]:
pop.radius_B[:10]


Out[10]:
array([   0.15716966,    0.22931597,    0.14225803,  119.05026062,
          0.44244812,    0.23416311,    0.31517727,    0.55514619,
          0.49646648,    0.39489863])

In [11]:
rB[:10]


Out[11]:
array([   0.14651767,    0.20932919,    0.22894365,  115.90336165,
          0.49478899,    0.18239524,    0.28059119,    0.31287778,
          0.67566143,    0.53647009])

In [2]:
%matplotlib inline
rootLogger.setLevel(logging.INFO)
pop._train_pipelines(n_jobs=8, plot=True)
pop._train_trap(N=1000, plot=True);


BGEB: dmag regressor trained, R2=0.975228863924
BGEB: qR regressor trained, R2=0.908807218686
BGEB: Depth trained: R2=0.999520898496
BGEB: Duration trained: R2=0.997345061377
BGEB: Slope trained: R2=0.992131678434

In [4]:
from copy import deepcopy

pop2 = deepcopy(pop)

In [5]:
pop._generate_binaries()
pop2._generate_binaries(use_ic=True)

In [8]:
import matplotlib.pyplot as plt
import numpy as np

ok = np.isfinite(pop.stars.radius_B)
plt.plot(pop.stars.mass_B[ok], np.log10(pop.stars.radius_B[ok]), 'o', ms=1, mew=1)
ok = np.isfinite(pop2.stars.radius_B)
plt.figure()
plt.plot(pop2.stars.mass_B[ok], np.log10(pop2.stars.radius_B[ok]), 'o', ms=1, mew=1)


Out[8]:
[<matplotlib.lines.Line2D at 0x7f947150c150>]

In [7]:
pop.stars.query('radius_B == -100')[['mass_A', 'radius_A', 'mass_B', 'radius_B']]


Out[7]:
mass_A radius_A mass_B radius_B
1536 0.15215 0.195592 0.115682 -100
150565 0.11577 0.130621 0.099075 -100
2268 2.21863 4.200070 1.958928 -100
3434 4.15192 0.022123 3.452282 -100
113358 0.17211 0.181810 0.099116 -100
140075 0.12470 0.137609 0.099162 -100
62600 0.82567 0.780939 0.099180 -100
171448 0.11797 0.129300 0.099207 -100
169170 0.83517 0.020049 0.830359 -100
172439 0.83641 0.017556 0.332649 -100
3551 3.98248 0.022532 3.576042 -100
3955 0.14114 0.166740 0.140213 -100
2184 0.12455 0.157538 0.099513 -100
158566 0.11051 0.119926 0.099419 -100
1039 0.12009 0.175577 0.100736 -100
6967 0.11181 0.137548 0.099067 -100
6128 3.68339 0.023623 3.126509 -100
109522 0.23575 0.230909 0.099234 -100
3843 0.15814 0.181859 0.156931 -100
170614 0.26133 0.250789 0.099150 -100
147178 0.21801 0.217998 0.099020 -100
119448 0.13956 0.152614 0.099226 -100
147536 0.12959 0.143054 0.099227 -100
151455 0.14816 0.162772 0.099148 -100
84123 0.15898 0.176151 0.099127 -100
219 0.12598 0.259935 0.104221 -100
132619 0.13826 0.149473 0.099154 -100
126606 0.19261 0.198863 0.099047 -100
45699 4.11491 0.021973 3.885189 -100
608 0.12694 0.201147 0.100592 -100
129789 0.13220 0.146666 0.099148 -100
142616 0.12865 0.141553 0.099129 -100
599 2.04829 1.821419 0.356555 -100
1170 0.13981 0.197462 0.099813 -100
167332 0.17557 0.179862 0.099505 -100
2274 0.46156 0.402558 0.460876 -100
3576 0.16183 0.185885 0.159139 -100
4221 3.59878 0.024004 3.552550 -100
68711 4.09112 0.021910 3.902132 -100
494 0.17000 0.219249 0.100284 -100
136838 0.18372 0.191114 0.099028 -100
112112 0.19476 0.199510 0.099127 -100
172633 0.82399 1.856415 0.100625 -100
9984 3.94065 0.021727 3.634498 -100
88609 0.21807 0.227778 0.099051 -100
48706 0.30744 0.292479 0.251239 -100
83673 0.23823 0.237527 0.099028 -100
148288 0.14134 0.155005 0.099226 -100
36071 4.09106 0.021709 3.221704 -100
151230 0.21114 0.213059 0.099168 -100
117062 0.16740 0.178070 0.099077 -100
11353 1.93466 0.737932 1.683871 -100
122081 0.13934 0.152669 0.099013 -100
107711 0.11892 0.131021 0.099172 -100

In [3]:
obs_pop = pop.get_N_observed(N=5000, new_orbits=True, query='T14_pri < 2 or T14_sec < 2')

In [4]:
obs_pop.trap_corner(range=[(0,0.8), (-5,0), (2,10)]);


WARNING:root:Too few points to create valid contours

In [5]:
pop.save('bgpop', overwrite=True)

In [6]:
pop = TRILEGAL_BGBinaryPopulation.load('bgpop')

In [7]:
obs = pop.observe(regr_trap=True)

In [9]:
rootLogger.setLevel(logging.INFO)
%timeit pop.observe(new=True, use_ic=True, regr_trap=True)


1 loops, best of 3: 805 ms per loop

In [10]:
%matplotlib inline

import matplotlib.pyplot as plt
obs = pop.observe(new=True)
plt.hist(obs.b_target.values, bins=20);
plt.xlabel('Galactic Latitude')
plt.ylabel('N');



In [ ]: