diff --git a/ObservationSim/SimSteps.py b/ObservationSim/SimSteps.py index 5b7c8bf86d2f0b3c9d0f8789ae2fc9d7d525c665..ecb484e6494d6df249246fddea9d7b611844fa59 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 99847ee21c9df034428663039003d2cb4169c0f9..933c6e09d65f493ffb374e927d62799156bfb1f0 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 df6203a8a0911acdb25ccbaf65d7b43e31918ca1..428363715e0bdf70b1f132d6dfd0fcade3f6db28 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