diff options
-rw-r--r-- | fg21sim/configs/20-extragalactic.conf.spec | 14 | ||||
-rw-r--r-- | fg21sim/configs/checkers.py | 3 | ||||
-rw-r--r-- | fg21sim/extragalactic/clusters/main.py | 23 |
3 files changed, 36 insertions, 4 deletions
diff --git a/fg21sim/configs/20-extragalactic.conf.spec b/fg21sim/configs/20-extragalactic.conf.spec index f2b0c30..74266cd 100644 --- a/fg21sim/configs/20-extragalactic.conf.spec +++ b/fg21sim/configs/20-extragalactic.conf.spec @@ -35,6 +35,20 @@ # mass, redshift, position, shape, and the recent major merger info. catalog_outfile = string(default=None) + # Directly use the (previously simulated) catalog file specified + # as the above "catalog_outfile" option. + # NOTE: + # By using an existing catalog, the steps to derive these data are + # simply skipped. + # Due to the small number density of the galaxy clusters, the simulated + # results within a small patch of sky (e.g., 100 [deg^2]) show + # significant fluctuations (several or even several tens of times + # of differences between simulations). Therefore, one may run many + # tests and only create images at some frequencies necessary for + # testing, then select the satisfying one to continue the simulation + # to generate images at all frequencies. + use_output_catalog = boolean(default=False) + # Output file for dumping the simulated cluster halos data in Python # native *pickle* format (i.e., .pkl) halos_dumpfile = string(default=None) diff --git a/fg21sim/configs/checkers.py b/fg21sim/configs/checkers.py index 3985e46..5316eac 100644 --- a/fg21sim/configs/checkers.py +++ b/fg21sim/configs/checkers.py @@ -157,6 +157,9 @@ def check_extragalactic_clusters(configs): if comp in comp_enabled: # Only validate the configs if this component is enabled results.update(_check_existence(configs, comp+"/ps_data")) + # catalog required when enabled to use it + if configs.get(comp+"/use_output_catalog"): + results.update(_check_existence(configs, comp+"/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 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, |