In [1]:
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

The goal here is to simultaneously model the stellar binary population and the planet population. We can make the assumption that the same stellar binary population creates both the detected EBs and false positives.

I want to parametrize the stellar companion period distribution. Stellar companions as a whole are well modeled by a lognormal distribution, but there's this bump of short-period companions that are caused by dynamical evolution in triple systems (e.g., Figure 12 of the latest Kepler EB paper). For the purposes of single-transit exploration, it's fine to ignore that short-period bump. And since the maximum of the solar-type star companion period distribution is at a period of about 250 years (Duchene & Kraus), the period range we care about should be able to be modeled as a power law.

$\Gamma_P \propto P^\alpha$

For vespa as designed for standard Kepler candidates, I synthesized new populations for each individual candidate. Part of the reason for this is that the integration time smears out the transit shape such that the shape is not simply scalable with period. However, for long periods it might become negligible. I should test this.


In [9]:
# OK, first make a model of a star
# Give it sun-like spectroscopic properties and a Jmag of 10
from isochrones import BinaryStarModel
from isochrones.dartmouth import Dartmouth_Isochrone
#mod = BinaryStarModel(Dartmouth_Isochrone, Teff=(5700,100), logg=(4.5,0.1), feh=(0.0,0.1), J=(10,0.05))
#mod.fit()

In [10]:
#mod.save_hdf('test_binpop.h5')
mod = BinaryStarModel.load_hdf('test_binpop.h5')

In [5]:
%matplotlib inline

mod.triangle();



In [90]:
# OK, now make an EBPopluation
from vespa import EBPopulation

try:
    rootLogger.setLevel(logging.INFO)
except:
    pass

N = 20000
P = np.logspace(0,3,N)
np.random.shuffle(P)

#ebpop = EBPopulation(period=2, starmodel=mod, n=N)
#ebpop.fit_trapezoids()
#ebpop.save_hdf('ebpop.h5', overwrite=True);
ebpop = EBPopulation.load_hdf('ebpop.h5')

In [12]:
ebpop.stars.columns


Out[12]:
Index([u'level_0', u'H_mag', u'H_mag_A', u'J_mag', u'J_mag_A', u'K_mag',
       u'K_mag_A', u'Kepler_mag', u'Kepler_mag_A', u'Teff_A', u'age_A',
       u'g_mag', u'g_mag_A', u'i_mag', u'i_mag_A', u'logL_A', u'logg_A',
       u'mass_A', u'r_mag', u'r_mag_A', u'radius_A', u'z_mag', u'z_mag_A',
       u'H_mag_B', u'J_mag_B', u'K_mag_B', u'Kepler_mag_B', u'Teff_B',
       u'age_B', u'g_mag_B', u'i_mag_B', u'logL_B', u'logg_B', u'mass_B',
       u'r_mag_B', u'radius_B', u'z_mag_B', u'q', u'distance', u'distmod',
       u'Kepler_mag_1', u'Kepler_mag_2', u'Kepler_mag_tot', u'P', u'T14_pri',
       u'T14_sec', u'T23_pri', u'T23_sec', u'b_pri', u'b_sec', u'dpri',
       u'dsec', u'ecc', u'fluxfrac_1', u'fluxfrac_2', u'inc', u'switched',
       u'u1_1', u'u1_2', u'u2_1', u'u2_2', u'w', u'mass_1', u'radius_1',
       u'mass_2', u'radius_2', u'depth', u'duration', u'slope', u'secdepth',
       u'secondary'],
      dtype='object')

Let's list out the most likely relevant predictor features:

  • T14
  • T23
  • d [theoretical depth]
  • b
  • u1
  • u2
  • k

In [27]:
from vespa import PopulationSet
popset = PopulationSet.load_hdf('K06563.01/popset.h5')

In [28]:
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
from sklearn.svm import SVR
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline

pop = popset['pl']
#pop = ebpop
ok = (pop.stars.depth > 0).values
stars = pop.stars[ok] #.query('depth > 0')

texp = 1626/86400.

# Define features
sec = stars.secondary
P = stars.P
T14 = sec*stars.T14_sec + ~sec*stars.T14_pri
T23 = sec*stars.T23_sec + ~sec*stars.T23_pri
T14 += texp
T23 = np.clip(T23-texp, 0, np.inf)
tau = (T14 - T23)/2.
#tau[tau < texp] = texp
#slope_anal = T14/tau
#slope_anal[slope_anal]
k = sec*(stars.radius_A/stars.radius_B) + ~sec*(stars.radius_B/stars.radius_A)
b = sec*(stars.b_sec/k) + ~sec*stars.b_pri
logd = np.log10(sec*stars.dsec + ~sec*stars.dpri)
u1 = sec*stars.u1_2 + ~sec*stars.u1_1
u2 = sec*stars.u2_2 + ~sec*stars.u2_1
#fluxfrac = sec*stars.fluxfrac_2 + ~sec*stars.fluxfrac_1
dilution = pop.dilution_factor[ok]

#X = np.array([P,T14,tau,k,b,logd,u1,u2,dilution,sec]).T
X = pop.eclipse_features
#X = np.concatenate([pop.eclipse_features for pop in popset.poplist])
inds = np.arange(len(X))
itest = inds % 5 == 0
itrain = ~itest
Xtest = X[itest, :]
Xtrain = X[itrain, :]

# Define targets
duration = stars.duration
logdepth = np.log10(stars.depth)
slope = stars.slope

Yslope = np.array(slope)
Ylogd = np.array(logdepth)
Ydur = np.array(duration)

#Ydur = np.concatenate([pop.eclipse_targets[0] for pop in popset.poplist])
#Ylogd = np.concatenate([pop.eclipse_targets[1] for pop in popset.poplist])
#Yslope = np.concatenate([pop.eclipse_targets[2] for pop in popset.poplist])

#Ydur, Ylogd, Yslope = pop.eclipse_targets

Yp = []
Yt = []
scores = []
for Y in [Yslope, Ylogd, Ydur]:
    Ytest = Y[itest]
    Ytrain = Y[itrain]

    #regr = LinearRegression()
    regr = RandomForestRegressor(n_estimators=10)
    #regr = SVR(kernel='rbf', C=1e3, gamma=0.1)
    pipeline = Pipeline([('scale', StandardScaler()), ('regression', regr)])
    #pipeline = Pipeline([('regression',regr)])

    pipeline.fit(Xtrain, Ytrain)
    Yp.append(pipeline.predict(Xtest))
    Yt.append(Ytest)
    scores.append(pipeline.score(Xtest, Ytest))

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

fig, axes = plt.subplots(1, 3, figsize=(12,4))

slope_diff = (np.abs(Yt[0]-Yp[0]))/Yt[0]
bad = slope_diff > 0.2
bad = Yt[2] > 1.5

for ax,(yt,yp),score in zip(axes, zip(Yt,Yp), scores):
    ax.plot(yt, yp, '.')
    ax.plot(yt[bad], yp[bad], 'r.')
    ax.plot(yt, yt, 'k-')
    ax.annotate(score, xy=(0.1,0.9), xycoords='axes fraction')
maxslope = 10
axes[0].set_xlim(xmax=maxslope)
axes[0].set_ylim(ymax=maxslope);
#print(np.where(bad))


Out[35]:
(2.0, 10)

In [39]:
cols = ['radius_A', 'radius_B', 'T14_pri', 'T14_sec', 'secondary',
       'depth','duration','slope', 'ecc','w', 'b_pri', 'b_sec', 'dsec', 'dpri',
       'fluxfrac_1', 'fluxfrac_2']
