aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-10-25 11:55:16 +0800
committerAaron LI <aly@aaronly.me>2018-10-25 11:55:16 +0800
commit67b9349a8d1cdc786926a10d5ad3d0c2cc8a6d13 (patch)
tree5941c194110a665f81f13ee532e717e5c60ad776 /fg21sim
parentee0ec86428846515325e70e6b2250fcde6fc8b58 (diff)
downloadfg21sim-67b9349a8d1cdc786926a10d5ad3d0c2cc8a6d13.tar.bz2
clusters/halo: Simplify the code a bit
Diffstat (limited to 'fg21sim')
-rw-r--r--fg21sim/extragalactic/clusters/halo.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py
index a94eb84..4e1b0bf 100644
--- a/fg21sim/extragalactic/clusters/halo.py
+++ b/fg21sim/extragalactic/clusters/halo.py
@@ -708,10 +708,7 @@ class RadioHalo:
return False
t_merger = self._merger_time(t)
t_turb = self.time_turbulence(t_merger)
- if (t >= t_merger) and (t <= t_merger + t_turb):
- return True
- else:
- return False
+ return (t >= t_merger) and (t <= t_merger + t_turb)
def _energy_loss(self, gamma, t):
"""
@@ -801,11 +798,8 @@ class RadioHaloAM(RadioHalo):
Determine the beginning time of the merger event within which
the given time is located.
"""
- try:
- idx = self._merger_idx(t)
- return self.age_merger[idx]
- except IndexError:
- return None
+ idx = self._merger_idx(t)
+ return self.age_merger[idx]
def _merger(self, idx):
"""
@@ -880,8 +874,7 @@ class RadioHaloAM(RadioHalo):
dt = self.time_step
xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt)
t_turb = np.array([self.time_turbulence(t) for t in xt])
- avg = np.sum(t_turb * dt) / (len(xt) * dt)
- return avg
+ return np.sum(t_turb * dt) / (len(xt) * dt)
@property
def mach_turbulence_avg(self):
@@ -892,8 +885,7 @@ class RadioHaloAM(RadioHalo):
dt = self.time_step
xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt)
mach = np.array([self.mach_turbulence(t) for t in xt])
- avg = np.sum(mach * dt) / (len(xt) * dt)
- return avg
+ return np.sum(mach * dt) / (len(xt) * dt)
@property
def tau_acceleration_avg(self):
@@ -907,8 +899,7 @@ class RadioHaloAM(RadioHalo):
dt = self.time_step
xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt)
tau = np.array([self.tau_acceleration(t) for t in xt])
- avg = np.sum(tau * dt) / (len(xt) * dt)
- return avg
+ return np.sum(tau * dt) / (len(xt) * dt)
@property
def time_acceleration_fraction(self):
@@ -917,8 +908,7 @@ class RadioHaloAM(RadioHalo):
``age_begin`` to ``age_obs`` that the turbulence acceleration
is active.
"""
- dt = self.time_step
+ dt = self.fpsolver.tstep
xt = np.arange(self.age_begin, self.age_obs+dt/2, step=dt)
active = np.array([self._is_turb_active(t) for t in xt], dtype=int)
- fraction = active.mean()
- return fraction
+ return active.mean()