'e': float(data[pmask]['pl_orbeccen'].iloc[i]), 'omega': 0 }) # create REBOUND simulation sim = generate(objects) print(objects) # year long integrations, timestep = 1 hour sim_data = integrate(sim, objects, 20 * objects[-1]['P'], int(20 * objects[-1]['P'] * 24)) # collect the analytics from the simulation ttv_data = analyze(sim_data) #if name=='Kepler-30': # import pdb; pdb.set_trace() # save simulation data for i in range(pmask.sum()): iname = data[pmask].iloc[i].name data.at[iname, 'ttv'] = np.percentile( np.abs(ttv_data['planets'][i]['ttv']) * 24 * 60, 90) mask = (data.ttv > 1) & (data.pl_ttvflag == 1) print(data[mask].sort_values('ttv', ascending=False).get([ 'pl_name', 'pl_orbper', 'pl_orbeccen', 'st_mass', 'st_optmag', 'ttv', 'pl_disc_refname', 'pl_def_refname', 'pl_ttvflag' ]))
def get_ttv(objects, ndays=60, ttvfast=True): sim = generate(objects) sim_data = integrate(sim, objects, ndays, ndays * 24 * 2) # dt=30 minutes return analyze(sim_data, ttvfast=ttvfast)
'm': args.mass1, 'P': args.period1, 'inc': 3.14159 / 2, 'e': 0, 'omega': 0 }, { 'm': (ypred[i, 1]) * mearth / msun, 'P': ypred[i, 0], 'inc': 3.14159 / 2, 'e': ypred[i, 3], 'omega': ypred[i, 2] }, ] sim_data = generate(pred, max(data[:, 1]), int(max(data[:, 1]) * 24)) ttv_pred = analyze(sim_data) ml_error = lambda x: x # TODO nlstats = { 'marginals': [ { 'median': 0, 'sigma': 0 }, # Tmid { 'median': pred[1]['P'], 'sigma': 0 }, # P1 { 'median': pred[2]['P'],
def nbody_limits(newobj, nlstats, n=1): # TODO create wrapper? upper = np.copy(ttv) lower = np.copy(ttv) obj = copy.deepcopy(newobj) obj[2]['m'] = nlstats['marginals'][3][ 'median'] - n * nlstats['marginals'][3]['sigma'] obj[2]['omega'] = nlstats['marginals'][5][ 'median'] - n * nlstats['marginals'][5]['sigma'] sim_data = generate(obj, newobj[1]['P'] * (len(ttv) + 1), int((len(ttv) + 1) * newobj[1]['P'] * 24)) ttv_data = analyze(sim_data) for i in range(len(ttv_data['planets'][0]['ttv'])): try: upper[i] = max(upper[i], ttv_data['planets'][0]['ttv'][i]) lower[i] = min(lower[i], ttv_data['planets'][0]['ttv'][i]) except: pass obj = copy.deepcopy(newobj) obj[2]['m'] = nlstats['marginals'][3][ 'median'] - n * nlstats['marginals'][3]['sigma'] sim_data = generate(obj, newobj[1]['P'] * (len(ttv) + 1), int((len(ttv) + 1) * newobj[1]['P'] * 24)) ttv_data = analyze(sim_data) for i in range(len(ttv_data['planets'][0]['ttv'])): try: upper[i] = max(upper[i], ttv_data['planets'][0]['ttv'][i]) lower[i] = min(lower[i], ttv_data['planets'][0]['ttv'][i]) except: pass obj = copy.deepcopy(newobj) obj[2]['m'] = nlstats['marginals'][3][ 'median'] + n * nlstats['marginals'][3]['sigma'] sim_data = generate(obj, newobj[1]['P'] * (len(ttv) + 1), int((len(ttv) + 1) * newobj[1]['P'] * 24)) ttv_data = analyze(sim_data) for i in range(len(ttv_data['planets'][0]['ttv'])): try: upper[i] = max(upper[i], ttv_data['planets'][0]['ttv'][i]) lower[i] = min(lower[i], ttv_data['planets'][0]['ttv'][i]) except: pass obj = copy.deepcopy(newobj) obj[2]['m'] = nlstats['marginals'][3][ 'median'] - n * nlstats['marginals'][3]['sigma'] obj[2]['omega'] = nlstats['marginals'][5][ 'median'] + n * nlstats['marginals'][5]['sigma'] sim_data = generate(obj, newobj[1]['P'] * (len(ttv) + 1), int((len(ttv) + 1) * newobj[1]['P'] * 24)) ttv_data = analyze(sim_data) for i in range(len(ttv_data['planets'][0]['ttv'])): try: upper[i] = max(upper[i], ttv_data['planets'][0]['ttv'][i]) lower[i] = min(lower[i], ttv_data['planets'][0]['ttv'][i]) except: pass obj = copy.deepcopy(newobj) obj[2]['m'] = nlstats['marginals'][3][ 'median'] + n * nlstats['marginals'][3]['sigma'] obj[2]['omega'] = nlstats['marginals'][5][ 'median'] - n * nlstats['marginals'][5]['sigma'] sim_data = generate(obj, newobj[1]['P'] * (len(ttv) + 1), int((len(ttv) + 1) * newobj[1]['P'] * 24)) ttv_data = analyze(sim_data) for i in range(len(ttv_data['planets'][0]['ttv'])): try: upper[i] = max(upper[i], ttv_data['planets'][0]['ttv'][i]) lower[i] = min(lower[i], ttv_data['planets'][0]['ttv'][i]) except: pass obj = copy.deepcopy(newobj) obj[2]['m'] = nlstats['marginals'][3][ 'median'] + n * nlstats['marginals'][3]['sigma'] obj[2]['omega'] = nlstats['marginals'][5][ 'median'] + n * nlstats['marginals'][5]['sigma'] sim_data = generate(obj, newobj[1]['P'] * (len(ttv) + 1), int((len(ttv) + 1) * newobj[1]['P'] * 24)) ttv_data = analyze(sim_data) for i in range(len(ttv_data['planets'][0]['ttv'])): try: upper[i] = max(upper[i], ttv_data['planets'][0]['ttv'][i]) lower[i] = min(lower[i], ttv_data['planets'][0]['ttv'][i]) except: pass return upper, lower
# add longitude of ascending node }, { 'm': [2 * mjup / msun, 10 * mjup / msun], 'P': [6, 9], 'inc': [np.pi / 2 * 0.8, np.pi / 2 * 0.9], 'e': [0.05, 0.075], 'omega': [np.pi / 4, np.pi / 2], }, ] # run original simulation sim = generate(objects) sim_data = integrate(sim, objects, 180, 180 * 24) # year long integrations, timestep = 1 minute ttv_data_og = analyze(sim_data) # create a plot f = plt.figure(figsize=(9, 13)) plt.subplots_adjust() ax = [ plt.subplot2grid((6, 2), (0, 0)), plt.subplot2grid((6, 2), (1, 0)), plt.subplot2grid((6, 2), (2, 0)), plt.subplot2grid((6, 2), (3, 0)), plt.subplot2grid((6, 2), (4, 0)), plt.subplot2grid((6, 2), (5, 0)), plt.subplot2grid((6, 2), (1, 1)), plt.subplot2grid((6, 2), (2, 1)), plt.subplot2grid((6, 2), (3, 1)), plt.subplot2grid((6, 2), (4, 1)),