From 925d4a2e42601db7fef20b13ac0238478b51bd66 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 1 Jan 2018 23:02:13 +0800 Subject: clusters/mergertree: add param mtree to maximum_merger and recent_major_merger --- fg21sim/extragalactic/clusters/formation.py | 11 ++++++----- fg21sim/extragalactic/clusters/main.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'fg21sim/extragalactic/clusters') diff --git a/fg21sim/extragalactic/clusters/formation.py b/fg21sim/extragalactic/clusters/formation.py index a48d68e..38f7764 100644 --- a/fg21sim/extragalactic/clusters/formation.py +++ b/fg21sim/extragalactic/clusters/formation.py @@ -192,7 +192,7 @@ class ClusterFormation: logger.debug("Simulated cluster formation with merger tree.") return self.mtree - def recent_major_merger(self, ratio_major=3.0): + def recent_major_merger(self, mtree=None, ratio_major=3.0): """ Identify and return the most recent major merger event. @@ -213,7 +213,8 @@ class ClusterFormation: "z": z, "age": age}``; ``None`` if no major event found. """ - mtree = self.mtree + if mtree is None: + mtree = self.mtree event = None while mtree and mtree.main: if mtree.sub is None: @@ -239,8 +240,7 @@ class ClusterFormation: return event - @property - def maximum_merger(self): + def maximum_merger(self, mtree=None): """ The merger event corresponding to the biggest sub cluster, i.e., the main cluster gains the most mass. @@ -257,7 +257,8 @@ class ClusterFormation: the above ``self.recent_major_event``. ``None`` if no mergers occurred during the traced period. """ - mtree = self.mtree + if mtree is None: + mtree = self.mtree event_max = {"M_main": -1, "M_sub": -1, "R_mass": -1, "z": -1, "age": -1} while mtree and mtree.main: diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index 9d3810d..b704938 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -217,9 +217,9 @@ class GalaxyClusters: clform.simulate_mtree(main_only=True) if self.use_max_merger: # NOTE: may be ``None`` due to no mergers occurred at all! - mmev = clform.maximum_merger + mmev = clform.maximum_merger() else: - mmev = clform.recent_major_merger(self.ratio_major) + mmev = clform.recent_major_merger(ratio_major=self.ratio_major) if mmev: mdata[i, :] = [mmev["M_main"], mmev["M_sub"], mmev["z"], mmev["age"]] -- cgit v1.2.2