From 3c362e744b0acde57a8f99de8f671d7b258b8de9 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 26 Jan 2019 17:19:26 +0800 Subject: clusters/halo: Fold _merger_idx() into _merger_event() Update _merger_time() accordingly. --- fg21sim/extragalactic/clusters/halo.py | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index 14a9028..b11f060 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -774,27 +774,12 @@ class RadioHaloAM(RadioHalo1M): """ return self.age_merger[-1] - def _merger_idx(self, t): - """ - Determine the index of the merger event within which the given - time is located, i.e.: - age_merger[idx-1] >= t > age_merger[idx] - """ - return (self.age_merger > t).sum() - - def _merger_time(self, t): - """ - Determine the beginning time of the merger event within which - the given time is located. - """ - idx = self._merger_idx(t) - return self.age_merger[idx] - def _merger_event(self, t): """ - Return the merger event at cosmic time ``t``. + Return the most recent merger event happend before the given time, + i.e., the merger event that the given time locates in. """ - idx = self._merger_idx(t) + idx = (self.age_merger > t).sum() return { "idx": idx, "M_main": self.M_main[idx], @@ -803,6 +788,14 @@ class RadioHaloAM(RadioHalo1M): "age": self.age_merger[idx], } + def _merger_time(self, t): + """ + Determine the beginning time of the merger event within which + the given time is located. + """ + merger = self._merger_event(t) + return merger["age"] + def mass_merged(self, t): """ The mass of merged cluster at the given (cosmic) time. -- cgit v1.2.2