In [1]:
import pickle
import numpy as np
from amuse.lab import *


/home/draco/amuse/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters

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


100
4

171
4

382
3

515
3

16
321

205
5

206
5

70
4

319
4

30
320

37
3

336
7

320
9

692

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


241
339

In [5]:
print encounterInfoReload["30"][-50]


                 key       child1       child2           id         mass  potential_in_code       radius         time     timestep           vx           vy           vz            x            y            z
                   -         none         none         none           kg  m**2 * s**-2            m            s            s    m * s**-1    m * s**-1    m * s**-1            m            m            m
====================  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========
 4764976994691796228           --           --           16    2.286e+29   -1.493e+06    1.496e+14    3.575e+14    3.397e+07    9.307e+02   -1.674e+02   -5.997e+02    1.604e+14   -7.974e+14    1.959e+14
15262126054357264317           --           --           30    5.757e+29   -1.444e+06    1.496e+14    3.575e+14    3.397e+07   -3.696e+02    6.649e+01    2.382e+02   -6.370e+13    3.167e+14   -7.781e+13
====================  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========  ===========
/home/draco/amuse/amuse-conda/src/amuse/datamodel/particles.py:302: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  if numpy.issubdtype(quantity.dtype, float):

In [ ]: