From f058808a852d849115f8922f8199e702658e7784 Mon Sep 17 00:00:00 2001 From: fangyuedong Date: Sat, 2 Nov 2024 17:11:13 +0800 Subject: [PATCH] add crosstalk step. add validation for objects parameters --- config/obs_config_SCI.yaml | 2 ++ observation_sim/mock_objects/CatalogBase.py | 16 +++++++------- observation_sim/sim_steps/__init__.py | 5 +++-- observation_sim/sim_steps/add_objects.py | 23 +++++++++++++++++++-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/config/obs_config_SCI.yaml b/config/obs_config_SCI.yaml index ef82bcd..fecdf01 100644 --- a/config/obs_config_SCI.yaml +++ b/config/obs_config_SCI.yaml @@ -74,6 +74,8 @@ call_sequence: # Add bias bias: bias_16channel: YES + # Add cross-talk + cross_talk: {} # Add readout noise readout_noise: {} # Apply gain diff --git a/observation_sim/mock_objects/CatalogBase.py b/observation_sim/mock_objects/CatalogBase.py index cd1b669..77c9896 100644 --- a/observation_sim/mock_objects/CatalogBase.py +++ b/observation_sim/mock_objects/CatalogBase.py @@ -29,8 +29,8 @@ class CatalogBase(metaclass=ABCMeta): param = { "star": -1, "id": -1, - "ra": 0, - "dec": 0., + "ra": -999., + "dec": -999., "ra_orig": 0., "dec_orig": 0., "z": 0., @@ -44,15 +44,15 @@ class CatalogBase(metaclass=ABCMeta): "bfrac": 0., "av": 0., "redden": 0., - "hlr_bulge": 0., - "hlr_disk": 0., + "hlr_bulge": -999., + "hlr_disk": -999., "ell_bulge": 0., "ell_disk": 0., "ell_tot": 0., - "e1_disk": 0., - "e2_disk": 0., - "e1_bulge": 0., - "e2_bulge": 0., + "e1_disk": -999., + "e2_disk": -999., + "e1_bulge": -999., + "e2_bulge": -999., "teff": 0., "logg": 0., "feh": 0., diff --git a/observation_sim/sim_steps/__init__.py b/observation_sim/sim_steps/__init__.py index e8e2661..7669fe4 100644 --- a/observation_sim/sim_steps/__init__.py +++ b/observation_sim/sim_steps/__init__.py @@ -11,11 +11,11 @@ class SimSteps: from .prepare_headers import prepare_headers, updateHeaderInfo from .add_sky_background import add_sky_background_sci, add_sky_flat_calibration, add_sky_background - from .add_objects import add_objects + from .add_objects import add_objects, _is_obj_valid from .add_cosmic_rays import add_cosmic_rays from .add_pattern_noise import apply_PRNU, add_poisson_and_dark, add_detector_defects, add_nonlinearity, add_blooming, add_bias from .add_brighter_fatter_CTE import add_brighter_fatter, apply_CTE - from .readout_output import add_prescan_overscan, add_readout_noise, apply_gain, quantization_and_output + from .readout_output import add_prescan_overscan, add_readout_noise, apply_gain, quantization_and_output, add_crosstalk from .add_LED_flat import add_LED_Flat @@ -37,4 +37,5 @@ SIM_STEP_TYPES = { "quantization_and_output": "quantization_and_output", "led_calib_model": "add_LED_Flat", "sky_flatField": "add_sky_flat_calibration", + "cross_talk": "add_crosstalk" } diff --git a/observation_sim/sim_steps/add_objects.py b/observation_sim/sim_steps/add_objects.py index bbe8baa..49707d4 100644 --- a/observation_sim/sim_steps/add_objects.py +++ b/observation_sim/sim_steps/add_objects.py @@ -10,6 +10,22 @@ from observation_sim.psf import PSFGauss, FieldDistortion, PSFInterp, PSFInterpS from astropy.time import Time from datetime import datetime, timezone +def _is_obj_valid(self, obj): + if obj.param['star'] == 4: + # Currently there's no parameter checks for 'calib' type + return True + pos_keys = ['ra', 'dec'] + shape_keys = ['hlr_bulge', 'hlr_disk', 'e1_disk', 'e2_disk', 'e1_bulge', 'e2_bulge'] + if any(obj.param[key] == -999. for key in pos_keys): + msg = 'One or more positional information (ra, dec) is missing' + self.chip_output.Log_error(msg) + return False + if obj.param['star'] == 0 and any(obj.param[key] == -999. for key in shape_keys): + msg = 'One or more shape information (hlr_bulge, hlr_disk, e1_disk, e2_disk, e1_bulge, e2_bulge) is missing' + self.chip_output.Log_error(msg) + return False + return True + def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): @@ -85,6 +101,9 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): # break obj = cat.objs[j] + if not self._is_obj_valid(obj): + continue + # load and convert SED; also caculate object's magnitude in all CSST bands try: sed_data = cat.load_sed(obj) @@ -153,7 +172,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): if pos_img.x == -1 or pos_img.y == -1: self.chip_output.Log_info('obj_ra = %.6f, obj_dec = %.6f, obj_ra_orig = %.6f, obj_dec_orig = %.6f' % ( obj.ra, obj.dec, obj.ra_orig, obj.dec_orig)) - self.chip_output.Log_error("Objected missed: %s" % (obj.id)) + self.chip_output.Log_error("Object missed: %s" % (obj.id)) missed_obj += 1 obj.unload_SED() continue @@ -199,7 +218,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): pass elif isUpdated == 0: missed_obj += 1 - self.chip_output.Log_error("Objected missed: %s" % (obj.id)) + self.chip_output.Log_error("Object missed: %s" % (obj.id)) else: self.chip_output.Log_error( "Draw error, object omitted: %s" % (obj.id)) -- GitLab