Commit a8977496 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

Merge branch 'master' into release_v0.5

parents 67bcd735 be11dd52
...@@ -316,9 +316,22 @@ class Chip(FocalPlane): ...@@ -316,9 +316,22 @@ class Chip(FocalPlane):
BoolDeadPix = False BoolDeadPix = False
self.logger = logger self.logger = logger
# Get Poisson noise generator
seed = int(config["random_seeds"]["seed_poisson"]) + pointing_ID*30 + self.chipID
rng_poisson = galsim.BaseDeviate(seed)
poisson_noise = galsim.PoissonNoise(rng_poisson, sky_level=0.)
# Add sky background # Add sky background
if sky_map is None: if sky_map is None:
sky_map = filt.getSkyNoise(exptime=self.exptime) sky_map = filt.getSkyNoise(exptime=self.exptime)
sky_map = sky_map * np.ones_like(img.array)
sky_map = galsim.Image(array=sky_map)
# Apply Poisson noise to the sky map
# (NOTE): only for photometric chips
# since it utilize the photon shooting
# to draw stamps
if self.survey_type == "photometric":
sky_map.addNoise(poisson_noise)
elif img.array.shape != sky_map.shape: elif img.array.shape != sky_map.shape:
raise ValueError("The shape img and sky_map must be equal.") raise ValueError("The shape img and sky_map must be equal.")
elif tel is not None: # If sky_map is given in flux elif tel is not None: # If sky_map is given in flux
...@@ -361,11 +374,11 @@ class Chip(FocalPlane): ...@@ -361,11 +374,11 @@ class Chip(FocalPlane):
del shutt_gsimg del shutt_gsimg
del shuttimg del shuttimg
# Add Poisson noise # Add Poisson noise to the resulting images
seed = int(config["random_seeds"]["seed_poisson"]) + pointing_ID*30 + self.chipID # (NOTE): this can only applied to the slitless image
rng_poisson = galsim.BaseDeviate(seed) # since it dose not use photon shooting to draw stamps
poisson_noise = galsim.PoissonNoise(rng_poisson, sky_level=0.) if self.survey_type == "spectroscopic":
img.addNoise(poisson_noise) img.addNoise(poisson_noise)
# Add cosmic-rays # Add cosmic-rays
if config["ins_effects"]["cosmic_ray"] == True and pointing_type=='MS': if config["ins_effects"]["cosmic_ray"] == True and pointing_type=='MS':
...@@ -580,7 +593,7 @@ class Chip(FocalPlane): ...@@ -580,7 +593,7 @@ class Chip(FocalPlane):
if config["ins_effects"]["add_bias"] == True: if config["ins_effects"]["add_bias"] == True:
biaslevel = self.bias_level biaslevel = self.bias_level
overscan = biaslevel-2 overscan = biaslevel-2
elif config["ins_effects"]["add_bias"] == True: elif config["ins_effects"]["add_bias"] == False:
biaslevel = 0 biaslevel = 0
overscan = 0 overscan = 0
darklevel = self.dark_noise*(self.flat_exptime+0.5*self.readout_time) darklevel = self.dark_noise*(self.flat_exptime+0.5*self.readout_time)
......
...@@ -26,7 +26,7 @@ extensions = [ ...@@ -26,7 +26,7 @@ extensions = [
setup(name='CSSTSim', setup(name='CSSTSim',
version='0.5.1', version='0.5.2',
packages=find_packages(), packages=find_packages(),
# install_requires=[ # install_requires=[
# 'numpy>=1.18.5', # 'numpy>=1.18.5',
......
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