print(Yt[2][bad])
print(Yp[2][bad])
stars.loc[bad, cols]
stars.query('duration > 1.5')[cols]


[ 1.85281197  2.09691969  1.61232918  1.50614649  1.54878772  1.8024449
  1.72368622  1.57092277  1.6629183   2.50072026  2.13112211  1.50631624
  2.24020562  1.56277548  2.43319483  2.04733906  2.16401866]
[ 1.81855087  2.11243112  1.61198635  1.50292121  1.54180831  1.82715068
  1.71493802  1.55645278  1.6674519   2.62539421  2.13414597  1.48460837
  2.25488647  1.57375232  2.34575701  2.03003845  2.13495619]
Out[39]:
radius_A radius_B T14_pri T14_sec secondary depth duration slope ecc w b_pri b_sec dsec dpri fluxfrac_1 fluxfrac_2
40 4.573967 0.174722 1.761674 0.310367 False 0.001574 1.852812 6.303075 0.799368 292.507175 0.543634 0.081779 0 0.001653 1 0
257 4.601809 0.201664 2.625574 0.287306 False 0.002148 2.718631 7.036737 0.816038 271.426305 0.391806 0.039749 0 0.002265 1 0
467 5.514155 0.347429 1.500417 0.652070 False 0.004549 1.530279 7.182760 0.566166 314.921030 0.207445 0.088716 0 0.004803 1 0
784 4.969558 0.206363 1.763692 0.461902 False 0.001873 1.817029 7.085714 0.628748 275.797214 0.504497 0.116219 0 0.001978 1 0
928 5.220454 0.272442 1.515706 0.619163 False 0.003155 1.560685 7.135696 0.519006 305.917295 0.048766 0.019903 0 0.003324 1 0
959 4.598232 0.289544 1.806609 0.404470 False 0.004610 1.882153 6.002146 0.700419 245.564462 0.166370 0.036808 0 0.004813 1 0
1344 5.683509 0.308738 1.455554 0.780744 False 0.003331 1.516484 5.988455 0.352365 248.052768 0.388368 0.197040 0 0.003482 1 0
1693 4.994927 0.214176 1.660239 0.550776 False 0.002088 1.719797 7.051715 0.525037 280.022677 0.306767 0.097665 0 0.002200 1 0
1759 4.678084 0.280904 1.555140 0.528653 False 0.004208 1.623355 5.997901 0.532966 248.092714 0.111423 0.037690 0 0.004391 1 0
2835 4.328207 0.182752 2.010746 0.348845 False 0.002068 2.096920 6.979337 0.721160 257.756559 0.062320 0.010793 0 0.002175 1 0
2870 5.164955 0.234277 1.564051 0.451966 False 0.001998 1.612329 5.544279 0.672034 280.068975 0.748078 0.152307 0 0.002090 1 0
3236 4.688394 0.191865 1.582464 0.505735 False 0.001931 1.649670 6.979560 0.558596 248.703404 0.176144 0.055556 0 0.002032 1 0
3277 4.577891 0.219924 1.748202 0.453958 False 0.002669 1.806861 7.092859 0.608517 255.734135 0.120286 0.031041 0 0.002810 1 0
3437 5.110270 0.292120 1.639016 0.595487 False 0.003794 1.713646 5.980931 0.503054 289.997520 0.191363 0.068513 0 0.003960 1 0
3954 4.601809 0.299446 1.504625 0.339692 False 0.004439 1.526637 6.045773 0.780965 241.610321 0.612825 0.113683 0 0.004665 1 0
4808 4.579377 0.169566 1.620152 0.338408 False 0.001588 1.713744 6.761691 0.784720 303.226502 0.124524 0.025829 0 0.001669 1 0
5203 4.787821 0.312904 1.565247 0.577879 False 0.004968 1.623262 6.042221 0.478345 256.163178 0.156562 0.057253 0 0.005188 1 0
5454 5.447219 0.230277 1.745321 0.553026 False 0.002005 1.811834 6.973471 0.605031 243.571132 0.374967 0.111435 0 0.002115 1 0
5464 5.608193 0.281241 1.496579 0.797225 False 0.002916 1.542931 7.123655 0.342380 297.063201 0.004000 0.002131 0 0.003071 1 0
5637 5.087478 0.199091 2.116959 0.373407 False 0.001660 2.224128 6.314296 0.761425 284.898486 0.528342 0.080407 0 0.001744 1 0
5889 4.923777 0.328919 1.945256 0.364659 False 0.005204 2.029237 5.973688 0.788351 240.438268 0.113162 0.021097 0 0.005434 1 0
5976 4.735605 0.287795 1.666154 0.542816 False 0.004312 1.737543 6.006456 0.510746 267.033150 0.101220 0.032841 0 0.004499 1 0
6103 4.572463 0.171986 1.478728 0.317833 False 0.001638 1.569129 6.717095 0.816661 307.458431 0.126323 0.026957 0 0.001722 1 0
6208 4.947087 0.319724 2.168859 0.392481 False 0.004538 2.216951 6.053855 0.730747 275.582191 0.523633 0.082676 0 0.004762 1 0
6326 5.127905 0.240590 2.189304 0.409634 False 0.002471 2.259621 7.057919 0.719806 257.114661 0.369591 0.064793 0 0.002607 1 0
7237 4.465927 0.247497 1.904980 0.378125 False 0.003424 1.979895 5.993951 0.698423 263.497027 0.441770 0.079822 0 0.003582 1 0
7508 5.061854 0.237998 1.775155 0.448838 False 0.002483 1.834446 7.018547 0.681140 295.241304 0.366708 0.087109 0 0.002620 1 0
7559 5.227153 0.234195 2.133459 0.400285 False 0.002316 2.222564 6.967345 0.755544 294.575598 0.160053 0.029684 0 0.002438 1 0
7638 4.873293 0.317144 1.546560 0.556120 False 0.004817 1.595779 6.046773 0.540352 244.998193 0.341639 0.117024 0 0.005039 1 0
7802 4.873797 0.257552 1.945684 0.352675 False 0.003122 2.024745 6.361925 0.781599 294.088282 0.410494 0.068625 0 0.003281 1 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
13263 5.164955 0.247634 1.713929 0.604027 False 0.002660 1.770762 7.098053 0.488104 259.880257 0.103906 0.036459 0 0.002801 1 0
13470 5.143754 0.318790 1.795987 0.415986 False 0.004444 1.841192 7.146831 0.751086 236.212673 0.052436 0.012131 0 0.004687 1 0
13869 5.447219 0.211858 1.624152 0.699174 False 0.001757 1.699542 6.933688 0.411562 284.632027 0.023365 0.010056 0 0.001847 1 0
14028 5.068001 0.235767 1.671369 0.511496 False 0.002347 1.712437 7.123339 0.584916 280.700004 0.505445 0.136494 0 0.002482 1 0
14211 4.779032 0.204363 2.044234 0.386711 False 0.002117 2.131122 6.977691 0.723941 289.281228 0.111459 0.020968 0 0.002227 1 0
14249 4.406395 0.174031 1.510781 0.481081 False 0.001785 1.575021 6.975173 0.537992 258.612877 0.256824 0.079465 0 0.001878 1 0
14270 4.834475 0.236665 1.906896 0.351888 False 0.002772 1.980390 7.003762 0.786634 241.291379 0.113637 0.020850 0 0.002918 1 0
14426 5.111548 0.297034 1.443510 0.683959 False 0.003912 1.506316 5.996528 0.368598 261.081092 0.212858 0.099218 0 0.004084 1 0
15130 5.243593 0.314614 1.478092 0.439818 False 0.004162 1.523383 7.062158 0.758542 225.656171 0.087857 0.026060 0 0.004388 1 0
15447 5.474103 0.323737 1.982041 0.435667 False 0.003558 2.030177 5.554998 0.727217 257.619497 0.678952 0.115002 0 0.003724 1 0
15684 4.794291 0.291685 1.646350 0.516936 False 0.004224 1.707872 6.024493 0.552048 282.705929 0.326401 0.097901 0 0.004415 1 0
15732 4.978990 0.190680 1.557189 0.371732 False 0.001656 1.626105 7.467810 0.787727 232.910804 0.310909 0.070957 0 0.001754 1 0
16076 5.579774 0.265768 2.171801 0.525570 False 0.002584 2.240206 7.099555 0.629796 279.463810 0.278978 0.065179 0 0.002724 1 0
16524 5.246472 0.293505 1.637058 0.575230 False 0.003565 1.676385 7.159808 0.574044 238.895663 0.269864 0.092002 0 0.003762 1 0
16610 4.788172 0.285546 2.076923 0.343278 False 0.003608 2.105403 5.997796 0.776075 274.753376 0.673960 0.086114 0 0.003798 1 0
17234 4.684636 0.250138 1.442488 0.590413 False 0.003268 1.509533 5.968044 0.434388 268.636285 0.303095 0.119554 0 0.003413 1 0
17807 5.325988 0.241038 1.947476 0.474158 False 0.002229 2.006745 7.010956 0.671569 285.986998 0.494925 0.106590 0 0.002356 1 0
17883 4.665704 0.307111 1.619213 0.525691 False 0.005064 1.681422 6.036392 0.551612 292.359988 0.046230 0.014996 0 0.005287 1 0
18234 4.971630 0.199211 1.500294 0.516406 False 0.001817 1.564842 6.922658 0.608563 303.717493 0.332285 0.108940 0 0.001914 1 0
18383 4.892776 0.209478 1.787007 0.512924 False 0.002108 1.856022 7.028305 0.560525 268.028332 0.203671 0.057413 0 0.002219 1 0
18707 4.478457 0.207034 2.206148 0.336487 False 0.002399 2.274908 7.096773 0.750176 269.183446 0.370002 0.052833 0 0.002531 1 0
18743 4.993919 0.196463 2.013771 0.387350 False 0.001622 2.114285 5.902673 0.732712 270.805639 0.623762 0.096252 0 0.001698 1 0
18869 7.006343 0.290315 1.652666 0.993477 False 0.001989 1.721097 6.993755 0.276679 244.757565 0.090138 0.054053 0 0.002093 1 0
18926 4.961585 0.195948 1.523603 0.395980 False 0.001524 1.562775 6.437539 0.720897 252.007626 0.729202 0.135989 0 0.001608 1 0
18961 5.065603 0.250183 2.356521 0.401482 False 0.002811 2.433195 7.096210 0.723531 259.760757 0.167951 0.028252 0 0.002961 1 0
19423 4.648362 0.181520 1.732154 0.433901 False 0.001770 1.814833 6.916431 0.649263 247.517819 0.062922 0.015735 0 0.001861 1 0
19566 4.897444 0.275600 1.984972 0.425306 False 0.003450 2.047339 6.032810 0.684975 268.693302 0.520337 0.097348 0 0.003615 1 0
19750 4.789839 0.211011 2.511608 0.332841 False 0.002247 2.616929 6.981032 0.787839 256.780482 0.102618 0.013534 0 0.002365 1 0
19782 5.164955 0.210307 2.042994 0.458554 False 0.001925 2.136207 6.941713 0.677421 290.762234 0.018616 0.004178 0 0.002024 1 0
19986 5.556989 0.248543 2.088813 0.566757 False 0.002299 2.164019 7.057454 0.583066 263.675049 0.208269 0.055443 0 0.002421 1 0

