From d15cfcc864e81f0dd6b7d96906ab69872f8f45be Mon Sep 17 00:00:00 2001 From: yuedong Date: Sun, 3 Apr 2022 05:36:41 +0800 Subject: [PATCH] add try-except block when reading healpix --- Catalog/NGPCatalog.py | 20 ++++++++++++++------ config/config_NGP.yaml | 8 ++++---- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Catalog/NGPCatalog.py b/Catalog/NGPCatalog.py index 26eb2f3..c854440 100644 --- a/Catalog/NGPCatalog.py +++ b/Catalog/NGPCatalog.py @@ -257,15 +257,23 @@ class NGPCatalog(CatalogBase): 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 + try: + stars = star_cat[str(pix)] + self._load_stars(stars, pix_id=pix) + del stars + except Exception as e: + self.logger.error(str(e)) + print(e) 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)] - self._load_gals(gals, pix_id=pix) - del gals + try: + gals = gals_cat[str(pix)] + self._load_gals(gals, pix_id=pix) + del gals + except Exception as e: + self.logger.error(str(e)) + print(e) if self.logger is not None: self.logger.info("number of objects in catalog: %d"%(len(self.objs))) else: diff --git a/config/config_NGP.yaml b/config/config_NGP.yaml index d402ad1..36c81ae 100644 --- a/config/config_NGP.yaml +++ b/config/config_NGP.yaml @@ -12,14 +12,14 @@ # work_dir: "/public/home/fangyuedong/sim_code_release/CSST/test/" work_dir: "/public/home/fangyuedong/temp/CSST/workplace/" data_dir: "/data/simudata/CSSOSDataProductsSims/data/" -run_name: "NGP_test" +run_name: "NGP_Astrometry-on" # (Optional) a file of point list # if you just want to run default pointing: # - pointing_dir: null # - pointing_file: null pointing_dir: "/data/simudata/CSSOSDataProductsSims/data/" -pointing_file: "pointing_test_NGP_3.dat" +pointing_file: "pointing_test_NGP_2.17.dat" # Whether to use MPI run_option: @@ -34,7 +34,7 @@ run_option: out_cat_only: NO # Only simulate stars? - star_only: YES + star_only: NO # Only simulate galaxies? galaxy_only: NO @@ -73,7 +73,7 @@ obs_setting: # - give a list of indexes of pointings: [ip_1, ip_2...] # - run all pointings: null # Note: only valid when a pointing list is specified - run_pointings: [1] + run_pointings: [ 5, 7, 11, 14, 19, 60, 70, 82, 88] # Run specific chip(s): # - give a list of indexes of chips: [ip_1, ip_2...] -- GitLab