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_msc_sim
Commits
1a887d44
Commit
1a887d44
authored
Oct 28, 2024
by
Wei Chengliang
Browse files
update module-crosstalk
parent
50e37e55
Pipeline
#7141
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
observation_sim/sim_steps/readout_output.py
View file @
1a887d44
...
@@ -44,7 +44,7 @@ def add_crosstalk(self, chip, filt, tel, pointing, catalog, obs_param):
...
@@ -44,7 +44,7 @@ def add_crosstalk(self, chip, filt, tel, pointing, catalog, obs_param):
crosstalk
[
15
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
])
crosstalk
[
15
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
])
# 2*8 -> 1*16
# 2*8 -> 1*16
img
=
formatOutput
(
chip
.
img
)
img
=
chip_utils
.
formatOutput
(
chip
.
img
)
ny
,
nx
=
img
.
array
.
shape
ny
,
nx
=
img
.
array
.
shape
nsecy
=
1
nsecy
=
1
nsecx
=
16
nsecx
=
16
...
@@ -57,7 +57,7 @@ def add_crosstalk(self, chip, filt, tel, pointing, catalog, obs_param):
...
@@ -57,7 +57,7 @@ def add_crosstalk(self, chip, filt, tel, pointing, catalog, obs_param):
newimg
.
array
[:,
int
(
i
*
dx
):
int
(
i
*
dx
+
dx
)]
+=
crosstalk
[
i
,
j
]
*
img
.
array
[:,
int
(
j
*
dx
):
int
(
j
*
dx
+
dx
)]
newimg
.
array
[:,
int
(
i
*
dx
):
int
(
i
*
dx
+
dx
)]
+=
crosstalk
[
i
,
j
]
*
img
.
array
[:,
int
(
j
*
dx
):
int
(
j
*
dx
+
dx
)]
# 1*16 -> 2*8
# 1*16 -> 2*8
newimg
=
formatRevert
(
newimg
)
newimg
=
chip_utils
.
formatRevert
(
newimg
)
chip
.
img
.
array
[:,
:]
=
newimg
.
array
[:,
:]
chip
.
img
.
array
[:,
:]
=
newimg
.
array
[:,
:]
return
chip
,
filt
,
tel
,
pointing
return
chip
,
filt
,
tel
,
pointing
...
...
tests/test_crosstalk.py
0 → 100644
View file @
1a887d44
import
unittest
import
sys
import
os
import
math
from
itertools
import
islice
import
numpy
as
np
import
copy
import
ctypes
import
galsim
import
yaml
from
astropy.io
import
fits
from
observation_sim.instruments.chip
import
chip_utils
import
matplotlib.pyplot
as
plt
# test FUNCTION --- START #
def
add_crosstalk
(
GSimg
):
crosstalk
=
np
.
zeros
([
16
,
16
])
crosstalk
[
0
,
:]
=
np
.
array
([
1.
,
1e-4
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
1
,
:]
=
np
.
array
([
1e-4
,
1.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
2
,
:]
=
np
.
array
([
0.
,
0.
,
1.
,
1e-4
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
3
,
:]
=
np
.
array
([
0.
,
0.
,
1e-4
,
1.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
4
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
1.
,
1e-4
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
5
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
6
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1.
,
1e-4
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
7
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
8
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1.
,
1e-4
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
9
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
10
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1.
,
1e-4
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
11
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
,
0.
,
0.
,
0.
,
0.
])
crosstalk
[
12
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1.
,
1e-4
,
0.
,
0.
])
crosstalk
[
13
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
,
0.
,
0.
])
crosstalk
[
14
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1.
,
1e-4
])
crosstalk
[
15
,
:]
=
np
.
array
([
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
0.
,
1e-4
,
1.
])
# 2*8 -> 1*16
img
=
chip_utils
.
formatOutput
(
GSimg
)
ny
,
nx
=
img
.
array
.
shape
nsecy
=
1
nsecx
=
16
dy
=
int
(
ny
/
nsecy
)
dx
=
int
(
nx
/
nsecx
)
newimg
=
galsim
.
Image
(
nx
,
ny
,
init_value
=
0
)
for
i
in
range
(
16
):
for
j
in
range
(
16
):
newimg
.
array
[:,
int
(
i
*
dx
):
int
(
i
*
dx
+
dx
)]
+=
crosstalk
[
i
,
j
]
*
img
.
array
[:,
int
(
j
*
dx
):
int
(
j
*
dx
+
dx
)]
# 1*16 -> 2*8
newimg
=
chip_utils
.
formatRevert
(
newimg
)
return
newimg
# test FUNCTION --- END #
class
detModule_coverage
(
unittest
.
TestCase
):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
(
detModule_coverage
,
self
).
__init__
(
methodName
)
self
.
dataPath
=
os
.
path
.
join
(
os
.
getenv
(
'UNIT_TEST_DATA_ROOT'
),
'csst_msc_sim/csst_fz_msc'
)
def
test_add_crosstalk
(
self
):
nsecy
=
2
nsecx
=
8
ny
,
nx
=
1024
,
1024
dy
=
int
(
ny
/
nsecy
)
dx
=
int
(
nx
/
nsecx
)
mapclip
=
np
.
zeros
([
dy
,
int
(
nsecx
*
nsecy
*
dx
)])
for
i
in
range
(
int
(
nsecx
*
nsecy
)):
mapclip
[:,
i
*
dx
:
dx
+
i
*
dx
]
=
np
.
random
.
randint
(
10
)
+
np
.
random
.
rand
(
int
(
dy
*
dx
)).
reshape
([
dy
,
dx
])
mapclip
=
galsim
.
ImageF
(
mapclip
)
nsecy
=
1
nsecx
=
16
ny
,
nx
=
mapclip
.
array
.
shape
dy
=
int
(
ny
/
nsecy
)
dx
=
int
(
nx
/
nsecx
)
for
i
in
range
(
int
(
nsecy
*
nsecx
)):
gal
=
galsim
.
Gaussian
(
sigma
=
0.2
,
flux
=
500000
).
drawImage
(
nx
=
32
,
ny
=
32
).
array
py
=
np
.
random
.
randint
(
450
)
+
10
mapclip
.
array
[
py
:
py
+
32
,
int
(
i
*
dx
)
+
10
:
int
(
i
*
dx
)
+
42
]
+=
gal
tmap
=
chip_utils
.
formatRevert
(
mapclip
,
nsecy
=
1
,
nsecx
=
16
)
# 1*16 -> 2*8
temp
=
add_crosstalk
(
tmap
)
fig
=
plt
.
figure
(
figsize
=
(
20
,
60
))
ax
=
plt
.
subplot
(
311
)
plt
.
imshow
(
np
.
log10
(
mapclip
.
array
+
1
),
origin
=
'lower'
,
cmap
=
'gray'
)
ax
=
plt
.
subplot
(
312
)
plt
.
imshow
(
np
.
log10
(
temp
.
array
+
1
),
origin
=
'lower'
,
cmap
=
'gray'
)
ax
=
plt
.
subplot
(
313
)
plt
.
imshow
(
np
.
log10
(
temp
.
array
-
tmap
.
array
+
1
),
origin
=
'lower'
,
cmap
=
'gray'
)
plt
.
savefig
(
os
.
path
.
join
(
self
.
dataPath
,
"./test_crosstalk.png"
),
dpi
=
300
,
bbox_inches
=
'tight'
)
self
.
assertTrue
(
True
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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