From 053e60790e74af606e015e380f130815f307a3e4 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Mon, 25 Mar 2024 13:29:19 +0800 Subject: [PATCH] merge accuracy skybackground model and set sky background back model --- ObservationSim/SimSteps.py | 21 ++++++++++++++++++++- config/obs_config_Calibration.yaml | 9 ++++++++- config/obs_config_SCI_WIDE_phot.yaml | 5 +++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ObservationSim/SimSteps.py b/ObservationSim/SimSteps.py index 5b7c8bf..ecb484e 100644 --- a/ObservationSim/SimSteps.py +++ b/ObservationSim/SimSteps.py @@ -109,6 +109,25 @@ class SimSteps: return chip, filt, tel, pointing def add_sky_background(self, chip, filt, tel, pointing, catalog, obs_param): + if not hasattr(self, 'h_ext'): + _, _ = self.prepare_headers(chip=chip, pointing=pointing) + chip_wcs = galsim.FitsWCS(header = self.h_ext) + + if "flat_level" not in obs_param or "flat_level_filt" not in obs_param: + chip, filt, tel, pointing = self.add_sky_background_sci(chip, filt, tel, pointing, catalog, obs_param) + else: + if obs_param.get('flat_level') is None or obs_param.get('flat_level_filt')is None: + chip, filt, tel, pointing = self.add_sky_background_sci(chip, filt, tel, pointing, catalog, obs_param) + else: + chip, filt, tel, pointing = self.add_sky_flat_calibration(chip, filt, tel, pointing, catalog, obs_param) + + chip, filt, tel, pointing = self.add_sky_background_sci(chip, filt, tel, pointing, catalog, obs_param) + + return chip, filt, tel, pointing + + + + def add_sky_background_sci(self, chip, filt, tel, pointing, catalog, obs_param): flat_normal = np.ones_like(chip.img.array) if obs_param["flat_fielding"] == True: flat_normal = flat_normal * chip.flat_img.array / np.mean(chip.flat_img.array) @@ -524,5 +543,5 @@ SIM_STEP_TYPES = { "gain": "apply_gain", "quantization_and_output": "quantization_and_output", "led_calib_model":"add_LED_Flat", - "sky_flatField":"add_sky_flat_calibration", + # "sky_flatField":"add_sky_flat_calibration", } \ No newline at end of file diff --git a/config/obs_config_Calibration.yaml b/config/obs_config_Calibration.yaml index 99847ee..933c6e0 100644 --- a/config/obs_config_Calibration.yaml +++ b/config/obs_config_Calibration.yaml @@ -24,12 +24,19 @@ call_sequence: LED_TYPE: ['LED5'] LED_TIME: [1.] - sky_flatField: + + # flat_level: set the total skybackground value (e-) in the exptime,if none,set null, or delete the key + # flat_level_filt: the vale of "flat_level" is in the filter "flat_level_filt", can set NUV, u, g, r, i, z, y, if + # none,set null,or delete the key + + sky_background: exptime: 150. # [s] shutter_effect: YES flat_fielding: YES + enable_straylight_model: YES flat_level: 20000 flat_level_filt: g + # Apply PRNU to accumulated photons PRNU_effect: {} # Accumulate photons caused by cosmic rays diff --git a/config/obs_config_SCI_WIDE_phot.yaml b/config/obs_config_SCI_WIDE_phot.yaml index df6203a..4283637 100644 --- a/config/obs_config_SCI_WIDE_phot.yaml +++ b/config/obs_config_SCI_WIDE_phot.yaml @@ -23,11 +23,16 @@ call_sequence: flat_fielding: YES field_dist: YES # Accumulate fluxes from sky background + # flat_level: set the total skybackground value (e-) in the exptime,if none,set null, or delete the key + # flat_level_filt: the vale of "flat_level" is in the filter "flat_level_filt", can set NUV, u, g, r, i, z, y, if + # none,set null,or delete the key sky_background: exptime: 150. # [s] shutter_effect: YES flat_fielding: YES enable_straylight_model: YES + flat_level: null + flat_level_filt: null # Apply PRNU to accumulated photons PRNU_effect: {} # Accumulate photons caused by cosmic rays -- GitLab