In [3]:
%matplotlib inline
import numpy as np
import pandas as pd
import time
import matplotlib.pyplot as plt
from vespa.transitsignal import TransitSignal_ASCII
from vespa.populations import HEBPopulation, EBPopulation
from vespa.populations import BEBPopulation, PlanetPopulation
from vespa.populations import PopulationSet
from vespa.transit_basic import MAInterpolationFunction
from keputils import koiutils as ku
import logging
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.INFO)
In [2]:
import warnings
warnings.simplefilter("error")
warnings.simplefilter("ignore", DeprecationWarning)
In [4]:
ra,dec = ku.radec(2704)
mags = ku.KICmags(2704)
mass = (0.18, 0.04)
radius = (0.21, 0.03)
feh = (0.27, 0.13)
age = (9.7,0.1)
Teff = 3147
logg = 4.9
rprs = 0.0622
period = ku.get_property(2704,'koi_period')
colors = []
print period
In [5]:
from vespa.transitsignal import TransitSignal_ASCII
sig = TransitSignal_ASCII('2704.02.txt', P=period)
sig.MCMC(savedir='2704_chains/')
In [6]:
popset = PopulationSet('2704_retest.h5')
In [7]:
from vespa.fpp import FPPCalculation
fpp = FPPCalculation(sig, popset)
fpp.set_maxrad(2)
In [10]:
fpp.lhoodcachefile
In [9]:
%timeit fpp['heb'].stars.to_pickle('test.pkl')
In [11]:
%timeit fpp['heb'].stars.to_hdf('test.h5','df')
In [12]:
%timeit pd.read_pickle('test.pkl')
In [13]:
%timeit pd.read_hdf('test.h5','df')
In [7]:
fpp.apply_secthresh(0.001)
In [8]:
fpp.constraints
Out[8]:
In [8]:
#Uncomment to re-run simulations/fits
#n = 2e4
#t1 = time.time()
#popset = PopulationSet(ra=ra, dec=dec, period=period, mags=mags,
# n=n, mass=mass, age=age, feh=feh,
# radius=radius, rprs=rprs, colors=colors,
# trilegal_filename='2704_starfield.h5',
# Teff=Teff, logg=logg, savefile='2704_retest.h5')
#t2 = time.time()
#print '{:.2f} minutes for all simulations/fits.'.format((t2-t1)/60)
In [4]:
MAfn = MAInterpolationFunction(pmin=0.007, pmax=1/0.007, nzs=200, nps=400)
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [12]:
#uncomment below if you want to redo the simulations/fits
#n = 5e3
#hebpop = HEBPopulation(mass=mass, age=age, feh=feh, colors=[],
# period=period, mags=mags, MAfn=MAfn, n=n)
#t0 = time.time()
#hebpop.fit_trapezoids(MAfn=MAfn)
#t1 = time.time()
#print 'Fitting {} systems took {:.2f} minutes.'.format(n,(t1-t0)/60)
#hebpop.save_hdf('heb_2704.02.h5', overwrite=True)
hebpop = HEBPopulation().load_hdf('heb_2704.02.h5')
In [23]:
plt.hist(hebpop.stars['mass_A'], histtype='step', lw='3')
plt.hist(hebpop.stars['mass_B'], histtype='step', lw='3')
plt.hist(hebpop.stars['mass_C'], histtype='step', lw='3');
((hebpop.stars['mass_C'] <= hebpop.stars['mass_B']) |
(hebpop.stars['mass_C'] <= hebpop.stars['mass_A'])).sum()
Out[23]:
In [13]:
plt.hist(hebpop.dmag('K'))
Out[13]:
In [6]:
#uncomment below if you want to redo the simulations/fits
#n = 5e3
#ebpop = EBPopulation(mass=mass, age=age, feh=feh, colors=[],
# period=period, mags=mags, MAfn=MAfn, n=n)
#t0 = time.time()
#ebpop.fit_trapezoids(MAfn=MAfn)
#t1 = time.time()
#print 'Fitting {} systems took {:.2f} minutes.'.format(n,(t1-t0)/60)
#ebpop.save_hdf('eb_2704.02.h5', overwrite=True)
ebpop = EBPopulation().load_hdf('eb_2704.02.h5')
In [11]:
#rootLogger.setLevel(logging.DEBUG)
#uncomment below if you want to redo the simulations/fits
#n = 5e3
#bebpop = BEBPopulation(trilegal_filename='2704_starfield.h5',
# ra=ra, dec=dec, period=period, mags=mags,
# MAfn=MAfn, n=5e3)
#t0 = time.time()
#bebpop.fit_trapezoids(MAfn=MAfn)
#t1 = time.time()
#print 'Fitting systems took {:.2f} minutes.'.format((t1-t0)/60)
#bebpop.save_hdf('beb_2704.02.h5', overwrite=True)
bebpop = BEBPopulation().load_hdf('beb_2704.02.h5')
In [9]:
#uncomment below if you want to redo the simulations/fits
#n = 5e3
#plpop = PlanetPopulation(period=period, rprs=0.0622, mass=mass, radius=radius,
# Teff=Teff, logg=logg, n=n, MAfn=MAfn)
#t0 = time.time()
#plpop.fit_trapezoids(MAfn=MAfn)
#t1 = time.time()
#print 'Fitting systems took {:.2f} minutes.'.format((t1-t0)/60)
#plpop.save_hdf('pl_2704.02.h5', overwrite=True)
plpop = PlanetPopulation().load_hdf('pl_2704.02.h5')
In [1]:
popset = PopulationSet([ebpop, hebpop, bebpop, plpop])
popset.save_hdf('2704.02_pops.h5', overwrite=True)
In [1]:
from vespa.populations import PopulationSet
popset = PopulationSet('2704.02_pops.h5')
#popset.set_maxrad(2)
In [2]:
from vespa.transitsignal import TransitSignal_ASCII
sig = TransitSignal_ASCII('2704.02.txt', P=4.871222215)
sig.MCMC(savedir='2704_chains/')
In [3]:
from vespa.fpp import FPPCalculation
import astropy.units as u
fpp = FPPCalculation(sig, popset)
fpp['beb'].set_maxrad(2*u.arcsec)
In [4]:
from starutils.contrastcurve import ContrastCurveFromFile
cc = ContrastCurveFromFile('AO_and_apmask_2704.txt',band='K')
In [5]:
popset.apply_secthresh(1e-3)
popset.apply_cc(cc)
In [16]:
%matplotlib inline
popset['eb'].lhoodplot(sig)
popset['beb'].lhoodplot(sig)
popset['heb'].lhoodplot(sig)
popset['pl'].lhoodplot(sig)
In [6]:
%matplotlib inline
fpp.FPPsummary()
In [9]:
popset.constraints
Out[9]:
In [15]:
hebpop.Rsky
In [11]:
hebpop.priorfactors, bebpop.priorfactors
Out[11]:
In [19]:
hebpop.distance
Out[19]:
In [9]:
sig.plot(plot_trap=True)
In [22]:
pop = bebpop
pop.stars[(pop.depth <= 0) | (np.isnan(pop.depth))]
Out[22]:
In [18]:
pop = bebpop
(np.isnan(pop.depth) | (pop.depth == 0)).sum()
Out[18]:
In [8]:
sig.slopefit
Out[8]:
In [15]:
plpop.priorfactors
Out[15]:
In [14]:
bebpop.density.to('arcsec^-2').value
Out[14]:
In [13]:
bebpop.density.to('arcsec^-2').value*np.pi*64
Out[13]:
In [17]:
hebpop.prior
In [32]:
from starutils.populations import DARTMOUTH as dar
In [136]:
mass = bgpop.stars['m_ini'].copy().values
age = bgpop.stars['logAge'].copy().values
feh = bgpop.stars['[M/H]'].copy().values
pct = 0.05
mass[mass < dar.minmass*(1+pct)] = dar.minmass*(1+pct)
mass[mass > dar.maxmass*(1-pct)] = dar.maxmass*(1-pct)
age[age < dar.minage*(1+pct)] = dar.minage*(1+pct)
age[age > dar.maxage*(1-pct)] = dar.maxage*(1-pct)
feh[feh < dar.minfeh+0.05] = dar.minfeh+0.05
feh[feh > dar.maxfeh-0.05] = dar.maxfeh-0.05
n = int(1e3)
inds = np.random.randint(len(mass), size=n)
mass = mass[inds]
age = age[inds]
feh = feh[inds]
testpop = MultipleStarPopulation(mA=mass,
age=age,
feh=feh,
f_triple=0, f_binary=1,
distance=bgpop.stars['distance'],
period_long=200.)
In [145]:
print len(testpop.stars['mass_A'])
badA = np.isnan(testpop.stars['mass_A'])
print badA.sum()
len(testpop.stars.dropna(subset=['mass_A']))
Out[145]:
In [130]:
print len(testpop.stars['mass_B'])
badB = np.isnan(testpop.stars['mass_B'])
print badB.sum()
In [131]:
plt.plot(mass[badA], age[badA], '.')
Out[131]:
In [119]:
plt.plot(mass[badB], age[badB], '.')
Out[119]:
In [77]:
mass[badB]
Out[77]:
In [58]:
plt.hist(mass,bins=50)
Out[58]:
In [23]:
plt.hist(testpop.stars['mass_A'], histtype='step', normed=True)
plt.hist(testpop.stars['mass_B'], histtype='step', normed=True)
In [59]:
from scipy.interpolate import LinearNDInterpolator
In [60]:
LinearNDInterpolator?
In [146]:
bgpop._properties
Out[146]:
In [147]:
bgpop.trilegal_args
Out[147]:
In [151]:
bgpop.density
Out[151]:
In [152]:
pop
In [5]:
MAfn = MAInterpolationFunction(pmin=0.05, pmax=1/0.05)
In [6]:
bgpop = BGEBPopulation(trilegal_filename='kep22field.h5', period=200,
MAfn=MAfn, n=2e4)
In [9]:
np.arange(1e2)
Out[9]:
In [7]:
np.atleast_1d(None) * 1
In [2]:
fpp['heb']
In [ ]: