Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Liu Dezi
csst_msc_sim
Commits
22b1b8e8
Commit
22b1b8e8
authored
Jul 04, 2022
by
Fang Yuedong
Browse files
change the logical of adding Poisson noise in Chip.py
parent
da9c9fbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
ObservationSim/Instrument/Chip/Chip.py
View file @
22b1b8e8
...
...
@@ -316,9 +316,22 @@ class Chip(FocalPlane):
BoolDeadPix
=
False
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
if
sky_map
is
None
:
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
:
raise
ValueError
(
"The shape img and sky_map must be equal."
)
elif
tel
is
not
None
:
# If sky_map is given in flux
...
...
@@ -361,11 +374,11 @@ class Chip(FocalPlane):
del
shutt_gsimg
del
shuttimg
# Add Poisson noise
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.
)
img
.
addNoise
(
poisson_noise
)
# Add Poisson noise
to the resulting images
# (NOTE): this can only applied to the slitless image
# since it dose not use photon shooting to draw stamps
if
self
.
survey_type
==
"spectroscopic"
:
img
.
addNoise
(
poisson_noise
)
# Add cosmic-rays
if
config
[
"ins_effects"
][
"cosmic_ray"
]
==
True
and
pointing_type
==
'MS'
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment