From c897a7e8165e471ccc5438297a67ca9cff528cbe Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 21 Feb 2019 18:52:27 +0800 Subject: clusters/halo: Extends _validate_time() with 'include_end' parameter Check the time against the merge end time only if 'include_end' is True (the default). Specify 'include_end=False' in duration_turb() method. --- fg21sim/extragalactic/clusters/halo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'fg21sim/extragalactic/clusters/halo.py') diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index 4c27dc0..bce6fd3 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -274,7 +274,7 @@ class RadioHalo1M: Unit: [Gyr] """ - self._validate_time(t_merger) + self._validate_time(t_merger, include_end=False) z_merger = COSMO.redshift(t_merger) M_main = self.mass_main(t=t_merger) M_sub = self.mass_sub(t=t_merger) @@ -657,14 +657,16 @@ class RadioHalo1M: """ return self.t_merger - def _validate_time(self, t): + def _validate_time(self, t, include_end=True): """ Validate that the given time ``t`` is the time when a merger begins - or ends, otherwise raise an error. + or ends (if ``include_end`` is ``True``), otherwise raise an error. """ - if (not np.any(np.isclose(t, self.t_merger)) and - not np.any(np.isclose(t, self.t_merger_end))): - raise ValueError("Not a merger begin/end time: %f" % t) + if np.any(np.isclose(t, self.t_merger)): + return + if include_end and np.any(np.isclose(t, self.t_merger_end)): + return + raise ValueError("Not a merger begin/end time: %f" % t) def mass_merged(self, t=None): """ -- cgit v1.2.2