Skip to content

Commit

Permalink
convert time units of BHmergers file to match current changa output f…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
mtremmel committed Nov 13, 2024
1 parent 5de1d61 commit 39845db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tangos/tools/changa_bh_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,16 @@ def _generate_halolinks(self, pairs):
logger.info("Generated %d tracker links between steps %r and %r", len(links), ts1, ts2)

logger.info("Generating BH Merger information for steps %r and %r", ts1, ts2)
#get information needed from simulation to convert time from simulation units
import pynbody
f = pynbody.load(ts1.filename)
tunits = f.infer_original_units('Gyr')
gyr_ratio = pynbody.Gyr.ratio(tunits)
for l in open(self._bhmerger_filename):
l_split = l.split()
t = float(l_split[6])
#convert time to Gyr and account for negative times
#(for "fake" mergers but we'd still want them if the BHs actually make it to the database)
t = float(np.abs(l_split[6]))*gyr_ratio
bh_dest_id = int(l_split[0])
bh_src_id = int(l_split[1])
ratio = float(l_split[4])
Expand Down

0 comments on commit 39845db

Please sign in to comment.