@@ -63,9 +63,9 @@ def _timelink_black_holes(self):
63
63
def _generate_halolinks (self , pairs ):
64
64
for ts1 , ts2 in parallel_tasks .distributed (pairs ):
65
65
if BlackHolesLog .can_load (ts2 .filename ):
66
- bh_log = BlackHolesLog (ts2 .filename )
66
+ bh_log = BlackHolesLog . get_existing_or_new (ts2 .filename )
67
67
elif ShortenedOrbitLog .can_load (ts2 .filename ):
68
- bh_log = ShortenedOrbitLog (ts2 .filename )
68
+ bh_log = ShortenedOrbitLog . get_existing_or_new (ts2 .filename )
69
69
else :
70
70
logger .error ("Warning! No orbit file found!" )
71
71
@@ -106,9 +106,16 @@ def _generate_halolinks(self, pairs):
106
106
logger .info ("Generated %d tracker links between steps %r and %r" , len (links ), ts1 , ts2 )
107
107
108
108
logger .info ("Generating BH Merger information for steps %r and %r" , ts1 , ts2 )
109
+ #get information needed from simulation to convert time from simulation units
110
+ import pynbody
111
+ f = pynbody .load (ts1 .filename )
112
+ tunits = f .infer_original_units ('Gyr' )
113
+ gyr_ratio = pynbody .units .Gyr .ratio (tunits )
109
114
for l in open (self ._bhmerger_filename ):
110
115
l_split = l .split ()
111
- t = float (l_split [6 ])
116
+ #convert time to Gyr and account for negative times
117
+ #(for "fake" mergers but we'd still want them if the BHs actually make it to the database)
118
+ t = np .abs (float (l_split [6 ]))/ gyr_ratio
112
119
bh_dest_id = int (l_split [0 ])
113
120
bh_src_id = int (l_split [1 ])
114
121
ratio = float (l_split [4 ])
@@ -196,7 +203,7 @@ def _get_bh_halo_assignments(self, pynbody_snapshot):
196
203
iteration_count += 1
197
204
198
205
# find the parent halos of the bh_cen_halos
199
- bh_halos_new = [pynbody_halos .get_dummy_halo (i ).properties ['hostHalo' ] for i in bh_halos ]
206
+ bh_halos_new = [pynbody_halos .get_dummy_halo (i ).properties ['hostHalo' ] if i != - 1 else - 1 for i in bh_halos ]
200
207
201
208
# if the parent is -1, we have definitely found the top level halos
202
209
continue_searching = not all ([bhi == - 1 for bhi in bh_halos_new ])
0 commit comments