diff --git a/Catalog/NGPCatalog.py b/Catalog/NGPCatalog.py index ead36a5b2516d1c1c3abc85e2db0d994908a7bcd..15e195c7ace8150f34b74d4f4e3937fcd4982550 100644 --- a/Catalog/NGPCatalog.py +++ b/Catalog/NGPCatalog.py @@ -32,9 +32,9 @@ class NGPCatalog(CatalogBase): self.logger = chip_output.logger with pkg_resources.path('Catalog.data', 'SLOAN_SDSS.g.fits') as filter_path: - self.normF_star = Table.read(str(filter_path)) + self.normF_star = Table.read(str(filter_path)) with pkg_resources.path('Catalog.data', 'lsst_throuput_g.fits') as filter_path: - self.normF_galaxy = Table.read(str(filter_path)) + self.normF_galaxy = Table.read(str(filter_path)) self.config = config self.chip = chip diff --git a/ObservationSim/Instrument/Filter.py b/ObservationSim/Instrument/Filter.py index 552a53e2ccf93aa24468d48d82c8ca89a48988cd..0e8fa49822987abfd33e89584904a7d948928ab5 100755 --- a/ObservationSim/Instrument/Filter.py +++ b/ObservationSim/Instrument/Filter.py @@ -39,12 +39,12 @@ class Filter(object): self.mag_limiting = filter_param.param[filter_type][7] # self.filter_dir = filter_param.filter_dir - def is_too_bright(self, mag): - return mag <= self.mag_saturation - 2.5 + def is_too_bright(self, mag, margin=-2.5): + return mag <= self.mag_saturation + margin # return mag <= 14.0 - def is_too_dim(self, mag): - return mag >= self.mag_limiting + 1.0 + def is_too_dim(self, mag, margin=1.0): + return mag >= self.mag_limiting + margin def _get_bandpasses(self, filter_dir=None, unit='A'): if self.filter_id < 7: # Photometric diff --git a/ObservationSim/MockObject/CatalogBase.py b/ObservationSim/MockObject/CatalogBase.py index 9ca1482d2bbec8f5bb71acc153bfcbc1aec5f2a4..bc7f6e6e2d7d399f8259e80533a2faa577e1fb4b 100644 --- a/ObservationSim/MockObject/CatalogBase.py +++ b/ObservationSim/MockObject/CatalogBase.py @@ -88,7 +88,7 @@ class CatalogBase(metaclass=ABCMeta): bandpass=bandpass ) if target_filt.survey_type == "photometric": - return sed_photon, mag_csst + return sed_photon, mag_csst, interFlux elif target_filt.survey_type == "spectroscopic": del sed_photon - return sed, mag_csst \ No newline at end of file + return sed, mag_csst, interFlux \ No newline at end of file diff --git a/ObservationSim/MockObject/MockObject.py b/ObservationSim/MockObject/MockObject.py index f5270fc0a6da045a5071320b131e6de4f4cb82db..4bdb2a9a9859f32590c7d9140e5c044109dc316e 100755 --- a/ObservationSim/MockObject/MockObject.py +++ b/ObservationSim/MockObject/MockObject.py @@ -54,16 +54,21 @@ class MockObject(object): return self.param["mag_%s"%filt.filter_type] # (TEST) stamp size # return 13.0 + + def getFluxFilter(self, filt): + return self.param["flux_%s"%filt.filter_type] def getNumPhotons(self, flux, tel, exptime=150.): pupil_area = tel.pupil_area * (100.)**2 # m^2 to cm^2 return flux * pupil_area * exptime def getElectronFluxFilt(self, filt, tel, exptime=150.): - photonEnergy = filt.getPhotonE() - flux = magToFlux(self.getMagFilter(filt)) - factor = 1.0e4 * flux/photonEnergy * VC_A * (1.0/filt.blue_limit - 1.0/filt.red_limit) - return factor * filt.efficiency * tel.pupil_area * exptime + # photonEnergy = filt.getPhotonE() + # flux = magToFlux(self.getMagFilter(filt)) + # factor = 1.0e4 * flux/photonEnergy * VC_A * (1.0/filt.blue_limit - 1.0/filt.red_limit) + # return factor * filt.efficiency * tel.pupil_area * exptime + flux = self.getFluxFilter(filt) + return flux * tel.pupil_area * exptime def getPosWorld(self): ra = self.param["ra"] diff --git a/ObservationSim/ObservationSim.py b/ObservationSim/ObservationSim.py index 22cef071afe26921c7467944b409a0641497e4f7..4ca0669e0065792472db544b399870cc5095f18d 100755 --- a/ObservationSim/ObservationSim.py +++ b/ObservationSim/ObservationSim.py @@ -193,13 +193,13 @@ class Observation(object): try: sed_data = self.cat.load_sed(obj) norm_filt = self.cat.load_norm_filt(obj) - obj.sed, obj.param["mag_%s"%filt.filter_type] = self.cat.convert_sed( + obj.sed, obj.param["mag_%s"%filt.filter_type], obj.param["flux_%s"%filt.filter_type] = self.cat.convert_sed( mag=obj.param["mag_use_normal"], sed=sed_data, target_filt=filt, norm_filt=norm_filt, ) - _, obj.param["mag_%s"%cut_filter.filter_type] = self.cat.convert_sed( + _, obj.param["mag_%s"%cut_filter.filter_type], obj.param["flux_%s"%cut_filter.filter_type] = self.cat.convert_sed( mag=obj.param["mag_use_normal"], sed=sed_data, target_filt=cut_filter, @@ -216,13 +216,17 @@ class Observation(object): # Exclude very bright/dim objects (for now) # if filt.is_too_bright(mag=obj.getMagFilter(filt)): # if filt.is_too_bright(mag=obj.mag_use_normal): - if cut_filter.is_too_bright(mag=obj.param["mag_%s"%self.config["obs_setting"]["cut_in_band"].lower()]): + if cut_filter.is_too_bright( + mag=obj.param["mag_%s"%self.config["obs_setting"]["cut_in_band"].lower()], + margin=self.config["obs_setting"]["mag_sat_margin"]): # print("obj too birght!!", flush=True) if obj.type != 'galaxy': bright_obj += 1 obj.unload_SED() continue - if filt.is_too_dim(mag=obj.getMagFilter(filt)): + if filt.is_too_dim( + mag=obj.getMagFilter(filt), + margin=self.config["obs_setting"]["mag_lim_margin"]): # if cut_filter.is_too_dim(mag=obj.param["mag_%s"%self.config["obs_setting"]["cut_in_band"].lower()]): # print("obj too dim!!", flush=True) dim_obj += 1 diff --git a/config/config_NGP_dev.yaml b/config/config_NGP_dev.yaml index 78777e871276337f52cac6c5eafbbf258b0593b7..86aca7e40c10890d4e3f01a80e950a40c46a836e 100644 --- a/config/config_NGP_dev.yaml +++ b/config/config_NGP_dev.yaml @@ -12,14 +12,16 @@ # work_dir: "/public/home/fangyuedong/sim_code_release/CSST/test/" work_dir: "/public/home/fangyuedong/test/CSST/workplace/" data_dir: "/data/simudata/CSSOSDataProductsSims/data/" -run_name: "TEST_16channel_off" +run_name: "v0.5_TEST" # (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_dir: "/data/simudata/CSSOSDataProductsSims/data/" +pointing_dir: "/public/home/fangyuedong/test/CSST/test_20220622/" pointing_file: "pointing_test_NGP_2.17.dat" +# pointing_file: "pointing_test_case2.dat" # Whether to use MPI run_option: @@ -79,7 +81,7 @@ obs_setting: # - give a list of indexes of chips: [ip_1, ip_2...] # - run all chips: null # Note: for all pointings - run_chips: [24] + run_chips: null # Whether to enable astrometric modeling # astrometric_lib: "libshao.so" @@ -88,6 +90,12 @@ obs_setting: # Cut by saturation/limiting magnitude in which band? cut_in_band: "g" + # saturation magnitude margin + mag_sat_margin: -2.5 + + # limiting magnitude margin + mag_lim_margin: +1.0 + ############################################### # Input path setting ############################################### @@ -160,22 +168,22 @@ ins_effects: field_dist: ON # Whether to add field distortions add_back: ON # Whether to add sky background add_dark: ON # Whether to add dark noise - add_readout: ON # Whether to add read-out (Gaussian) noise - add_bias: ON # Whether to add bias-level to images + add_readout: ON # Whether to add read-out (Gaussian) noise + add_bias: ON # Whether to add bias-level to images bias_16channel: ON # Whether to add different biases for 16 channels gain_16channel: ON # Whether to make different gains for 16 channels - shutter_effect: ON # Whether to add shutter effect - flat_fielding: ON # Whether to add flat-fielding effect - prnu_effect: ON # Whether to add PRNU effect - non_linear: ON # Whether to add non-linearity - cosmic_ray: ON # Whether to add cosmic-ray - cray_differ: ON # Whether to generate different cosmic ray maps CAL and MS output - cte_trail: ON # Whether to simulate CTE trails - saturbloom: ON # Whether to simulate Saturation & Blooming - add_badcolumns: ON # Whether to add bad columns - add_hotpixels: ON # Whether to add hot pixels - add_deadpixels: ON # Whether to add dead(dark) pixels - bright_fatter: ON # Whether to simulate Brighter-Fatter (also diffusion) effect + shutter_effect: ON # Whether to add shutter effect + flat_fielding: ON # Whether to add flat-fielding effect + prnu_effect: ON # Whether to add PRNU effect + non_linear: ON # Whether to add non-linearity + cosmic_ray: ON # Whether to add cosmic-ray + cray_differ: ON # Whether to generate different cosmic ray maps CAL and MS output + cte_trail: ON # Whether to simulate CTE trails + saturbloom: ON # Whether to simulate Saturation & Blooming + add_badcolumns: ON # Whether to add bad columns + add_hotpixels: ON # Whether to add hot pixels + add_deadpixels: ON # Whether to add dead(dark) pixels + bright_fatter: ON # Whether to simulate Brighter-Fatter (also diffusion) effect # values dark_exptime: 300 # Exposure time for dark current frames [seconds] diff --git a/run_sim.py b/run_sim.py index 483db6872dcb0de09c8a7db99ef5d264eead9dbc..23a5105c34cfc3c996f1cf478e2898ebd6e88269 100755 --- a/run_sim.py +++ b/run_sim.py @@ -49,10 +49,14 @@ def run_sim(Catalog): config['work_dir'] = args.work_dir # Some default values - if "bias_16channel" not in config: - config["bias_16channel"] = False - if "gain_16channel" not in config: - config["gain_16channel"] = False + if "bias_16channel" not in config["ins_effects"]: + config["ins_effects"]["bias_16channel"] = False + if "gain_16channel" not in config["ins_effects"]: + config["ins_effects"]["gain_16channel"] = False + if "mag_sat_margin" not in config["obs_setting"]: + config["obs_setting"]["mag_sat_margin"] = -2.5 + if "mag_lim_margin" not in config["obs_setting"]: + config["obs_setting"]["mag_lim_margin"] = 1.0 # Generate lists pointings based on the input pointing list (or default # pointing RA, DEC) and "config["obs_setting"]["run_pointings"]".