def get_longitude_of_periastron_stats(row): print('Processing ', row.simarchive_filename) sa = rebound.SimulationArchive(row.simarchive_filename, process_warnings=False) oa = chaincalc.OrbitArray(sa) tlook = 1e4 * keplertime #probably 1e2-1e3 times the output cadence lko = oa.tail_orbitarray(tlook) mean_dlongitude_of_periastron = [] std_dlongitude_of_periastron = [] for n in range(lko['pomega'].shape[0] - 1): longstats = [{ 'mean': chaincalc.wrap2pi(lko['pomega'][n + 1, :] - lko['pomega'][n, :] + a).mean() - a, 'std': chaincalc.wrap2pi(lko['pomega'][n + 1, :] - lko['pomega'][n, :] + a).std() } for a in [0.0, np.pi]] if longstats[0]['std'] < longstats[1]['std']: mean_dlongitude_of_periastron.append(longstats[0]['mean']) std_dlongitude_of_periastron.append(longstats[0]['std']) else: mean_dlongitude_of_periastron.append(longstats[1]['mean']) std_dlongitude_of_periastron.append(longstats[1]['std']) #print(mean_dlongitude_of_periastron) #print(std_dlongitude_of_periastron) #if max(mean_dlongitude_of_periastron) > -np.pi/2: # print(row.hash) # print(mean_dlongitude_of_periastron) return { 'delta_longitude_of_periastron': mean_dlongitude_of_periastron, 'std_delta_longitude_of_periastron': std_dlongitude_of_periastron }
def doublecheck(row): sa = rebound.SimulationArchive(row.simarchive_filename, process_warnings=False) oa = chaincalc.OrbitArray(sa) tlook = 1e4*keplertime #probably 1e2-1e3 times the output cadence lko = oa.tail_orbitarray(tlook) finding = oa.is_this_a_constant_ratio_chain(oa.compute_tight_angles(lko,pratiocut=0.02)) print(row.hash, finding) return finding[0]
def targettime_hook(self, model): #This gets called whenever a model is being run, even if not # evolved because it was already finished, so avoid doing this twice. findingdkey = 'is_this_a_constant_ratio_chain' if not (findingdkey in model.status): sa = rebound.SimulationArchive(model.status['simarchive_filename'], process_warnings=False) oa = chaincalc.OrbitArray(sa) tlook = 1e4*keplertime #probably 1e2-1e3 times the output cadence lko = oa.tail_orbitarray(tlook) finding = oa.is_this_a_constant_ratio_chain(oa.compute_tight_angles(lko)) model.status['is_this_a_constant_ratio_chain'] = finding model.overwrite_status()
import json import numpy as np import rebound import chaincalc import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['axes.formatter.limits'] = (-2, 2) status_filename = sys.argv[1] with open(status_filename,'r') as json_file: status = json.load(json_file) sa = rebound.SimulationArchive(status['simarchive_filename']) oa = chaincalc.OrbitArray(sa) keplertime = 2.0*np.pi*1.0**1.5 print('Number of snapshots {:d}'.format(len(sa))) print('Time limits {:e} {:e}'.format(sa.tmin, sa.tmax)) nchain = len(sa[0].particles) -1 print('nchain',nchain) for ip in range(0,nchain): plt.plot(oa.orbitdata['t'][ip,:]/keplertime, oa.orbitdata['a'][ip,:],'-') plt.xlim(left=0) plt.title('semimajor axis')