From 2c1eaa56a8aed5facc20bb967dee75516048da25 Mon Sep 17 00:00:00 2001 From: yuedong Date: Mon, 10 Jan 2022 03:40:25 +0800 Subject: [PATCH] minor change in config files --- Catalog/C3Catalog.py | 8 ++++---- ObservationSim/ObservationSim.py | 12 ++++++------ config/config_C3.yaml | 14 +++++++------- config/config_example.yaml | 15 +++++++-------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Catalog/C3Catalog.py b/Catalog/C3Catalog.py index 54eae84..dd066b9 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"] and not config["galaxy_only"]: + if "star_cat" in config["input_path"] and config["input_path"]["star_cat"] and not config["run_option"]["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"] and not config["star_only"]: + if "galaxy_cat" in config["input_path"] and config["input_path"]["galaxy_cat"] and not config["run_option"]["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"]) @@ -192,13 +192,13 @@ class C3Catalog(CatalogBase): self.avGal = extAv(self.nav, seed=self.seed_Av) self.objs = [] self.ids = 0 - if "star_cat" in self.config["input_path"] and self.config["input_path"]["star_cat"] and not self.config["galaxy_only"]: + if "star_cat" in self.config["input_path"] and self.config["input_path"]["star_cat"] and not self.config["run_option"]["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"]: + if "galaxy_cat" in self.config["input_path"] and self.config["input_path"]["galaxy_cat"] and not self.config["run_option"]["star_only"]: gals_cat = h5.File(self.galaxy_path, 'r')['galaxies'] for pix in self.pix_list: gals = gals_cat[str(pix)] diff --git a/ObservationSim/ObservationSim.py b/ObservationSim/ObservationSim.py index c56439a..ccfd408 100755 --- a/ObservationSim/ObservationSim.py +++ b/ObservationSim/ObservationSim.py @@ -123,11 +123,11 @@ class Observation(object): # if j >= 100: # break obj = self.cat.objs[j] - if obj.type == 'star' and self.config["galaxy_only"]: + if obj.type == 'star' and self.config["run_option"]["galaxy_only"]: continue - elif obj.type == 'galaxy' and self.config["star_only"]: + elif obj.type == 'galaxy' and self.config["run_option"]["star_only"]: continue - elif obj.type == 'quasar' and self.config["star_only"]: + elif obj.type == 'quasar' and self.config["run_option"]["star_only"]: continue # load SED @@ -185,9 +185,9 @@ class Observation(object): # Draw object & update output catalog try: - if self.config["out_cat_only"]: + if self.config["run_option"]["out_cat_only"]: isUpdated = True - if chip.survey_type == "photometric" and not self.config["out_cat_only"]: + if chip.survey_type == "photometric" and not self.config["run_option"]["out_cat_only"]: isUpdated, pos_shear = obj.drawObj_multiband( tel=self.tel, pos_img=pos_img, @@ -199,7 +199,7 @@ class Observation(object): g2=obj.param["g2"], exptime=pointing.exp_time ) - elif chip.survey_type == "spectroscopic" and not self.config["out_cat_only"]: + elif chip.survey_type == "spectroscopic" and not self.config["run_option"]["out_cat_only"]: isUpdated, pos_shear = obj.drawObj_slitless( tel=self.tel, pos_img=pos_img, diff --git a/config/config_C3.yaml b/config/config_C3.yaml index edbf533..e233264 100644 --- a/config/config_C3.yaml +++ b/config/config_C3.yaml @@ -30,15 +30,15 @@ run_option: # in order to config the number of threads to request from NAOC cluster n_threads: 80 -# Output catalog only? -# If yes, no imaging simulation will run -out_cat_only: NO + # Output catalog only? + # If yes, no imaging simulation will run + out_cat_only: NO -# Only simulate stars? -star_only: YES + # Only simulate stars? + star_only: YES -# Only simulate galaxies? -galaxy_only: NO + # Only simulate galaxies? + galaxy_only: NO ############################################### # Observation setting diff --git a/config/config_example.yaml b/config/config_example.yaml index 723a9d1..ff5afe0 100644 --- a/config/config_example.yaml +++ b/config/config_example.yaml @@ -28,16 +28,15 @@ run_option: # simulation codes. It should be implemented later in the web frontend # in order to config the number of threads to request from NAOC cluster n_threads: 40 + # Output catalog only? + # If yes, no imaging simulation will run + out_cat_only: NO -# Output catalog only? -# If yes, no imaging simulation will run -out_cat_only: NO + # Only simulate stars? + star_only: NO -# Only simulate stars? -star_only: NO - -# Only simulate galaxies? -galaxy_only: NO + # Only simulate galaxies? + galaxy_only: NO ############################################### # Observation setting -- GitLab