aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/extragalactic/clusters/main.py
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-13 21:09:46 +0800
committerAaron LI <aly@aaronly.me>2017-08-13 21:09:46 +0800
commit8221ece7a7d18dc0f76f3c0bbf25371eedd1e33f (patch)
tree394e70f5e9b8385d109a2c60bd25f3910bf20fdc /fg21sim/extragalactic/clusters/main.py
parent4441d819c71258cdef74ad9ec97355e8a59c0c6f (diff)
downloadfg21sim-8221ece7a7d18dc0f76f3c0bbf25371eedd1e33f.tar.bz2
clusters/main.py: Implement "simulate_frequency()" and "simulate()"
Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/extragalactic/clusters/main.py')
-rw-r--r--fg21sim/extragalactic/clusters/main.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py
index 94a3288..610e60b 100644
--- a/fg21sim/extragalactic/clusters/main.py
+++ b/fg21sim/extragalactic/clusters/main.py
@@ -29,6 +29,7 @@ from .halo import RadioHalo
from ...share import CONFIGS, COSMO
from ...utils.io import dataframe_to_csv, pickle_dump
from ...utils.ds import dictlist_to_dataframe
+from ...utils.convert import JyPerPix_to_K
from ...sky import get_sky
from . import helper
@@ -364,6 +365,51 @@ class GalaxyClusters:
self._preprocessed = True
+ def simulate_frequency(self, freqidx):
+ """
+ Simulate the superimposed radio halos image at frequency (by
+ frequency index) based on the above simulated halo templates.
+
+ Parameters
+ ----------
+ freqidx : int
+ The index of the frequency in the ``self.frequencies`` where
+ to simulate the radio halos image.
+
+ Returns
+ -------
+ sky : `~fg21sim.sky.SkyPatch`
+ The simulated sky image of radio halos as a new sky instance.
+ """
+ freq = self.frequencies[freqidx]
+ logger.info("Simulating radio halo map at %.2f [MHz] ..." % freq)
+ sky = self.sky.copy()
+ sky.frequency = freq
+ # Conversion factor for [Jy/pixel] to [K]
+ JyPP2K = JyPerPix_to_K(freq, sky.pixelsize)
+
+ for hdict in self.halos:
+ center = (hdict["lon"], hdict["lat"])
+ template = hdict["template"] # normalized to have mean of 1
+ Npix = template.size
+ flux = hdict["flux[%d]" % freqidx] # [Jy]
+ Tmean = (flux/Npix) * JyPP2K # [K]
+ Timg = Tmean * template # [K]
+ sky.add(Timg, center=center)
+
+ return sky
+
+ def simulate(self):
+ """
+ Simulate the sky images of radio halos at each frequency.
+ """
+ logger.info("Simulating {name} ...".format(name=self.name))
+ for idx, freq in enumerate(self.frequencies):
+ sky = self.simulate_frequency(freqidx=idx)
+ outfile = self._outfilepath(frequency=freq)
+ sky.write(outfile)
+ logger.info("Done simulate {name}!".format(name=self.name))
+
def postprocess(self):
"""
Do some necessary post-simulation operations.