86 rows × 16 columns


In [82]:
from vespa_transitutils import traptransit

i = 223
sec = False
pars = pop.eclipse_pars(i, secondary=sec)
ts,fs = pop.eclipse(i, secondary=sec, tol=1e-4)
plt.plot(ts, fs)
print(pars)
trap = np.array(pop.eclipse_trapfit(i, secondary=sec))
plt.plot(ts, traptransit(ts, trap))
print(trap)


{'p0': 0.86306415918215096, 'b': 1.8627470202155669, 'frac': 0.59385411516802433, 'u1': 0.26944782276065254, 'u2': 0.33440621135968279, 'P': 579.72891170000003, 'aR': 1009.5217465660928, 'w': 136.02299358768306, 'ecc': 0.46249102806300202}
[  2.31474649e-02   8.09568353e-08   8.53068121e+00]

In [42]:
from vespa.populations import PopulationSet

#popset = PopulationSet.load_hdf('K06705.01/popset.h5')
popset = PopulationSet.load_hdf('K00087.01/popset.h5')

pop = popset['beb_px2']

In [44]:
i = 45
print(pop.stars.ix[i])
sec = False
pars = pop.eclipse_pars(i, secondary=sec)
ts,fs = pop.eclipse(i, secondary=sec, tol=1e-4)
plt.plot(ts, fs)
print(pars)
trap = np.array(pop.eclipse_trapfit(i, secondary=sec))
plt.plot(ts, traptransit(ts, trap))
print(trap)


level_0                     45
H_mag                 4.838111
H_mag_A               4.838352
J_mag                    5.775
J_mag_A               5.775453
K_mag                 4.526646
K_mag_A               4.526832
Kepler_mag            10.02762
Kepler_mag_A          10.03872
Teff_A                    3501
age_A                     9.45
g_mag                 12.71985
g_mag_A               12.80954
i_mag                 9.274986
i_mag_A               9.280609
logL_A                3.353908
logg_A                    2.51
mass_A                 1.63939
r_mag                 11.57823
r_mag_A               11.62303
radius_A              150.3123
z_mag                 7.986582
z_mag_A               7.988259
H_mag_B               13.97494
J_mag_B               14.22438
K_mag_B               13.94222
Kepler_mag_B          15.00894
Teff_B                6149.662
age_B                     9.45
g_mag_B               15.47191
                      ...     
Kepler_mag_tot        10.02762
P                     579.7289
T14_pri               20.67738
T14_sec                      0
T23_pri                16.0516
T23_sec                      0
b_pri                0.9644953
b_sec                 1.009736
dpri              5.052169e-05
dsec                0.00308578
ecc                  0.0393035
fluxfrac_1           0.9898265
fluxfrac_2          0.01017348
inc                      69.03
switched                 False
u1_1                 0.2659696
u1_2                 0.2772069
u2_1                  0.415704
u2_2                 0.3188489
w                     35.66469
mass_1                 1.63939
radius_1              150.3123
mass_2                1.211394
radius_2               1.29688
Rsky                  5.124852
depth                      NaN
duration                   NaN
slope                      NaN
secdepth          5.052169e-05
secondary                 True
Name: 45, dtype: object
{'p0': 0.0086279071643035644, 'b': 0.96449527806925894, 'frac': 0.98982651755440421, 'u1': 0.26596959999999997, 'u2': 0.41570399999999996, 'P': 579.72891170000003, 'aR': 2.7610543024302281, 'w': 35.66469120914099, 'ecc': 0.039303499078153406}
[  2.06329726e+01   4.82427292e-05   6.87720487e+00]

In [26]:
!scp -r tmorton@della:/tigress/tmorton/kepler/fpp/K06563.01 .


