diff options
author | Aaron LI <aly@aaronly.me> | 2017-09-03 15:01:14 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-09-03 15:01:14 +0800 |
commit | 007c6c667e2a4bd21bee9bdeeb187a73d3a41db9 (patch) | |
tree | 709d7d885f4fd5e25e9951f9a5c97bf8746753bb /fg21sim/extragalactic/clusters/main.py | |
parent | a8c2a75f4023d5243707f081a2c98f42f8a92cb0 (diff) | |
download | fg21sim-007c6c667e2a4bd21bee9bdeeb187a73d3a41db9.tar.bz2 |
clusters: Add option "use_output_catalog" to continue halo simulation
Diffstat (limited to 'fg21sim/extragalactic/clusters/main.py')
-rw-r--r-- | fg21sim/extragalactic/clusters/main.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index 800a471..3d71593 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -28,7 +28,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, pickle_dump +from ...utils.io import dataframe_to_csv, csv_to_dataframe, pickle_dump from ...utils.ds import dictlist_to_dataframe from ...utils.convert import JyPerPix_to_K from ...sky import get_sky @@ -80,6 +80,7 @@ class GalaxyClusters: """ comp = self.compID self.catalog_outfile = self.configs.get_path(comp+"/catalog_outfile") + self.use_output_catalog = self.configs.getn(comp+"/use_output_catalog") self.halos_dumpfile = self.configs.get_path(comp+"/halos_dumpfile") self.prefix = self.configs.getn(comp+"/prefix") self.output_dir = self.configs.get_path(comp+"/output_dir") @@ -354,9 +355,21 @@ class GalaxyClusters: return logger.info("{name}: preprocessing ...".format(name=self.name)) - self._simulate_catalog() - self._process_catalog() - self._simulate_mergers() + if self.use_output_catalog: + logger.info("Use existing cluster & halo catalog: %s" % + self.catalog_outfile) + self.catalog, self.catalog_comment = csv_to_dataframe( + self.catalog_outfile) + ncluster = len(self.catalog) + idx_rmm = ~self.catalog["rmm_z"].isnull() + nhalo = idx_rmm.sum() + logger.info("Loaded cluster catalog: %d clusters with %d halos" % + (ncluster, nhalo)) + else: + self._simulate_catalog() + self._process_catalog() + self._simulate_mergers() + self._simulate_halos() self._draw_halos() @@ -425,6 +438,8 @@ class GalaxyClusters: logger.info("Save the resulting catalog ...") if self.catalog_outfile is None: logger.warning("Catalog output file not set; skip saving!") + elif self.use_output_catalog: + logger.info("No need to save the cluster catalog.") else: dataframe_to_csv(self.catalog, outfile=self.catalog_outfile, comment=self.catalog_comment, |