aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-10-19 13:14:14 +0800
committerAaron LI <aly@aaronly.me>2017-10-19 13:14:14 +0800
commitad4a43dce176c3f087f5dc5af188dfc081934027 (patch)
tree6137d40bf12053d304079d2d7e3ee5ee04793775 /fg21sim
parenteac586b473c31c2ca607a3cf9c27109b87fc8043 (diff)
downloadfg21sim-ad4a43dce176c3f087f5dc5af188dfc081934027.tar.bz2
clusters/halo: Support use the previously dumped halos raw data
Add option "use_dump_halos_data" to control whether to just use the previously dumped halos data, therefore, the radio emissions at additional frequencies can be simply calculated.
Diffstat (limited to 'fg21sim')
-rw-r--r--fg21sim/configs/20-extragalactic.conf.spec7
-rw-r--r--fg21sim/configs/checkers.py8
-rw-r--r--fg21sim/extragalactic/clusters/main.py12
3 files changed, 26 insertions, 1 deletions
diff --git a/fg21sim/configs/20-extragalactic.conf.spec b/fg21sim/configs/20-extragalactic.conf.spec
index 36d14c9..df5ea86 100644
--- a/fg21sim/configs/20-extragalactic.conf.spec
+++ b/fg21sim/configs/20-extragalactic.conf.spec
@@ -86,6 +86,13 @@
# calculate the emissions at other frequencies.
dump_halos_data = boolean(default=True)
+ # Whether to directly use the (previously dumped) halos data (".pkl")
+ # as specified by the above ``halos_catalog_outfile`` and
+ # ``dump_halos_data`` options?
+ # In this way, the radio emissions at additional frequencies can be
+ # easily (and consistently) calculated.
+ use_dump_halos_data = boolean(default=False)
+
# The minimum mass for clusters when to determine the galaxy clusters
# total counts and their distributions.
# Unit: [Msun]
diff --git a/fg21sim/configs/checkers.py b/fg21sim/configs/checkers.py
index cbffcc8..2d23706 100644
--- a/fg21sim/configs/checkers.py
+++ b/fg21sim/configs/checkers.py
@@ -150,6 +150,7 @@ def check_galactic_snr(configs):
def check_extragalactic_clusters(configs):
"""
Check the "[extragalactic][clusters]" section of the configurations.
+
The related sections ("[extragalactic][psformalism]",
"[extragalactic][halos]") are also checked.
"""
@@ -165,6 +166,13 @@ def check_extragalactic_clusters(configs):
results.update(_check_existence(configs, comp+"/catalog_outfile"))
else:
results.update(_check_missing(configs, comp+"/catalog_outfile"))
+ # dumped halos data required when enabled to use it
+ if configs.get(comp+"/use_dump_halos_data"):
+ results.update(_check_existence(configs,
+ comp+"/halos_catalog_outfile"))
+ else:
+ results.update(_check_missing(configs,
+ comp+"/halos_catalog_outfile"))
results.update(_check_missing(configs, comp+"/output_dir"))
return results
diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py
index 06ee9f6..e838094 100644
--- a/fg21sim/extragalactic/clusters/main.py
+++ b/fg21sim/extragalactic/clusters/main.py
@@ -81,6 +81,8 @@ class GalaxyClusters:
self.halos_data_dumpfile = os.path.splitext(
self.halos_catalog_outfile)[0] + ".pkl"
self.dump_halos_data = self.configs.getn(comp+"/dump_halos_data")
+ self.use_dump_halos_data = self.configs.getn(
+ comp+"/use_dump_halos_data")
self.prefix = self.configs.getn(comp+"/prefix")
self.output_dir = self.configs.get_path(comp+"/output_dir")
self.merger_mass_min = self.configs.getn(comp+"/merger_mass_min")
@@ -409,7 +411,15 @@ class GalaxyClusters:
self._process_catalog()
self._simulate_mergers()
- self._simulate_halos()
+ if self.use_dump_halos_data:
+ logger.info("Use existing dumped halos raw data: %s" %
+ self.halos_data_dumpfile)
+ self.halos = pickle_load(self.halos_data_dumpfile)
+ logger.info("Loaded data of %d halos" % len(self.halos))
+ else:
+ self._simulate_halos()
+
+ self._calc_halos_emission()
self._draw_halos()
self._preprocessed = True