signal.png                                    100%   45KB  44.7KB/s   00:00    
results.txt                                   100%  276     0.3KB/s   00:00    
popset.h5                                     100%  115MB  10.5MB/s   00:11    
dartmouth_triangle_binary_physical.png        100% 1374KB   1.3MB/s   00:00    
eb.png                                        100%   52KB  51.9KB/s   00:00    
dartmouth_starmodel_triple.h5                 100% 3670KB   3.6MB/s   00:00    
lhoodcache.dat                                100% 1075     1.1KB/s   00:00    
dartmouth_triangle_binary_observed.png        100%  884KB 884.2KB/s   00:00    
dartmouth_mags_single.png                     100%   23KB  22.6KB/s   00:00    
dartmouth_mags_binary.png                     100%   22KB  22.5KB/s   00:00    
dartmouth_starmodel_binary.h5                 100% 2792KB   2.7MB/s   00:00    
dartmouth_triangle_single_physical.png        100%  370KB 370.4KB/s   00:00    
beb_Px2.png                                   100%   60KB  59.9KB/s   00:00    
pl.png                                        100%   66KB  66.1KB/s   00:00    
dartmouth_single_results.txt                  100%  336     0.3KB/s   00:00    
FPPsummary.png                                100%  108KB 108.4KB/s   00:00    
calcfpp.log                                   100%   25KB  25.3KB/s   00:00    
dartmouth_starmodel_single.h5                 100% 1563KB   1.5MB/s   00:01    
dartmouth_triangle_single_observed.png        100%  852KB 852.1KB/s   00:00    
dartmouth_mags_triple.png                     100%   22KB  22.4KB/s   00:00    
starfit.log                                   100%  486     0.5KB/s   00:00    
beb.png                                       100%   95KB  94.8KB/s   00:00    
heb.png                                       100%   51KB  51.3KB/s   00:00    
single-IS.ptprob                              100% 4297KB   4.2MB/s   00:00    
single-phys_live.points                       100%  169KB 169.0KB/s   00:00    
binary-resume.dat                             100%  225     0.2KB/s   00:00    
single-IS.points                              100%   13MB  12.6MB/s   00:01    
triple-resume.dat                             100%  225     0.2KB/s   00:00    
single-properties.json                        100%  294     0.3KB/s   00:00    
binary-.txt                                   100% 2456KB   2.4MB/s   00:00    
single-live.points                            100%  165KB 165.0KB/s   00:00    
triple-IS.iterinfo                            100%  529KB 529.1KB/s   00:00    
binary-IS.ptprob                              100% 2081KB   2.0MB/s   00:00    
binary-IS.points                              100% 7077KB   6.9MB/s   00:01    
triple-summary.txt                            100% 1738     1.7KB/s   00:00    
single-.txt                                   100% 3000KB   2.9MB/s   00:01    
single-post_equal_weights.dat                 100% 1173KB   1.2MB/s   00:00    
binary-properties.json                        100%  294     0.3KB/s   00:00    
binary-ev.dat                                 100% 3571KB   3.5MB/s   00:01    
single-stats.dat                              100%  983     1.0KB/s   00:00    
triple-.txt                                   100% 2751KB   2.7MB/s   00:00    
triple-ev.dat                                 100% 4014KB   3.9MB/s   00:01    
single-IS.iterinfo                            100%  667KB 667.0KB/s   00:00    
binary-phys_live.points                       100%  196KB 196.3KB/s   00:00    
triple-IS.ptprob                              100% 2301KB   2.3MB/s   00:01    
binary-live.points                            100%  192KB 192.4KB/s   00:00    
triple-stats.dat                              100% 1237     1.2KB/s   00:00    
single-summary.txt                            100% 1290     1.3KB/s   00:00    
triple-live.points                            100%  220KB 219.7KB/s   00:00    
triple-properties.json                        100%  294     0.3KB/s   00:00    
triple-post_equal_weights.dat                 100% 1157KB   1.1MB/s   00:00    
binary-post_equal_weights.dat                 100% 1023KB   1.0MB/s   00:00    
triple-phys_live.points                       100%  224KB 223.6KB/s   00:00    
triple-IS.points                              100% 8742KB   8.5MB/s   00:01    
single-ev.dat                                 100% 4013KB   3.9MB/s   00:01    
binary-summary.txt                            100% 1514     1.5KB/s   00:00    
binary-IS.iterinfo                            100%  528KB 528.1KB/s   00:00    
single-resume.dat                             100%  225     0.2KB/s   00:00    
binary-stats.dat                              100% 1110     1.1KB/s   00:00    
heb_Px2.png                                   100%   46KB  46.3KB/s   00:00    
dartmouth_triangle_triple_physical.png        100% 1726KB   1.7MB/s   00:00    
trsig.pkl                                     100%   15MB  14.7MB/s   00:01    
fpp.ini                                       100%  218     0.2KB/s   00:00    
eb_Px2.png                                    100%   46KB  46.2KB/s   00:00    
star.ini                                      100%  162     0.2KB/s   00:00    
dartmouth_triangle_triple_observed.png        100%  859KB 859.5KB/s   00:00    

In [83]:
import sys
sys.path.append('/u/tdm/repositories/peerless/prediction')
sys.path.append('/u/tdm/repositories/peerless')

from sims import BinaryPopulation
from targets import targets

pop = BinaryPopulation(targets)

In [7]:
%prun obs = pop.observe('period > 5', new=True)


 

In [4]:
obs[['period','trap_dur_pri','T14_pri','trap_dur_sec','T14_sec',
     'trap_depth_pri','d_pri','trap_depth_sec','d_sec','flux_ratio']]


