From 655e9e5e0c342af57c942fe36e7baf3c60d8c21c Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 1 Jan 2018 23:36:32 +0800 Subject: clusters/formation: add "mergers()" to extract all the merger events --- fg21sim/extragalactic/clusters/formation.py | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'fg21sim/extragalactic/clusters') diff --git a/fg21sim/extragalactic/clusters/formation.py b/fg21sim/extragalactic/clusters/formation.py index 7d7b9a2..e7595d5 100644 --- a/fg21sim/extragalactic/clusters/formation.py +++ b/fg21sim/extragalactic/clusters/formation.py @@ -197,6 +197,10 @@ class ClusterFormation: Parameters ---------- + mtree : `~MergerTree`, optional + Specify the merger tree from which to identify the most + recent merger event. + Default: self.mtree ratio_major : float, optional The mass ratio of the main and sub clusters to define whether the merger is a major event or a minor one. @@ -258,6 +262,38 @@ class ClusterFormation: else: return event_max + def mergers(self, mtree=None): + """ + Extract and return all the merger events. + + Parameters + ---------- + mtree : `~MergerTree`, optional + Specify the merger tree from which to identify the most + recent merger event. + Default: self.mtree + + Returns + ------- + evlist : list[event] + List of merger events with each element being a dictionary + same as the return of ``self.recent_major_merger``. + """ + if mtree is None: + mtree = self.mtree + + evlist = [] + for main, sub in mtree.itermain(): + if sub: + evlist.append({ + "M_main": main["mass"], + "M_sub": sub["mass"], + "R_mass": main["mass"] / sub["mass"], + "z": main["z"], + "age": main["age"] + }) + return evlist + def _trace_main(self): """ Iteratively trace the merger and accretion events of the -- cgit v1.2.2