Skip to content

Commit

Permalink
added stao.ipynb and exoplanets.py for adding exoplanet systems
Browse files Browse the repository at this point in the history
  • Loading branch information
dtamayo committed Nov 8, 2017
1 parent 04f671c commit 8cd4cfb
Show file tree
Hide file tree
Showing 3 changed files with 8,836 additions and 0 deletions.
35 changes: 35 additions & 0 deletions exoplanets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pandas as pd
import rebound
import numpy as np

def add_planet(sim, planet, T1):
P = planet['pl_orbper']/365.25
e = planet['pl_orbeccen']
pomega = planet['pl_orbeccen']/(2.*np.pi)
t_transit = (planet['pl_tranmid']-T1)/365.25 # time of transit relative to first planet, defined as t=0
for el in [P, e, pomega, t_transit]:
if np.isnan(el) is True:
el = 0.
sim.integrate(t_transit)
sim.add(P=P, e=e, pomega=pomega, theta=0) # add new planet at true longitude=0 (transiting)

def make_sim(df, name):
system = df[df['pl_hostname'] == name]
if system.shape[0] == 0:
raise AttributeError("System {0} not found in NASA exoplanet archive".format(name))

p1 = system.iloc[0]
starmass = p1['st_mass']
sim = rebound.Simulation()
sim.G = 4*np.pi**2
sim.add(m=starmass)

T1 = p1['pl_tranmid'] # time of mid-transit for first planet
for i, planet in system.iterrows():
add_planet(sim, planet, T1)

Ps = [sim.particles[i].P for i in range(1, sim.N)]
Pmin = np.array(Ps).min()
sim.integrator="whfast"
sim.dt = Pmin*0.07
return sim
Loading

0 comments on commit 8cd4cfb

Please sign in to comment.