Out[4]:
period trap_dur_pri T14_pri trap_dur_sec T14_sec trap_depth_pri d_pri trap_depth_sec d_sec flux_ratio
468 9.852426 0.176193 0.191730 0.181772 0.191730 0.152430 0.156064 0.011765 0.011796 0.011937
777 34.385981 0.161995 0.173258 NaN 0.000000 0.128637 0.133421 NaN 0.000000 0.832501
879 25.053061 0.104596 0.116075 0.251390 0.269953 0.379952 0.390746 0.032947 0.034046 0.140927
955 44.205914 0.102258 0.105461 NaN 0.000000 0.027294 0.028579 NaN 0.000000 0.025366
1772 10.896998 NaN 0.000000 0.123232 0.130755 NaN 0.000000 0.009188 0.009524 0.021374
3427 8.505182 0.146859 0.160178 0.151533 0.160178 0.226040 0.234992 0.029748 0.030633 0.034107
5005 16.902246 0.151561 0.165178 0.155992 0.165178 0.213943 0.222017 0.077234 0.080244 0.090303
5375 5.298162 0.149564 0.165681 0.152925 0.165681 0.381232 0.388975 0.037441 0.037668 0.039142
5429 6.446318 0.056542 0.052389 0.039960 0.031863 0.002897 0.003220 0.000038 0.000048 0.004263
5529 197.938745 0.144608 0.151870 NaN 0.000000 0.083273 0.086043 NaN 0.000000 0.002964
5715 425.606934 0.293937 0.322151 0.879249 0.947117 0.217777 0.222570 0.005433 0.005585 0.010143
6287 9.412458 0.061726 0.059515 0.061627 0.059515 0.002199 0.002383 0.001414 0.001533 0.295350
7227 47.968484 NaN 0.000000 0.081309 0.080607 NaN 0.000000 0.000524 0.000557 0.015553
7388 10.637024 0.249748 0.276337 0.178041 0.198815 0.269789 0.278541 0.252300 0.257542 0.582751
8277 57.869444 0.360933 0.421130 0.268318 0.300943 0.458968 0.462271 0.270079 0.271589 0.372852
12870 76.620176 NaN 0.000000 0.223796 0.241331 NaN 0.000000 0.021145 0.022001 0.042879
14784 5.268019 NaN 0.000000 0.036578 0.026926 NaN 0.000000 0.013043 0.017433 0.602780
15250 10.250655 0.124213 0.137590 0.321456 0.351344 0.366116 0.373843 0.072844 0.074671 0.088280
15964 70.809941 0.286064 0.307238 0.293139 0.307238 0.133638 0.137532 0.018251 0.018279 0.018619
18057 25.190583 0.179261 0.199172 0.194982 0.213386 0.320973 0.324885 0.059875 0.060305 0.064175
18148 71.720035 0.128151 0.138483 NaN 0.000000 0.196483 0.200998 NaN 0.000000 0.011258
19996 63.474731 0.224393 0.241968 0.202402 0.217278 0.084484 0.086673 0.015605 0.016234 0.245860
21156 14.510556 0.100261 0.103249 NaN 0.000000 0.066673 0.069421 NaN 0.000000 0.002791
21707 22.176736 NaN 0.000000 0.057924 0.056086 NaN 0.000000 0.000952 0.001027 0.004070
22117 150.224775 0.392785 0.428204 0.386645 0.406332 0.121270 0.124275 0.005389 0.005409 0.005438
22505 106.222774 0.718213 0.802001 0.268839 0.296122 0.330153 0.333651 0.101882 0.102618 0.114353
23514 32.885984 0.044567 0.041831 NaN 0.000000 0.307078 0.377807 NaN 0.000000 0.590561
23657 19.397441 0.247833 0.272648 0.256455 0.272648 0.232835 0.238046 0.045076 0.045126 0.047259
24064 10.071119 0.208078 0.229533 0.188842 0.209201 0.271789 0.280313 0.165935 0.171413 0.487560
24092 5.812844 0.137576 0.149424 0.144299 0.152972 0.186683 0.194119 0.035952 0.037236 0.059049
... ... ... ... ... ... ... ... ... ... ...
171613 44.456103 0.052058 0.045527 NaN 0.000000 0.033122 0.024956 NaN 0.000000 0.683753
171941 24.144502 NaN 0.000000 0.085114 0.083652 NaN 0.000000 0.002263 0.002274 0.002279
173199 65.425782 0.243542 0.268265 0.248106 0.268265 0.209694 0.215592 0.067444 0.068488 0.073523
175753 835.011688 0.177990 0.191350 NaN 0.000000 0.083469 0.086276 NaN 0.000000 0.315627
176389 283.259605 0.359144 0.399090 0.411572 0.450890 0.307492 0.317418 0.041719 0.042598 0.051616
176798 19.617576 0.120945 0.126494 0.120805 0.126494 0.009748 0.010215 0.010315 0.010810 0.464478
177214 31.979613 0.136381 0.141292 0.094889 0.101920 0.027277 0.026539 0.217702 0.228994 0.477852
177431 40.649693 0.211061 0.227224 0.209191 0.219686 0.093644 0.096018 0.006393 0.006447 0.006489
178147 25.206719 NaN 0.000000 0.055233 0.047841 NaN 0.000000 0.003349 0.003390 0.003401
180614 865.645217 0.274657 0.292950 NaN 0.000000 0.038082 0.039309 NaN 0.000000 0.064277
180646 8.346275 0.164061 0.179900 0.163932 0.179098 0.167524 0.172458 0.157452 0.161947 0.533729
180809 70.873484 0.047901 0.044778 NaN 0.000000 0.328924 0.398379 NaN 0.000000 0.167525
181638 147.176018 0.465262 0.520772 0.467210 0.514095 0.321386 0.326302 0.040815 0.040954 0.042703
182002 6.174086 0.144472 0.159168 0.055353 0.054355 0.391993 0.402892 0.150383 0.158193 0.187921
183499 83.854331 0.466028 0.506235 0.211141 0.221081 0.101617 0.104293 0.010445 0.010491 0.010603
183846 5.205989 0.158384 0.161287 0.162068 0.161287 0.062577 0.064479 0.002862 0.002869 0.002877
184738 6.081253 0.074868 0.082939 0.219172 0.239324 0.534185 0.575014 0.082253 0.084362 0.270371
186047 8.277092 NaN 0.000000 0.054542 0.051480 NaN 0.000000 0.001771 0.001973 0.009445
186520 33.439669 0.056721 0.056254 NaN 0.000000 0.154320 0.167033 NaN 0.000000 0.087787
190868 176.557241 0.260025 0.276108 0.267057 0.279559 0.031197 0.032180 0.001278 0.001318 0.001670
190968 6.286980 0.044113 0.039070 NaN 0.000000 0.281585 0.351678 NaN 0.000000 0.040084
191556 943.833893 0.460606 0.516236 0.784653 0.857529 0.338822 0.342784 0.043102 0.043959 0.051301
192806 52.165567 0.149563 0.156876 NaN 0.000000 0.041779 0.043187 NaN 0.000000 0.003471
194017 5.597499 0.073086 0.073307 NaN 0.000000 0.026592 0.028158 NaN 0.000000 0.828032
194900 589.073896 1.028098 1.144801 1.010715 1.144801 0.641052 0.644618 0.177783 0.179137 0.551305
194943 6.629341 0.121294 0.128895 0.121501 0.128895 0.148326 0.153859 0.039566 0.041018 0.164026
195252 46.334197 0.219458 0.236773 0.207895 0.222281 0.095993 0.098485 0.024141 0.024735 0.402674
196387 5.494595 0.053546 0.049338 0.086881 0.088099 0.001298 0.001431 0.003504 0.003572 0.003585
198725 9.189774 0.157190 0.171440 0.157956 0.171440 0.326268 0.335779 0.055858 0.057422 0.111887
199452 36.319125 NaN 0.000000 0.087205 0.089126 NaN 0.000000 0.015931 0.016479 0.292333

210 rows × 10 columns


In [10]:
def get_features(df, secondary=False, texp=1626./86400):
    if secondary:
        T14 = df.T14_sec
        T23 = df.T23_sec
        k = 1./df.k
        b = b_sec/df.k
        logd = np.log10(df.d_sec)
        sec = np.ones(len(df))
    else:
        T14 = df.T14_pri
        T23 = df.T23_pri
        k = df.k
        b = df.b_pri
        logd = np.log10(df.d_pri)
        sec = np.zeros(len(df))
    u1 = 0.394*np.ones(len(df))
    u2 = 0.296*np.ones(len(df))
    T14 += texp
    T23 = np.clip(T23 - texp, 0, T14)
    tau = (T14 - T23)/2.
    return np.array([T14, tau, k, b, logd, u1, u2, sec]).T

In [15]:
obs = pop.observe('period > 5')
X = get_features(obs)

In [18]:
obs.columns


Out[18]:
Index([u'period', u'ecc', u'w', u'inc', u'a', u'b_pri', u'b_sec', u'k', u'tra',
       u'occ', u'd_pri', u'd_sec', u'T14_pri', u'T14_sec', u'T23_pri',
       u'T23_sec', u'dataspan', u'dutycycle', u'n_pri', u'n_sec'],
      dtype='object')

Most expensive parts of population simulations are exact isochrone interpolations of radius and magnitudes. If we can make those analytic we're in good shape for fast population simulations.


In [22]:
from isochrones.dartmouth import Dartmouth_Isochrone
dar = Dartmouth_Isochrone()

In [25]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

N = 1000
M1 = np.random.random(N) * 0.2 + 0.9
age = 9.4
feh = 0.0
q = np.random.random(N) * 0.8 + 0.2
M2 = q*M1
qrad = dar.radius(M2, age, feh)/dar.radius(M1, age, feh)
dmag = dar.mag['Kepler'](M2, age, feh) - dar.mag['Kepler'](M1, age, feh)

plt.hist(qrad, histtype='step', normed=True);
plt.hist(q, histtype='step', normed=True);
plt.figure()
plt.hist(dmag, histtype='step', normed=True);
plt.figure()
plt.plot(qrad, dmag, '.');



In [41]:
dar.tri.points.shape


Out[41]:
(133803, 3)

In [66]:
%timeit pipeline.predict(Xtest)


10 loops, best of 3: 108 ms per loop

In [61]:
len(Xtest)


Out[61]:
26796

In [1]:
import sys
sys.path.append('/u/tdm/repositories/peerless/prediction')
sys.path.append('/u/tdm/repositories/peerless')

from exosyspop.populations import KeplerBinaryPopulation
from targets import targets

pop = KeplerBinaryPopulation(targets, fB=0.4)


WARNING:root:progressbar not imported
/u/tdm/anaconda/lib/python2.7/site-packages/pandas/core/indexing.py:426: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item] = s
/u/tdm/anaconda/lib/python2.7/site-packages/pandas/core/indexing.py:266: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[key] = _infer_fill_value(value)

In [2]:
%matplotlib inline
pop._train_pipelines(plot=False, n_estimators=10)


flux_ratio regressor trained, R2=0.998692919612
q regressor trained, R2=0.999685406979

In [3]:
pop._train_trap('period > 1', N=10000, plot=True)


Depth trained: R2=0.996301450635
Duration trained: R2=0.998649233479
Slope trained: R2=0.998482171879

In [4]:
%timeit obs = pop.observe('period > 1', new=True)


1 loops, best of 3: 307 ms per loop

In [5]:
obs = pop.observe('period > 1', new=True)
obs.columns


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

In [9]:
cols = [u'trap_dur_pri', u'trap_depth_pri',
       u'trap_slope_pri', u'trap_dur_sec', u'trap_depth_sec',
       u'trap_slope_sec', u'trap_dur_pri_regr', u'trap_depth_pri_regr',
       u'trap_slope_pri_regr', u'trap_dur_sec_regr', u'trap_depth_sec_regr',
       u'trap_slope_sec_regr']
obs[cols].head(10)


Out[9]:
trap_dur_pri trap_depth_pri trap_slope_pri trap_dur_sec trap_depth_sec trap_slope_sec trap_dur_pri_regr trap_depth_pri_regr trap_slope_pri_regr trap_dur_sec_regr trap_depth_sec_regr trap_slope_sec_regr
0 0.239038 0.412134 2.308972 0.240705 0.242977 2.331064 0.237942 0.409001 2.311166 0.241196 0.245492 2.347690
1 0.077337 0.011377 2.455707 NaN NaN NaN 0.077252 0.011478 2.467392 NaN NaN NaN
2 0.217307 0.483581 2.290205 0.217715 0.143016 2.407427 0.216435 0.482941 2.327393 0.219577 0.139535 2.537586
3 0.063120 0.433251 2.236296 0.605520 0.434209 2.165807 0.065279 0.460401 2.227356 0.649277 0.438719 2.126631
4 NaN NaN NaN 0.105287 0.011769 2.487696 NaN NaN NaN 0.104447 0.011531 2.531349
5 0.086284 0.008541 2.365813 0.102230 0.004702 2.493766 0.084614 0.008734 2.457833 0.101561 0.004763 2.550102
6 0.133096 0.076971 2.401237 0.132703 0.005394 2.565073 0.133771 0.077264 2.397083 0.133693 0.005453 2.576072
7 0.754325 0.478008 2.216172 0.663083 0.316467 2.305099 0.749489 0.475447 2.223828 0.680252 0.314464 2.309366
8 0.557297 0.327229 2.328219 1.017391 0.046374 2.578269 0.552877 0.326790 2.338417 0.951340 0.044863 2.580546
9 0.070459 0.071049 2.373565 NaN NaN NaN 0.063379 0.072056 2.370719 NaN NaN NaN

In [5]:
pop._get_trap_features(obs)


Out[5]:
array([[ 0.63305785,  0.31652892,  0.863194  ,  1.41975218, -1.24910544,
         0.        ],
       [ 0.04820633,  0.02410316,  0.27427787,  0.51382461, -1.07427943,
         0.        ],
       [ 0.08799647,  0.04399823,  0.25606408,  0.90989946, -1.40457294,
         0.        ],
       ..., 
       [ 0.13276328,  0.06638164,  1.20068818,  0.87976376, -0.94320414,
         1.        ],
       [ 0.27261741,  0.13630871,  1.09762411,  0.61677692, -0.55244244,
         1.        ],
       [ 0.16135814,  0.08067907,  1.0028066 ,  1.22626185, -0.87995975,
         1.        ]])

In [6]:
obs[['period','d_pri','trap_depth_pri','T14_pri','trap_dur_pri','T14_sec','trap_dur_sec','d_sec','trap_depth_sec','k']].head(10)


Out[6]:
period d_pri trap_depth_pri T14_pri trap_dur_pri T14_sec trap_dur_sec d_sec trap_depth_sec k
0 9.284161 0.276665 0.268533 0.161611 0.146807 0.156408 0.142760 0.074953 0.072836 0.737258
1 12.118656 0.000000 NaN 0.000000 NaN 0.122476 0.116788 0.120255 0.115012 0.883374
2 12.665687 0.226575 0.221597 0.200106 0.182955 0.191297 0.178138 0.015692 0.015473 0.467011
3 7.575174 0.156732 0.152519 0.180037 0.165309 0.180107 0.165448 0.147742 0.143784 0.970655
4 13.198069 0.000000 NaN 0.000000 NaN 0.031075 0.041724 0.000771 0.000718 0.148406
5 326.306176 0.322200 0.319430 0.779991 0.695147 0.803616 0.729869 0.090470 0.090271 0.560279
6 32.554474 0.211078 0.205091 0.294440 0.268598 0.294440 0.269244 0.158181 0.153777 0.873239
7 9.373557 0.463029 0.457680 0.164172 0.144292 0.349760 0.310336 0.266078 0.261082 0.752584
8 15.599678 0.000000 NaN 0.000000 NaN 0.070368 0.069736 0.009977 0.009352 0.541858
9 8.669757 0.195425 0.190090 0.209922 0.192012 0.209922 0.193203 0.039264 0.037531 0.526578

In [6]:
%prun obs = pop.observe('period > 5', fit_trap=True)


 

In [4]:
len(obs)


Out[4]:
223

In [4]:
%timeit pop.get_necl('period > 5', new=True)


10 loops, best of 3: 144 ms per loop

In [11]:
pop.get_necl('period > 5', new=True)


Out[11]:
258.31809238791408

In [1]:
import pandas as pd
store = pd.HDFStore('mod13_bg.h5')
bgstars = store['df']
store.close()

In [15]:
len(bgstars)/(3600.**2)


Out[15]:
0.013578549382716049

In [2]:
from exosyspop.populations import TRILEGAL_BinaryPopulation
TRILEGAL_BinaryPopulation.binary_features# += ('logL', 'logTe', 'logg')


WARNING:root:progressbar not imported
Out[2]:
('mass_A', 'age', 'feh', 'logL', 'logTe', 'logg')

