Commit 3a8a4fbc authored by Fang Yuedong's avatar Fang Yuedong
Browse files

1. Add margin options for magnitude cuts

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