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
csst-sims
csst_ifs_sim
Commits
f06d91d2
Commit
f06d91d2
authored
Oct 08, 2024
by
Yan Zhaojun
Browse files
update
parent
41940f8c
Pipeline
#6971
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
csst_ifs_sim/csst_ifs_sim.py
View file @
f06d91d2
...
...
@@ -238,7 +238,7 @@ class CDM03bidir():
#################################################################################
###modify
#sys.path.append('../so')
from
.ifs_so
import
cdm03bidir
#
from .ifs_so import cdm03bidir
try
:
from
ifs_so
import
cdm03bidir
except
:
...
...
@@ -535,6 +535,14 @@ class cosmicrays():
:return: None
"""
if
coveringFraction
>
1
or
coveringFraction
<
0.1
:
self
.
log
.
error
(
'coveringFraction error, it shoub be in [0.1, 1]!'
)
raise
ValueError
(
'coveringFraction error, it shoub be in [0.1, 1]!'
)
self
.
cosmicrayMap
=
np
.
zeros
((
self
.
ysize
,
self
.
xsize
))
#how many events to draw at once, too large number leads to exceeding the covering fraction
...
...
@@ -2378,6 +2386,57 @@ class IFSsimulator():
self
.
log
.
info
(
'Added dark current to bule and red channel'
)
if
self
.
information
[
'dark1_b'
]
>
0.001
or
self
.
information
[
'dark1_b'
]
>
0.001
:
self
.
log
.
error
(
'dark1_b value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark1_b value error, it shoub be in [0.0001, 0.001]!'
)
if
self
.
information
[
'dark2_b'
]
>
0.001
or
self
.
information
[
'dark2_b'
]
>
0.001
:
self
.
log
.
error
(
'dark2_b value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark2_b value error, it shoub be in [0.0001, 0.001]!'
)
if
self
.
information
[
'dark3_b'
]
>
0.001
or
self
.
information
[
'dark3_b'
]
>
0.001
:
self
.
log
.
error
(
'dark3_b value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark3_b value error, it shoub be in [0.0001, 0.001]!'
)
if
self
.
information
[
'dark4_b'
]
>
0.001
or
self
.
information
[
'dark4_b'
]
>
0.001
:
self
.
log
.
error
(
'dark4_b value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark4_b value error, it shoub be in [0.0001, 0.001]!'
)
####################################################################
if
self
.
information
[
'dark1_r'
]
>
0.001
or
self
.
information
[
'dark1_r'
]
>
0.001
:
self
.
log
.
error
(
'dark1_r value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark1_r value error, it shoub be in [0.0001, 0.001]!'
)
if
self
.
information
[
'dark2_r'
]
>
0.001
or
self
.
information
[
'dark2_r'
]
>
0.001
:
self
.
log
.
error
(
'dark2_r value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark2_r value error, it shoub be in [0.0001, 0.001]!'
)
if
self
.
information
[
'dark3_r'
]
>
0.001
or
self
.
information
[
'dark3_r'
]
>
0.001
:
self
.
log
.
error
(
'dark3_r value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark3_r value error, it shoub be in [0.0001, 0.001]!'
)
if
self
.
information
[
'dark4_r'
]
>
0.001
or
self
.
information
[
'dark4_r'
]
>
0.001
:
self
.
log
.
error
(
'dark4_r value error, it shoub be in [0.0001, 0.001]!'
)
raise
ValueError
(
'dark4_r value error, it shoub be in [0.0001, 0.001]!'
)
###########################################################################
# blue zone 4
self
.
image_b
[
0
:
1024
,
0
:
2048
]
+=
self
.
information
[
'exptime'
]
*
\
self
.
information
[
'dark4_b'
]
...
...
@@ -2597,6 +2656,59 @@ class IFSsimulator():
average=0.0 and std=readout noise.
"""
self
.
log
.
info
(
'readnoise added in blue channel'
)
if
self
.
information
[
'rn1_b'
]
>
10
or
self
.
information
[
'rn1_b'
]
<
3
:
self
.
log
.
error
(
'rn1_b value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn1_b value error, it shoub be in [3, 10]!'
)
if
self
.
information
[
'rn2_b'
]
>
10
or
self
.
information
[
'rn2_b'
]
<
3
:
self
.
log
.
error
(
'rn2_b value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn2_b value error, it shoub be in [3, 10]!'
)
if
self
.
information
[
'rn3_b'
]
>
10
or
self
.
information
[
'rn3_b'
]
<
3
:
self
.
log
.
error
(
'rn3_b value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn3_b value error, it shoub be in [3, 10]!'
)
if
self
.
information
[
'rn4_b'
]
>
10
or
self
.
information
[
'rn4_b'
]
<
3
:
self
.
log
.
error
(
'rn4_b value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn4_b value error, it shoub be in [3, 10]!'
)
####################################################################
if
self
.
information
[
'rn1_r'
]
>
10
or
self
.
information
[
'rn1_r'
]
<
3
:
self
.
log
.
error
(
'rn1_r value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn1_r value error, it shoub be in [3, 10]!'
)
if
self
.
information
[
'rn2_r'
]
>
10
or
self
.
information
[
'rn2_r'
]
<
3
:
self
.
log
.
error
(
'rn2_r value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn2_r value error, it shoub be in [3, 10]!'
)
if
self
.
information
[
'rn3_r'
]
>
10
or
self
.
information
[
'rn3_r'
]
<
3
:
self
.
log
.
error
(
'rn3_r value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn3_r value error, it shoub be in [3, 10]!'
)
if
self
.
information
[
'rn4_r'
]
>
10
or
self
.
information
[
'rn4_r'
]
<
3
:
self
.
log
.
error
(
'rn4_r value error, it shoub be in [3, 10]!'
)
raise
ValueError
(
'rn4_r value error, it shoub be in [3, 10]!'
)
########################################################33
# blue zone 1
np
.
random
.
seed
()
prescan
=
50
...
...
@@ -2715,6 +2827,56 @@ class IFSsimulator():
"""
Convert from electrons to ADUs using the value read from the configuration file.
"""
if
self
.
information
[
'gain1_b'
]
>
2
or
self
.
information
[
'gain1_b'
]
<
1
:
self
.
log
.
error
(
'gain1_b value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain1_b value error, it shoub be in [1, 2]!'
)
if
self
.
information
[
'gain2_b'
]
>
2
or
self
.
information
[
'gain2_b'
]
<
1
:
self
.
log
.
error
(
'gain2_b value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain2_b value error, it shoub be in [1, 2]!'
)
if
self
.
information
[
'gain3_b'
]
>
2
or
self
.
information
[
'gain3_b'
]
<
1
:
self
.
log
.
error
(
'gain3_b value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain3_b value error, it shoub be in [1, 2]!'
)
if
self
.
information
[
'gain4_b'
]
>
2
or
self
.
information
[
'gain4_b'
]
<
1
:
self
.
log
.
error
(
'gain4_b value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain4_b value error, it shoub be in [1, 2]!'
)
####################################################################
if
self
.
information
[
'gain1_r'
]
>
2
or
self
.
information
[
'gain1_r'
]
<
1
:
self
.
log
.
error
(
'gain1_r value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain1_r value error, it shoub be in [1, 2]!'
)
if
self
.
information
[
'gain2_r'
]
>
2
or
self
.
information
[
'gain2_r'
]
<
1
:
self
.
log
.
error
(
'gain2_r value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain2_r value error, it shoub be in [1, 2]!'
)
if
self
.
information
[
'gain3_r'
]
>
2
or
self
.
information
[
'gain3_r'
]
<
1
:
self
.
log
.
error
(
'gain3_r value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain3_r value error, it shoub be in [1, 2]!'
)
if
self
.
information
[
'gain4_r'
]
>
2
or
self
.
information
[
'gain4_r'
]
<
1
:
self
.
log
.
error
(
'gain4_r value error, it shoub be in [1, 2]!'
)
raise
ValueError
(
'gain4_r value error, it shoub be in [1, 2]!'
)
####################################################################
self
.
log
.
info
(
'Converting from electrons to ADUs using a factor of gain'
)
...
...
@@ -2762,8 +2924,60 @@ class IFSsimulator():
The value of bias is read from the configure file and stored
in the information dictionary (key bias).
"""
if
self
.
information
[
'bias1_b'
]
>
2000
or
self
.
information
[
'bias1_b'
]
<
100
:
self
.
log
.
error
(
'bias1_b value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias1_b value error, it shoub be in [100, 2000]!'
)
if
self
.
information
[
'bias2_b'
]
>
2000
or
self
.
information
[
'bias2_b'
]
<
100
:
self
.
log
.
error
(
'bias2_b value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias2_b value error, it shoub be in [100, 2000]!'
)
if
self
.
information
[
'bias3_b'
]
>
2000
or
self
.
information
[
'bias3_b'
]
<
100
:
self
.
log
.
error
(
'bias3_b value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias3_b value error, it shoub be in [100, 2000]!'
)
if
self
.
information
[
'bias4_b'
]
>
2000
or
self
.
information
[
'bias4_b'
]
<
100
:
self
.
log
.
error
(
'bias4_b value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias4_b value error, it shoub be in [100, 2000]!'
)
####################################################################
if
self
.
information
[
'bias1_r'
]
>
2000
or
self
.
information
[
'bias1_r'
]
<
100
:
self
.
log
.
error
(
'bias1_r value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias1_r value error, it shoub be in [100, 2000]!'
)
if
self
.
information
[
'bias2_r'
]
>
2000
or
self
.
information
[
'bias2_r'
]
<
100
:
self
.
log
.
error
(
'bias2_r value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias2_r value error, it shoub be in [100, 2000]!'
)
if
self
.
information
[
'bias3_r'
]
>
2000
or
self
.
information
[
'bias3_r'
]
<
100
:
self
.
log
.
error
(
'bias3_r value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias3_r value error, it shoub be in [100, 2000]!'
)
if
self
.
information
[
'bias4_r'
]
>
2000
or
self
.
information
[
'bias4_r'
]
<
100
:
self
.
log
.
error
(
'bias4_r value error, it shoub be in [100, 2000]!'
)
raise
ValueError
(
'bias4_r value error, it shoub be in [100, 2000]!'
)
########################################################################
# blue zone 4
self
.
image_b
[
0
:
1344
,
0
:
2418
]
+=
self
.
information
[
'bias4_b'
]
...
...
@@ -5480,6 +5694,12 @@ class IFSsimulator():
self
.
dt
=
datetime
.
utcnow
()
if
self
.
information
[
'exptime'
]
>
2000
or
self
.
information
[
'exptime'
]
<
0
:
self
.
log
.
error
(
'exptime value error, it shoub be in [0, 2000]!'
)
exit
(
2
)
if
self
.
source
==
'SCI'
or
self
.
source
==
'COMP'
:
if
simnumber
<=
50
and
simnumber
>
20
:
...
...
@@ -5624,7 +5844,7 @@ class IFSsimulator():
else
:
print
(
'Souce is not correct and programe will return'
)
exit
(
1
)
raise
ValueError
(
'Souce is not correct and programe will return'
)
###############################################################################
# save the original image firstly;
self
.
image_b_ori
=
self
.
image_b
+
10.0
...
...
tests/test_ifs_sim.py
View file @
f06d91d2
...
...
@@ -13,6 +13,8 @@ import unittest
import
os
from
csst_ifs_sim
import
csst_ifs_sim
sys
.
path
.
append
(
'IFS_git/csst_ifs_sim/csst_ifs_sim'
)
import
sys
class
TestDemoFunction
(
unittest
.
TestCase
):
...
...
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