From 9adf1e91d0819f84b1327f6d38cf20c4389430cd Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 1 Aug 2017 00:59:38 +0800 Subject: clusters: Add config "halos_dumpfile" and dump simulate halos data --- fg21sim/configs/20-extragalactic.conf.spec | 4 ++++ fg21sim/extragalactic/clusters/main.py | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'fg21sim') diff --git a/fg21sim/configs/20-extragalactic.conf.spec b/fg21sim/configs/20-extragalactic.conf.spec index 515950e..cb174f0 100644 --- a/fg21sim/configs/20-extragalactic.conf.spec +++ b/fg21sim/configs/20-extragalactic.conf.spec @@ -26,6 +26,10 @@ # Output the effective/inuse clusters catalog data (CSV file) catalog_outfile = string(default=None) + # Output file for dumping the simulated cluster halos data in Python + # native *pickle* format (i.e., .pkl) + halos_dumpfile = string(default=None) + # The fraction of the dark matter mass in galaxy clusters. f_darkmatter = float(default=0.8, min=0.5, max=1.0) diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index 10f169c..43c4c09 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -26,7 +26,7 @@ from .psformalism import PSFormalism from .formation import ClusterFormation from .halo import RadioHalo from ...share import CONFIGS, COSMO -from ...utils.io import dataframe_to_csv +from ...utils.io import dataframe_to_csv, pickle_dump from ...sky import get_sky @@ -69,6 +69,7 @@ class GalaxyClusters: """ comp = "extragalactic/clusters" self.catalog_outfile = self.configs.get_path(comp+"/catalog_outfile") + self.halos_dumpfile = self.configs.get_path(comp+"/halos_dumpfile") self.prefix = self.configs.getn(comp+"/prefix") self.save = self.configs.getn(comp+"/save") self.output_dir = self.configs.get_path(comp+"/output_dir") @@ -300,3 +301,9 @@ class GalaxyClusters: dataframe_to_csv(self.catalog, outfile=self.catalog_outfile, comment=self.catalog_comment, clobber=self.clobber) + # Dump the simulated clusters data + if self.halos_dumpfile is None: + logger.warning("Missing dump outfile; skip dump cluster data!") + else: + pickle_dump(self.halos, outfile=self.halos_dumpfile, + clobber=self.clobber) -- cgit v1.2.2