In [3]:
bgpop = TRILEGAL_BinaryPopulation(bgstars)

In [4]:
%matplotlib inline
Xtest, dmag, qR = bgpop._train_pipelines(plot=True, n_estimators=10, n_jobs=8)


dmag regressor trained, R2=0.977571123278
qR regressor trained, R2=0.973418334553

In [5]:
bgpop._train_trap(N=1000)


Depth trained: R2=0.997573237358
Duration trained: R2=0.997601091174
Slope trained: R2=0.989084583987

In [13]:
len(bgpop.stars)/3600.**2


Out[13]:
0.013578549382716049

In [8]:
obs = bgpop.observe(regr_trap=True, dataspan=0.5, dutycycle=1.)
len(obs)


Out[8]:
366

In [9]:
query = 'period < 2 and (tra | occ)'
len(bgpop.stars.query(query))


Out[9]:
380

In [10]:
obs[['period', 'n_pri', 'n_sec', 'phase_sec','T14_pri','T14_sec','ecc','d_pri','d_sec']]


Out[10]:
period n_pri n_sec phase_sec T14_pri T14_sec ecc d_pri d_sec
0 2.386754 0 1 0.153243 0.000000 0.032153 0.714769 0.000000 1.738811e-01
1 3.080028 1 0 0.653488 0.012684 0.000000 0.625209 0.004569 0.000000e+00
2 1.331911 1 0 0.510784 0.048716 0.048867 0.017012 0.216598 1.148730e-01
3 1.346107 1 0 0.508204 0.155221 0.152597 0.016314 0.363977 2.302159e-01
4 1.233456 1 0 0.342074 0.066654 0.055070 0.388354 0.123600 4.511426e-04
5 1.306261 0 1 0.380359 0.076060 0.074204 0.221278 0.125822 6.113915e-03
6 14.470715 1 0 0.485185 0.063764 0.000000 0.241650 0.029462 0.000000e+00
7 3.120052 1 0 0.363606 0.022258 0.000000 0.515158 0.080556 0.000000e+00
8 1.493044 0 1 0.146828 0.000000 0.005810 0.830224 0.000000 3.628580e-03
9 2.252249 0 1 0.465507 0.000000 0.010395 0.915272 0.000000 2.222669e-01
10 1.070564 0 1 0.492063 0.052752 0.053094 0.013216 0.248177 1.793272e-01
11 2.129921 0 1 0.480762 0.144858 0.144859 0.030224 0.479373 4.150628e-01
12 15.447851 0 1 0.500000 0.000000 0.000000 0.000000 0.440768 1.700114e-08
13 2.213071 1 0 0.500000 0.000000 0.000000 0.000000 0.715966 1.645545e-09
14 2.221869 1 0 0.706942 0.044064 0.041209 0.331482 0.987408 2.274344e-06
15 7.661035 1 0 0.418385 0.040127 0.040663 0.128891 0.043621 5.172559e-02
16 1.613330 0 1 0.851655 0.000000 0.030438 0.595492 0.000000 7.297081e-03
17 1.047584 0 1 0.143142 0.032959 0.024280 0.684867 0.030234 2.319858e-01
18 6.964061 1 0 0.811230 0.061331 0.000000 0.693614 0.068506 0.000000e+00
19 2.623323 1 0 0.661865 0.040433 0.045698 0.276291 0.208067 1.237380e-01
20 1.138692 0 1 0.518492 0.035284 0.037551 0.042873 0.437903 4.447736e-01
21 1.202267 0 1 0.530726 0.053367 0.236771 0.640883 0.507420 3.509736e-01
22 1.785957 1 0 0.571760 0.024857 0.021692 0.127850 0.055161 2.246695e-02
23 11.157523 1 0 0.536077 0.125697 0.120088 0.064938 0.240366 1.584521e-01
24 1.387728 1 0 0.331673 0.036373 0.000000 0.568960 0.039242 0.000000e+00
25 14.411190 1 0 0.992346 0.009291 0.000000 0.968102 0.023061 0.000000e+00
26 1.091185 0 1 0.494535 0.138251 0.139827 0.035896 0.131347 2.695015e-02
27 1.809973 0 1 0.067191 0.000000 0.018390 0.805543 0.000000 9.861223e-02
28 2.083305 0 1 0.500000 0.000000 0.000000 0.000000 0.512858 1.109556e-08
29 5.783091 0 1 0.316075 0.000000 0.072162 0.365113 0.000000 2.008858e-02
... ... ... ... ... ... ... ... ... ...
44 3.735230 1 0 0.289737 0.008821 0.000000 0.469372 0.000597 0.000000e+00
45 1.247010 1 0 0.519264 0.042813 0.035235 0.172018 0.122409 2.218938e-01
46 1.632923 0 1 0.302307 0.036087 0.054493 0.370225 0.434403 3.128337e-01
47 1.144009 1 0 0.511783 0.023017 0.023380 0.104821 0.047233 1.172733e-01
48 1.486104 0 1 0.285879 0.000000 0.046262 0.587307 0.000000 3.611439e-02
49 6.124009 1 0 0.547158 0.169857 0.186784 0.088050 0.344257 3.087442e-02
50 2.343393 0 1 0.463150 0.101820 0.126970 0.124118 0.327647 2.817851e-02
51 2.192144 1 0 0.875428 0.039854 0.028651 0.658600 0.162874 2.725003e-01
52 5.233805 1 0 0.186330 0.131709 0.086894 0.545897 0.517315 1.500816e-01
53 1.011735 0 1 0.330545 0.000000 0.018527 0.530918 0.000000 3.951835e-03
54 2.397655 0 1 0.499730 0.040954 0.041340 0.003787 0.036586 2.763001e-02
55 3.114052 0 1 0.756196 0.029313 0.051395 0.496032 0.386930 2.766032e-01
56 3.919621 0 1 0.501247 0.069520 0.069669 0.002282 0.367545 3.178596e-01
57 1.076705 0 1 0.784697 0.000000 0.030938 0.476649 0.000000 2.097713e-03
58 1.675427 1 0 0.681362 0.043319 0.035179 0.310221 0.102611 1.317040e-02
59 1.492827 1 0 0.779919 0.021696 0.000000 0.669195 0.166163 0.000000e+00
60 1.162566 1 0 0.761632 0.058672 0.034833 0.483273 0.505391 4.099096e-01
61 1.186351 0 1 0.365597 0.029768 0.027621 0.236829 0.095104 1.320238e-01
62 1.207230 1 0 0.882842 0.016568 0.000000 0.732687 0.107297 0.000000e+00
63 2.400252 1 0 0.967807 0.068819 0.047461 0.861211 0.514848 2.230194e-01
64 1.159364 0 1 0.506029 0.048083 0.050104 0.024618 0.353333 3.102082e-01
65 1.790196 0 1 0.509005 0.028573 0.022908 0.034526 0.022230 7.268177e-03
66 1.647799 1 0 0.492358 0.009859 0.029066 0.040403 0.000230 3.315599e-03
67 1.073755 1 1 0.959296 0.013741 0.026658 0.849934 0.368198 2.173136e-01
68 4.151675 1 0 0.566991 0.128210 0.126311 0.105712 0.475761 1.601097e-01
69 1.349050 0 1 0.559744 0.000000 0.035211 0.775398 0.000000 4.001933e-02
70 3.859490 0 1 0.639142 0.109100 0.109464 0.220366 0.496021 1.079054e-01
71 1.073801 1 0 0.500000 0.000000 0.000000 0.000000 0.000527 1.942675e-06
72 1.167160 1 0 0.174565 0.067540 0.044728 0.566586 0.270347 4.870992e-02
73 2.018144 1 0 0.818240 0.023630 0.024507 0.599942 0.234405 1.733429e-02

