From 96fc980003e29a3a6de360971a0ea0eb5b50a498 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 11 Jan 2019 00:23:03 +0800 Subject: clusters/halo: Refactor calc_radius_turb() Keep all the calculated properties that can be used to tweak the parameters or to help debug. --- fg21sim/extragalactic/clusters/halo.py | 51 ++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 14 deletions(-) (limited to 'fg21sim/extragalactic') diff --git a/fg21sim/extragalactic/clusters/halo.py b/fg21sim/extragalactic/clusters/halo.py index 47895fe..9867ba2 100644 --- a/fg21sim/extragalactic/clusters/halo.py +++ b/fg21sim/extragalactic/clusters/halo.py @@ -964,28 +964,51 @@ class RadioHalo: largest turbulence radius of a merger that is generating a genuine radio halo. - Attributes - ---------- + Returns + ------- radius_turb_eff : float Effective radius of the turbulence region Unit: [kpc] + + Attributes + ---------- + radius_turb_eff : float + _halos : list[dict] + List of dictionary with each one saving the properties of the + halo generated by the corresponding merger. """ logger.info("Determining the effective turbulence radius ...") - halos = [RadioHalo1M(M_obs=self.M_obs, z_obs=self.z_obs, - M_main=self.M_main[i], - M_sub=self.M_sub[i], - z_merger=self.z_merger[i], - configs=self.configs) - for i in range(self.merger_num)] - halos.sort(key=lambda h: h.radius_turbulence(h.age_merger), - reverse=True) - for halo in halos: + halos = [{ + "M_main": self.M_main[i], + "M_sub": self.M_sub[i], + "z_merger": self.z_merger[i], + "i": i, + } for i in range(self.merger_num)] + for hdict in halos: + halo = RadioHalo1M(M_obs=self.M_obs, z_obs=self.z_obs, + M_main=hdict["M_main"], + M_sub=hdict["M_sub"], + z_merger=hdict["z_merger"], + configs=self.configs) + hdict["halo"] = halo + hdict["radius_turb"] = halo.radius_turbulence(halo.age_merger) + hdict["genuine"] = False + + halos.sort(key=lambda h: h["radius_turb"], reverse=True) + for hdict in halos: + halo = hdict["halo"] logger.info("Checking merger: %.2e & %.2e @ %.3f ..." % (halo.M_main, halo.M_sub, halo.z_merger)) n_e = halo.calc_electron_spectrum() - genuine, factor = halo.is_genuine(n_e) + genuine, em_factor = halo.is_genuine(n_e) + hdict["n_e"] = n_e + hdict["genuine"] = genuine + hdict["em_factor"] = em_factor + if genuine: - self.radius_turb_eff = halo.radius_turbulence(halo.age_merger) - logger.info("Identified effective merger") + self.radius_turb_eff = hdict["radius_turb"] + logger.info("Identified effective merger.") break + + self._halos = halos return self.radius_turb_eff -- cgit v1.2.2