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
7ae8c85f
Commit
7ae8c85f
authored
Jan 08, 2025
by
Yan Zhaojun
Browse files
update
parent
0c74ea42
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
csst_ifs_sim/__init__.py
View file @
7ae8c85f
__version__
=
"3.0.1"
csst_ifs_sim/csst_ifs_sim.py
View file @
7ae8c85f
...
...
@@ -356,7 +356,7 @@ class cosmicrays():
exposure time.
"""
def
__init__
(
self
,
log
,
image
,
crInfo
=
None
,
information
=
None
):
def
__init__
(
self
,
log
,
image
,
exposuretime
,
crInfo
=
None
,
information
=
None
):
"""
Cosmic ray generation class. Can either draw events from distributions or
set the energy of the events to a constant.
...
...
@@ -376,8 +376,7 @@ class cosmicrays():
# set up the information dictionary, first with defaults and then overwrite with inputs if given
self
.
information
=
(
dict
(
cosmicraylengths
=
'/home/yan/csst-master/data/cdf_cr_length.dat'
,
cosmicraydistance
=
'/home/yan/csst-master/data/cdf_cr_total.dat'
,
exptime
=
565
))
cosmicraydistance
=
'/home/yan/csst-master/data/cdf_cr_total.dat'
,
exptime
=
exposuretime
))
if
information
is
not
None
:
self
.
information
.
update
(
information
)
...
...
@@ -520,12 +519,6 @@ 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
...
...
@@ -2164,74 +2157,76 @@ class IFSsimulator():
return
FlatMat
####################################################################
def
getFrameTransferImg
(
self
):
"""
Returns
-------
None.
"""
"""
get frame transfer image from original image of self.image_b and self.image_r
"""
self
.
frame_b_4
=
np
.
zeros
((
1024
+
320
,
2048
),
dtype
=
float
)
self
.
frame_b_3
=
np
.
zeros
((
1024
+
320
,
2048
),
dtype
=
float
)
self
.
frame_b_2
=
np
.
zeros
((
1024
+
320
,
2048
),
dtype
=
float
)
self
.
frame_b_1
=
np
.
zeros
((
1024
+
320
,
2048
),
dtype
=
float
)
self
.
frame_r_4
=
np
.
zeros
((
1536
+
320
,
3072
),
dtype
=
float
)
self
.
frame_r_3
=
np
.
zeros
((
1536
+
320
,
3072
),
dtype
=
float
)
self
.
frame_r_2
=
np
.
zeros
((
1536
+
320
,
3072
),
dtype
=
float
)
self
.
frame_r_1
=
np
.
zeros
((
1536
+
320
,
3072
),
dtype
=
float
)
# blue channle
b_4
=
np
.
sum
(
self
.
image_b
[
0
:
1024
,
0
:
2048
],
axis
=
0
)
# flip right to left of part3 and part2
temp_b_3
=
np
.
fliplr
(
self
.
image_b
[
0
:
1024
,
2048
:
4096
])
# left to right
b_3
=
np
.
sum
(
temp_b_3
,
axis
=
0
)
temp_b_2
=
np
.
fliplr
(
self
.
image_b
[
1024
:
1024
+
1024
,
2048
:
2048
+
2048
])
# left to right
b_2
=
np
.
sum
(
temp_b_2
,
axis
=
0
)
b_1
=
np
.
sum
(
self
.
image_b
[
1024
:
1024
+
1024
,
0
:
2048
],
axis
=
0
)
####
for
k
in
range
(
1024
+
320
):
# part
self
.
frame_b_4
[
k
,
:]
+=
b_4
*
0.09216
/
self
.
information
[
'exptime'
]
self
.
frame_b_3
[
k
,
:]
+=
b_3
*
0.09216
/
self
.
information
[
'exptime'
]
self
.
frame_b_2
[
k
,
:]
+=
b_2
*
0.09216
/
self
.
information
[
'exptime'
]
self
.
frame_b_1
[
k
,
:]
+=
b_1
*
0.09216
/
self
.
information
[
'exptime'
]
###################
# red channle
r_4
=
np
.
sum
(
self
.
image_r
[
0
:
1536
,
0
:
3072
],
axis
=
0
)
# flip right to left of part3 and part2
temp_r_3
=
np
.
fliplr
(
self
.
image_r
[
0
:
1536
,
3072
:
6144
])
# left to right
r_3
=
np
.
sum
(
temp_r_3
,
axis
=
0
)
temp_r_2
=
np
.
fliplr
(
self
.
image_r
[
1536
:
1536
+
1536
,
3072
:
6144
])
# left to right
r_2
=
np
.
sum
(
temp_r_2
,
axis
=
0
)
# r_3 = np.sum(self.image_r[0:1536, 3072:6144], axis=0)
# r_2 = np.sum(self.image_r[1536:1536+1536, 3072:6144], axis=0)
r_1
=
np
.
sum
(
self
.
image_r
[
1536
:
1536
+
1536
,
0
:
3072
],
axis
=
0
)
for
k
in
range
(
1536
+
320
):
# part 4, OSH zone;
self
.
frame_r_4
[
k
,
:]
+=
r_4
*
0.13824
/
self
.
information
[
'exptime'
]
self
.
frame_r_3
[
k
,
:]
+=
r_3
*
0.13824
/
self
.
information
[
'exptime'
]
self
.
frame_r_2
[
k
,
:]
+=
r_2
*
0.13824
/
self
.
information
[
'exptime'
]
self
.
frame_r_1
[
k
,
:]
+=
r_1
*
0.13824
/
self
.
information
[
'exptime'
]
# end
def
getFrameTransferImg
(
self
):
"""
Returns
-------
None.
"""
"""
get frame transfer image from original image of self.image_b and self.image_r
"""
overscan
=
320
self
.
frame_b_4
=
np
.
zeros
((
1024
+
overscan
,
2048
),
dtype
=
float
)
self
.
frame_b_3
=
np
.
zeros
((
1024
+
overscan
,
2048
),
dtype
=
float
)
self
.
frame_b_2
=
np
.
zeros
((
1024
+
overscan
,
2048
),
dtype
=
float
)
self
.
frame_b_1
=
np
.
zeros
((
1024
+
overscan
,
2048
),
dtype
=
float
)
self
.
frame_r_4
=
np
.
zeros
((
1536
+
overscan
,
3072
),
dtype
=
float
)
self
.
frame_r_3
=
np
.
zeros
((
1536
+
overscan
,
3072
),
dtype
=
float
)
self
.
frame_r_2
=
np
.
zeros
((
1536
+
overscan
,
3072
),
dtype
=
float
)
self
.
frame_r_1
=
np
.
zeros
((
1536
+
overscan
,
3072
),
dtype
=
float
)
# OSH, part2 ,no change
b_2
=
np
.
sum
(
self
.
image_b
[
0
:
1024
,
0
:
2048
],
axis
=
0
)
# flip right to left of part1
temp_b_1
=
np
.
fliplr
(
self
.
image_b
[
0
:
1024
,
2048
:
4096
])
# left to right
b_1
=
np
.
sum
(
temp_b_1
,
axis
=
0
)
# part 4, left to right and up to down
temp_b_4
=
np
.
fliplr
(
self
.
image_b
[
1024
:
1024
+
1024
,
2048
:
2048
+
2048
])
# left to right
b_4
=
np
.
sum
(
temp_b_4
,
axis
=
0
)
# part 3,OSE, up to dwon
b_3
=
np
.
sum
(
self
.
image_b
[
1024
:
1024
+
1024
,
0
:
2048
],
axis
=
0
)
####
for
k
in
range
(
1024
+
overscan
):
# part
self
.
frame_b_4
[
k
,
:]
+=
b_4
*
0.09216
/
self
.
information
[
'exptime'
]
self
.
frame_b_3
[
k
,
:]
+=
b_3
*
0.09216
/
self
.
information
[
'exptime'
]
self
.
frame_b_2
[
k
,
:]
+=
b_2
*
0.09216
/
self
.
information
[
'exptime'
]
self
.
frame_b_1
[
k
,
:]
+=
b_1
*
0.09216
/
self
.
information
[
'exptime'
]
###################
# red channle
# OSH, part2 ,no change
r_2
=
np
.
sum
(
self
.
image_r
[
0
:
1536
,
0
:
3072
],
axis
=
0
)
# # flip right to left of part1
temp_r_1
=
np
.
fliplr
(
self
.
image_r
[
0
:
1536
,
3072
:
6144
])
# left to right
r_1
=
np
.
sum
(
temp_r_1
,
axis
=
0
)
# part 4, left to right and up to down
temp_r_4
=
np
.
fliplr
(
self
.
image_r
[
1536
:
1536
+
1536
,
3072
:
6144
])
# left to right
r_4
=
np
.
sum
(
temp_r_4
,
axis
=
0
)
# part 3,OSE, up to dwon
r_3
=
np
.
sum
(
self
.
image_r
[
1536
:
1536
+
1536
,
0
:
3072
],
axis
=
0
)
for
k
in
range
(
1536
+
overscan
):
# part 4, OSH zone;
self
.
frame_r_4
[
k
,
:]
+=
r_4
*
0.13824
/
self
.
information
[
'exptime'
]
self
.
frame_r_3
[
k
,
:]
+=
r_3
*
0.13824
/
self
.
information
[
'exptime'
]
self
.
frame_r_2
[
k
,
:]
+=
r_2
*
0.13824
/
self
.
information
[
'exptime'
]
self
.
frame_r_1
[
k
,
:]
+=
r_1
*
0.13824
/
self
.
information
[
'exptime'
]
# end
###############################################################################
def
applyflatfield
(
self
,
simnumber
):
...
...
@@ -2294,6 +2289,12 @@ class IFSsimulator():
support package.
"""
self
.
readCosmicRayInformation
()
#
if
self
.
information
[
'coveringfraction'
]
>
1
or
self
.
information
[
'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]!'
)
# to scale the number of cosmics with exposure time
self
.
cr
[
'exptime'
]
=
self
.
information
[
'exptime'
]
...
...
@@ -2303,8 +2304,8 @@ class IFSsimulator():
crImage_r
=
np
.
zeros
((
3072
,
6144
),
dtype
=
float
)
# cosmic ray instance
cosmics_b
=
cosmicrays
(
self
.
log
,
crImage_b
,
crInfo
=
self
.
cr
)
cosmics_r
=
cosmicrays
(
self
.
log
,
crImage_r
,
crInfo
=
self
.
cr
)
cosmics_b
=
cosmicrays
(
self
.
log
,
crImage_b
,
self
.
information
[
'exptime'
],
crInfo
=
self
.
cr
)
cosmics_r
=
cosmicrays
(
self
.
log
,
crImage_r
,
self
.
information
[
'exptime'
],
crInfo
=
self
.
cr
)
CCD_cr_b
=
cosmics_b
.
addUpToFraction
(
self
.
information
[
'coveringfraction'
]
*
self
.
information
[
'exptime'
]
/
300.0
,
limit
=
None
)
...
...
@@ -2729,49 +2730,49 @@ class IFSsimulator():
apply frame transfer effect to the four part images
"""
prescan
=
50
overscan
=
8
overscan
=
0
# zone
4
, OS
H
#### 1024, 2048
# zone
1
, OS
G
#### 1024, 2048
self
.
image_b
[
0
:
1024
+
overscan
,
prescan
:
2048
+
prescan
]
+=
self
.
frame_b_
4
[
0
:
1024
+
overscan
,
0
:
2048
]
prescan
]
+=
self
.
frame_b_
1
[
0
:
1024
+
overscan
,
0
:
2048
]
#
######### zone
3
, OS
G
#################
########## zone
2
, OS
H
#################
self
.
image_b
[
0
:
1024
+
overscan
,
prescan
+
2418
:
2418
+
2048
+
prescan
]
+=
self
.
frame_b_
3
[
0
:
1024
+
overscan
,
0
:
2048
]
prescan
]
+=
self
.
frame_b_
2
[
0
:
1024
+
overscan
,
0
:
2048
]
#
######### zone
1
, OSE ###################
########## zone
3
, OSE ###################
self
.
image_b
[
0
:
1024
+
overscan
,
prescan
+
2418
*
2
:
2418
*
2
+
2048
+
prescan
]
+=
self
.
frame_b_
1
[
0
:
1024
+
overscan
,
0
:
2048
]
2048
+
prescan
]
+=
self
.
frame_b_
3
[
0
:
1024
+
overscan
,
0
:
2048
]
#
######### zone
2
, OSF ###############
########## zone
4
, OSF ###############
self
.
image_b
[
0
:
1024
+
overscan
,
prescan
+
2418
*
3
:
2418
*
3
+
2048
+
prescan
]
+=
self
.
frame_b_
2
[
0
:
1024
+
overscan
,
0
:
2048
]
2048
+
prescan
]
+=
self
.
frame_b_
4
[
0
:
1024
+
overscan
,
0
:
2048
]
# 3
self
.
log
.
info
(
'readnoise added in blue channel'
)
# red zone
4
, OS
H
### 1536* 3072
# red zone
1
, OS
G
### 1536* 3072
self
.
image_r
[
0
:
1536
+
overscan
,
prescan
+
3442
*
0
:
3442
*
0
+
3072
+
prescan
]
+=
self
.
frame_r_
4
[
0
:
1536
+
overscan
,
0
:
3072
]
3072
+
prescan
]
+=
self
.
frame_r_
1
[
0
:
1536
+
overscan
,
0
:
3072
]
#
######### zone
3
,OS
G
#################
########## zone
2
,OS
h
#################
self
.
image_r
[
0
:
1536
+
overscan
,
prescan
+
3442
*
1
:
3442
*
1
+
3072
+
prescan
]
+=
self
.
frame_r_
3
[
0
:
1536
+
overscan
,
0
:
3072
]
3072
+
prescan
]
+=
self
.
frame_r_
2
[
0
:
1536
+
overscan
,
0
:
3072
]
#
######### zone 1 ,OSE ###################
########## zone 1 ,OSE ###################
self
.
image_r
[
0
:
1536
+
overscan
,
prescan
+
3442
*
2
:
3442
*
2
+
3072
+
prescan
]
+=
self
.
frame_r_
1
[
0
:
1536
+
overscan
,
0
:
3072
]
3072
+
prescan
]
+=
self
.
frame_r_
3
[
0
:
1536
+
overscan
,
0
:
3072
]
#
######### zone
2
,OSF ###########
########## zone
4
,OSF ###########
self
.
image_r
[
0
:
1536
+
overscan
,
prescan
+
3442
*
3
:
3442
*
3
+
3072
+
prescan
]
+=
self
.
frame_r_
2
[
0
:
1536
+
overscan
,
0
:
3072
]
3072
+
prescan
]
+=
self
.
frame_r_
4
[
0
:
1536
+
overscan
,
0
:
3072
]
##########################################################################
...
...
@@ -5932,7 +5933,7 @@ class IFSsimulator():
if
self
.
nonlinearity
:
self
.
applyNonlinearity
()
print
(
'Applying
nonlinearity finished.......'
)
print
(
'Applying nonlinearity finished.......'
)
# cut original CCD image to four parts by four read out channels and zones
self
.
CCDreadout
()
...
...
csst_ifs_sim/csst_ifs_sim_bug_250104.py
0 → 100644
View file @
7ae8c85f
This diff is collapsed.
Click to expand it.
requirements.txt
View file @
7ae8c85f
numpy
==1.23.5
scipy
==1.9.2
setuptools
==65.6.3
pandas
==1.5.3
julian
==0.14
astropy
==6.0.0
tqdm
==4.64.1
galsim
==2.4.9
#
numpy==1.23.5
#
scipy==1.9.2
#
setuptools==65.6.3
#
pandas==1.5.3
#
julian==0.14
#
astropy==6.0.0
#
tqdm==4.64.1
#
galsim==2.4.9
setup.py
View file @
7ae8c85f
...
...
@@ -16,7 +16,7 @@ with open("requirements.txt", "r") as f:
setuptools
.
setup
(
name
=
'csst_ifs_sim'
,
# 包名
version
=
"3.0.
0
"
,
# 版本号
version
=
"3.0.
1
"
,
# 版本号
author
=
"Zhaojun Yan"
,
# 作者
author_email
=
"zhaojunyan@shao.ac.cn"
,
# 邮箱
description
=
"The CSST IFS simulation - prototype"
,
# 短描述
...
...
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