aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-07-19 23:59:26 +0800
committerAaron LI <aly@aaronly.me>2017-07-19 23:59:26 +0800
commit871a45b2978a13beb16557d6e34172c2feb5e14a (patch)
tree90d5a9bd8367012ab84ae3b9db75d3f55a024583 /fg21sim/extragalactic
parent8e0c6d87118ee505753fc3454c85b3a3462be6a3 (diff)
downloadfg21sim-871a45b2978a13beb16557d6e34172c2feb5e14a.tar.bz2
clusters/mergertree.py: Add function "show_mtree()"
This function traces the main cluster and print its formation history to the screen, for easier illustration and examination. Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/extragalactic')
-rw-r--r--fg21sim/extragalactic/clusters/mergertree.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/fg21sim/extragalactic/clusters/mergertree.py b/fg21sim/extragalactic/clusters/mergertree.py
index 22d1d3b..3ea6165 100644
--- a/fg21sim/extragalactic/clusters/mergertree.py
+++ b/fg21sim/extragalactic/clusters/mergertree.py
@@ -69,6 +69,38 @@ def read_mtree(infile):
return mtree
+def show_mtree(mtree):
+ """
+ Trace the main cluster and show its formation history.
+ """
+ def _show_event(main, sub=None, parent=None):
+ z = main.data["z"]
+ age = main.data["age"]
+ mass = main.data["mass"]
+ info = "[z=%.3f/t=%.2f]" % (z, age)
+ if sub is None:
+ # Accretion
+ info += " %.5g" % mass
+ if parent is not None:
+ dM = parent.data["mass"] - mass
+ info += " (dM=%.5g)" % dM
+ else:
+ # Merger
+ Msub = sub.data["mass"]
+ Rmass = mass / Msub
+ info += " %.5g <> %.5g (Rm=%.1f)" % (mass, Msub, Rmass)
+ return info
+
+ i = 0
+ info = _show_event(main=mtree)
+ print("%2d %s" % (i, info))
+ while mtree and mtree.main:
+ i += 1
+ info = _show_event(main=mtree.main, sub=mtree.sub, parent=mtree)
+ print("%2d %s" % (i, info))
+ mtree = mtree.main
+
+
def plot_mtree(mtree, outfile, figsize=(12, 8)):
"""
Plot the cluster merger tree.