aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic/clusters/main.py
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-12 23:33:35 +0800
committerAaron LI <aly@aaronly.me>2017-08-12 23:33:35 +0800
commitc0b81153caea9b4299118f25dbc5856b2cfe6fde (patch)
treecf9f9679fc3064175459278fb38658e8800aa542 /fg21sim/extragalactic/clusters/main.py
parent973dda47633d99c844ff08f354f17a2b75a7f448 (diff)
downloadfg21sim-c0b81153caea9b4299118f25dbc5856b2cfe6fde.tar.bz2
clusters/main.py: Implement "_draw_halos()" method
New functions "halo_rprofile()" and "draw_halo()" added to helper.py Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/extragalactic/clusters/main.py')
-rw-r--r--fg21sim/extragalactic/clusters/main.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py
index 959e877..2d8f4d5 100644
--- a/fg21sim/extragalactic/clusters/main.py
+++ b/fg21sim/extragalactic/clusters/main.py
@@ -30,6 +30,7 @@ from ...share import CONFIGS, COSMO
from ...utils.io import dataframe_to_csv, pickle_dump
from ...utils.ds import dictlist_to_dataframe
from ...sky import get_sky
+from . import helper
logger = logging.getLogger(__name__)
@@ -294,7 +295,30 @@ class GalaxyClusters:
logger.info("Done halos data conversion.")
def _draw_halos(self):
- pass
+ """
+ Draw the template images for each halo, and cache them for
+ simulating the superimposed halos at requested frequencies.
+
+ NOTE
+ ----
+ The drawn template images are append to the dictionaries of
+ the corresponding halo within the ``self.halos``.
+ The templates are normalized to have sum of 1.
+ """
+ num = len(self.halos)
+ logger.info("Draw template images for %d halos ..." % num)
+ self.halos = []
+ i = 0
+ for hdict in self.halos:
+ i += 1
+ if i % 50 == 0:
+ logger.info("[%d/%d] %.1f%% ..." % (i, num, 100*i/num))
+ theta_e = hdict["angular_radius"] / self.sky.pixelsize
+ rprofile = helper.halo_rprofile(re=theta_e)
+ template = helper.draw_halo(rprofile, felong=hdict["felong"],
+ rotation=hdict["rotation"])
+ hdict["template"] = template
+ logger.info("Done drawn halo template images.")
def preprocess(self):
"""
@@ -314,7 +338,8 @@ class GalaxyClusters:
self._process_catalog()
self._simulate_mergers()
self._simulate_halos()
- # TODO ???
+ self._draw_halos()
+
self._preprocessed = True
def postprocess(self):