74 rows × 9 columns


In [6]:
import matplotlib.pyplot as plt
bgpop.params = bgpop.default_params
bgpop.ecc_empirical = False
bgpop._generate_orbits()
plt.hist(bgpop.ecc);



In [51]:
import matplotlib.pyplot as plt
import numpy as np
N = 10000
p = bgpop._sample_period(N)
ecc = bgpop._sample_ecc(N, p)
plt.plot(np.log10(p),ecc,'o', ms=0.5, alpha=0.3)
#plt.xlim(xmax=1)
plt.figure()

from scipy.stats import beta, rayleigh
x = np.arange(0,1,0.01)
a, b = 2.12, 3.09
a, b = 0.8, 2.0
sigma = 0.05
plt.plot(x, beta(a, b).pdf(x))
plt.plot(x, rayleigh(0,sigma).pdf(x))
plt.hist(ecc[p>100], histtype='step', normed=True);



In [53]:
plt.hist(np.random.rayleigh(0.1, 1000));



In [52]:
from vespa.stars.utils import rochelobe
rochelobe(1)


Out[52]:
0.37892051838045632

In [42]:
beta.fit(ecc[p>100])


Out[42]:
(0.79081257758622914,
 2.0611690998511678,
 -2.1075692259152315e-31,
 1.2219401803476591)

In [9]:
%timeit bgpop._generate_binaries()


1 loops, best of 3: 333 ms per loop

In [7]:
%timeit bgpop._generate_binaries(use_ic=True)


1 loops, best of 3: 1.08 s per loop

In [10]:
%prun obs = bgpop.observe(dataspan=4*365, dutycycle=1., new_orbits=True)


 

In [21]:
%prun bgpop._generate_orbits()


 

In [23]:
len(obs.query('period > 30 and n_pri > 1'))


Out[23]:
0

In [1]:
import pyximport; pyximport.install();

In [2]:
from exosyspop.distributions import sample_powerlaw
from exosyspop.utils import draw_powerlaw, draw_powerlaw2

In [3]:
%timeit x1 = sample_powerlaw(-2, 1., 10., 100000)
%timeit x2 = draw_powerlaw2(-2, 1., 10., 100000)
%timeit x3 = draw_powerlaw(-2, (1,10), 100000)


100 loops, best of 3: 3.15 ms per loop
The slowest run took 107.19 times longer than the fastest. This could mean that an intermediate result is being cached 
1 loops, best of 3: 2.92 ms per loop
100 loops, best of 3: 2.41 ms per loop

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

plt.hist(x1, bins=50, histtype='step');
plt.hist(x2, bins=50, histtype='step');



In [17]:
import numpy as np

In [18]:
np.random.poisson?

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

from exosyspop.populations import TRILEGAL_BGBinaryPopulation
pop = TRILEGAL_BGBinaryPopulation()

x = np.arange(5, 20, 0.01)
plt.plot(x, pop.rho_bg(x))
plt.ylim(ymin=0);
print(pop.rho_bg(5))
print(pop.rho_bg(20))


WARNING:root:progressbar not imported
0.05
0.005

In [2]:
ls


chains/     exosyspop/         K06563.01/       LICENSE      test_binpop.h5
demo.ipynb  Exploration.ipynb  K06705.01/       mod13_bg.h5
ebpop.h5    K00087.01/         kepchiplocs.txt  README.md

In [3]:
mv mod13_bg.h5 bgstars.h5

In [ ]:


In [74]:
B = 15/np.log(10)
print B


6.51441722855

In [75]:
0.05/np.exp(-5/B)


Out[75]:
0.1077217345015942

In [1]:
from exosyspop.utils import Pbg_kepler

In [37]:
print(Pbg_kepler(17,20,r=1))
print(Pbg_kepler(17, 5, r=1))


2.1466832 4.4688848 0.05997392
0.0211038992992
2.1466832 4.4688848 0.05997392
0.190300266065

In [38]:
0.02*0.5**2


Out[38]:
0.005

In [12]:
ls /scr/depot0/tdm/kepler/fpp/starfields/


kepler_starfield_10.0.h5  kepler_starfield_17.0.h5  kepler_starfield_24.0.h5
kepler_starfield_11.0.h5  kepler_starfield_18.0.h5  kepler_starfield_3.0.h5
kepler_starfield_12.0.h5  kepler_starfield_19.0.h5  kepler_starfield_4.0.h5
kepler_starfield_13.0.h5  kepler_starfield_20.0.h5  kepler_starfield_6.0.h5
kepler_starfield_14.0.h5  kepler_starfield_2.0.h5   kepler_starfield_7.0.h5
kepler_starfield_15.0.h5  kepler_starfield_22.0.h5  kepler_starfield_8.0.h5
kepler_starfield_16.0.h5  kepler_starfield_23.0.h5  kepler_starfield_9.0.h5

In [13]:


In [18]:
len(stars2)/3600.**2


Out[18]:
0.008102391975308642

In [20]:
len(stars24)/3600**2.


Out[20]:
0.02640570987654321

In [22]:
%%file kepchiplocs.txt
2 289.518116 50.83687
3 285.892454 49.202271
4 282.515934 47.450492
6 295.693679 49.873734
7 291.928416 48.484211
8 288.404053 46.860029
9 285.043609 45.201626
10 281.899401 43.425678
11 297.24426 45.823265
12 294.122350 45.996224
13 290.665452 44.484019
14 287.380312 42.871357
15 284.284433 41.188504
16 299.637740 44.853876
17 296.113142 43.521260
18 292.755219 42.079530
19 289.546528 40.531098
20 286.492399 38.912346
22 297.983923 40.968464
23 294.714081 39.625267
24 291.568009 38.149180


Writing kepchiplocs.txt

In [23]:
i, ra, dec = np.loadtxt('kepchiplocs.txt', unpack=True)

In [24]:
from astropy.coordinates import SkyCoord

b = [SkyCoord(r,d,unit='deg').galactic.b.deg for r,d in zip(ra,dec)]

In [27]:
for x,y in zip(i,b):
    print(x,y)


(2.0, 16.760785923916075)
(3.0, 18.325954253568938)
(4.0, 19.84824340327461)
(6.0, 12.782466441085637)
(7.0, 14.38562623484399)
(8.0, 15.898081600706428)
(9.0, 17.43740941717023)
(10.0, 18.92200838596133)
(11.0, 9.959368876674741)
(12.0, 11.96013714238006)
(13.0, 13.489932645116891)
(14.0, 15.000054246472294)
(15.0, 16.476903572181357)
(16.0, 8.01779225190079)
(17.0, 9.558153516282996)
(18.0, 11.073172247858508)
(19.0, 12.565669620897712)
(20.0, 14.036423310724205)
(22.0, 7.101492541670327)
(23.0, 8.626363214892734)
(24.0, 10.119301326176997)

In [28]:
stars4 = pd.read_hdf('/scr/depot0/tdm/kepler/fpp/starfields/kepler_starfield_4.0.h5')
stars22 = pd.read_hdf('/scr/depot0/tdm/kepler/fpp/starfields/kepler_starfield_22.0.h5')

In [29]:
len(stars4)/3600.**2


Out[29]:
0.006443441358024692

In [30]:
len(stars22)/3600.**2


Out[30]:
0.038075462962962964

In [ ]: