aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-02-21 18:52:27 +0800
committerAaron LI <aly@aaronly.me>2019-02-21 18:52:27 +0800
commitc897a7e8165e471ccc5438297a67ca9cff528cbe (patch)
treed838a9a63de6bcb6ea1d208ab79b5ab3bda5c208
parent261c97a6f2bac601014ec3337328dc1fd4155f4a (diff)
downloadfg21sim-c897a7e8165e471ccc5438297a67ca9cff528cbe.tar.bz2
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.
-rw-r--r--fg21sim/extragalactic/clusters/halo.py14
1 files changed, 8 insertions, 6 deletions
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):
"""