In [1]:
import pickle
import numpy as np
from amuse.lab import *
In [2]:
# Reading in is simple, just load a pickle file and save the dictionary
encounterInfoReload = None
encounter_file = open("/home/draco/jglaser/Public/Tycho_Runs/Test/LongTest02/LongTest02_encounters.pkl", "rb")
encounterInfoReload = pickle.load(encounter_file)
encounter_file.close()
In [3]:
# This is a quick example of a for loop that will comb through the dictionary and check which stars had an encounter
# The keys are the star's id
# Every encounter stores a particle set of the particles involved under both keys in the dictionary
# You can see the repeated encounter below
counter = 0
for key in encounterInfoReload:
if len(encounterInfoReload[key])>=3:
print key
#print encounterInfoReload[key][0][0]
#print encounterInfoReload[key][0][1]
print len(encounterInfoReload[key])
counter += len(encounterInfoReload[key])
print ""
print counter
In [4]:
counter = 0
list_of_keys = []
for key in encounterInfoReload:
if len(encounterInfoReload[key])!=0:
for particle in encounterInfoReload[key][0]:
if particle.id >= 50000:
list_of_keys.append(key)
#print encounterInfoReload[key][0][0]
#print encounterInfoReload[key][0][1]
#print len(encounterInfoReload[key])
counter += len(encounterInfoReload[key])
#print ""
print len(list_of_keys)
print counter
In [5]:
print encounterInfoReload["30"][-50]
In [ ]: