From c1a561a8c05a7e59cdf3a34ac2112eed5ea7c406 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 23 Oct 2017 21:11:07 +0800 Subject: clusters/halo: Use "lru_cache()", also improves some performance --- fg21sim/extragalactic/clusters/emission.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fg21sim/extragalactic/clusters/emission.py') diff --git a/fg21sim/extragalactic/clusters/emission.py b/fg21sim/extragalactic/clusters/emission.py index 5195423..4801eba 100644 --- a/fg21sim/extragalactic/clusters/emission.py +++ b/fg21sim/extragalactic/clusters/emission.py @@ -25,6 +25,7 @@ References """ import logging +from functools import lru_cache import numpy as np import scipy.special @@ -102,6 +103,7 @@ class SynchrotronEmission: self.B = B # [uG] @property + @lru_cache() def B_gauss(self): """ Magnetic field in unit of [G] (i.e., Gauss) @@ -109,6 +111,7 @@ class SynchrotronEmission: return self.B * 1e-6 # [uG] -> [G] @property + @lru_cache() def frequency_larmor(self): """ Electron Larmor frequency (a.k.a. gyro frequency): -- cgit v1.2.2