From 59b6c8afe1d5f295f71588415df425e64cd7a733 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 20 Jul 2017 16:10:53 +0800 Subject: clusters/main.py: Add basic "preprocess()" method Signed-off-by: Aaron LI --- fg21sim/extragalactic/clusters/main.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'fg21sim/extragalactic/clusters/main.py') diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index c3a89d0..438b860 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -213,12 +213,34 @@ class GalaxyClusters: logger.info("%d (%.1f%%) clusters have recent major mergers." % (num_major, 100*num_major/num)) + def preprocess(self): + """ + Perform the preparation procedures for the later simulations. + + Attributes + ---------- + _preprocessed : bool + This attribute presents and is ``True`` after the preparation + procedures have been done. + """ + if hasattr(self, "_preprocessed") and self._preprocessed: + return + + logger.info("{name}: preprocessing ...".format(name=self.name)) + self._load_catalog() + self._process_catalog() + self._simulate_merger() + + # TODO ??? + + self._preprocessed = True + def postprocess(self): """ Do some necessary post-simulation operations. """ logger.info("{name}: postprocessing ...".format(name=self.name)) - # Save the effective/inuse clusters catalog + # Save the final resulting clusters catalog logger.info("Save the resulting catalog ...") if self.catalog_outfile is None: logger.warning("Catalog output file not set; skip saving!") -- cgit v1.2.2