diff options
author | Aaron LI <aly@aaronly.me> | 2017-08-01 00:59:38 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-08-01 00:59:38 +0800 |
commit | 9adf1e91d0819f84b1327f6d38cf20c4389430cd (patch) | |
tree | 553e513405b4f53cce827dbd8577b91ac06a8688 | |
parent | adc667c206b8c3438be8a94f3a839edc3a077ce0 (diff) | |
download | fg21sim-9adf1e91d0819f84b1327f6d38cf20c4389430cd.tar.bz2 |
clusters: Add config "halos_dumpfile" and dump simulate halos data
-rw-r--r-- | fg21sim/configs/20-extragalactic.conf.spec | 4 | ||||
-rw-r--r-- | fg21sim/extragalactic/clusters/main.py | 9 |
2 files changed, 12 insertions, 1 deletions
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) |