From ae6b8921d04eb1ab2c47a2081313d9f0db52686b Mon Sep 17 00:00:00 2001 From: yuedong Date: Sun, 9 Jan 2022 14:00:10 +0800 Subject: [PATCH] minor fix in C3Catalog.py --- Catalog/C3Catalog.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Catalog/C3Catalog.py b/Catalog/C3Catalog.py index fc80695..54eae84 100644 --- a/Catalog/C3Catalog.py +++ b/Catalog/C3Catalog.py @@ -30,13 +30,13 @@ class C3Catalog(CatalogBase): self.chip = chip self.pointing = pointing - if "star_cat" in config["input_path"] and config["input_path"]["star_cat"]: + if "star_cat" in config["input_path"] and config["input_path"]["star_cat"] and not config["galaxy_only"]: star_file = config["input_path"]["star_cat"] star_SED_file = config["SED_templates_path"]["star_SED"] self.star_path = os.path.join(self.cat_dir, star_file) self.star_SED_path = os.path.join(config["data_dir"], star_SED_file) self._load_SED_lib_star() - if "galaxy_cat" in config["input_path"] and config["input_path"]["galaxy_cat"]: + if "galaxy_cat" in config["input_path"] and config["input_path"]["galaxy_cat"] and not config["star_only"]: galaxy_file = config["input_path"]["galaxy_cat"] self.galaxy_path = os.path.join(self.cat_dir, galaxy_file) self.galaxy_SED_path = os.path.join(config["data_dir"], config["SED_templates_path"]["galaxy_SED"]) @@ -190,17 +190,20 @@ class C3Catalog(CatalogBase): def _load(self, **kwargs): self.nav = 15005 self.avGal = extAv(self.nav, seed=self.seed_Av) - gals_cat = h5.File(self.galaxy_path, 'r')['galaxies'] - star_cat = h5.File(self.star_path, 'r')['catalog'] self.objs = [] self.ids = 0 - for pix in self.pix_list: - gals = gals_cat[str(pix)] - stars = star_cat[str(pix)] - self._load_gals(gals, pix_id=pix) - self._load_stars(stars, pix_id=pix) - del gals - del stars + if "star_cat" in self.config["input_path"] and self.config["input_path"]["star_cat"] and not self.config["galaxy_only"]: + star_cat = h5.File(self.star_path, 'r')['catalog'] + for pix in self.pix_list: + stars = star_cat[str(pix)] + self._load_stars(stars, pix_id=pix) + del stars + if "galaxy_cat" in self.config["input_path"] and self.config["input_path"]["galaxy_cat"] and not self.config["star_only"]: + gals_cat = h5.File(self.galaxy_path, 'r')['galaxies'] + for pix in self.pix_list: + gals = gals_cat[str(pix)] + self._load_gals(gals, pix_id=pix) + del gals print("number of objects in catalog: ", len(self.objs)) del self.avGal -- GitLab