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
cd1351bc
Commit
cd1351bc
authored
Sep 28, 2022
by
xin
Browse files
upload server
parent
364e4c76
Changes
1
Show whitespace changes
Inline
Side-by-side
ObservationSim/MockObject/MockObject.py
View file @
cd1351bc
...
...
@@ -252,7 +252,7 @@ class MockObject(object):
return
True
,
pos_shear
def
addSLStoChipImage
(
self
,
sdp
=
None
,
chip
=
None
,
xOrderSigPlus
=
None
,
local_wcs
=
None
):
def
addSLStoChipImage
(
self
,
sdp
=
None
,
chip
=
None
,
xOrderSigPlus
=
None
):
spec_orders
=
sdp
.
compute_spec_orders
()
for
k
,
v
in
spec_orders
.
items
():
img_s
=
v
[
0
]
...
...
@@ -267,17 +267,15 @@ class MockObject(object):
xlen_imf
=
int
(
specImg
.
xmax
-
specImg
.
xmin
+
1
)
ylen_imf
=
int
(
specImg
.
ymax
-
specImg
.
ymin
+
1
)
stamp
=
galsim
.
ImageF
(
xlen_imf
,
ylen_imf
)
stamp
.
wcs
=
local
_wcs
stamp
.
wcs
=
self
.
local
WCS
stamp
.
setOrigin
(
origin_order_x
,
origin_order_y
)
bounds
=
stamp
.
bounds
&
galsim
.
BoundsI
(
0
,
chip
.
npix_x
-
1
,
0
,
chip
.
npix_y
-
1
)
bounds
=
stamp
.
bounds
&
chip
.
img
.
bounds
if
bounds
.
area
()
==
0
:
continue
chip
.
img
.
setOrigin
(
0
,
0
)
stamp
[
bounds
]
=
chip
.
img
[
bounds
]
chip
.
sensor
.
accumulate
(
photons
,
stamp
)
chip
.
img
[
bounds
]
=
stamp
[
bounds
]
chip
.
img
.
setOrigin
(
chip
.
bound
.
xmin
,
chip
.
bound
.
ymin
)
del
stamp
del
spec_orders
...
...
@@ -303,20 +301,9 @@ class MockObject(object):
normalSED
=
Table
(
np
.
array
([
self
.
sed
[
'WAVELENGTH'
],
self
.
sed
[
'FLUX'
]
*
sedNormFactor
]).
T
,
names
=
(
'WAVELENGTH'
,
'FLUX'
))
real_pos
=
self
.
getRealPos
(
chip
.
img
,
global_x
=
self
.
posImg
.
x
,
global_y
=
self
.
posImg
.
y
,
img_real_wcs
=
self
.
real_wcs
)
x
,
y
=
real_pos
.
x
+
0.5
,
real_pos
.
y
+
0.5
x_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
y_nominal
=
int
(
np
.
floor
(
y
+
0.5
))
dx
=
x
-
x_nominal
dy
=
y
-
y_nominal
offset
=
galsim
.
PositionD
(
dx
,
dy
)
real_wcs_local
=
self
.
real_wcs
.
local
(
real_pos
)
xOrderSigPlus
=
{
'A'
:
1.3909419820029296
,
'B'
:
1.4760376591236062
,
'C'
:
4.035447379743442
,
'D'
:
5.5684364343742825
,
'E'
:
16.260021029735388
}
grating_split_pos_chip
=
0
+
grating_split_pos
grating_split_pos_chip
=
chip
.
bound
.
xmin
+
grating_split_pos
for
i
in
range
(
len
(
bandpass_list
)):
bandpass
=
bandpass_list
[
i
]
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
,
bandpass
=
bandpass
,
folding_threshold
=
folding_threshold
)
...
...
@@ -325,8 +312,8 @@ class MockObject(object):
star
=
galsim
.
Convolve
(
psf
,
star
)
starImg
=
star
.
drawImage
(
nx
=
100
,
ny
=
100
,
wcs
=
self
.
localWCS
)
origin_star
=
[
y_nominal
-
(
starImg
.
center
.
y
-
starImg
.
ymin
),
x_nominal
-
(
starImg
.
center
.
x
-
starImg
.
xmin
)]
origin_star
=
[
self
.
y_nominal
-
(
starImg
.
center
.
y
-
starImg
.
ymin
),
self
.
x_nominal
-
(
starImg
.
center
.
x
-
starImg
.
xmin
)]
gal_origin
=
[
origin_star
[
0
],
origin_star
[
1
]]
gal_end
=
[
origin_star
[
0
]
+
starImg
.
array
.
shape
[
0
]
-
1
,
origin_star
[
1
]
+
starImg
.
array
.
shape
[
1
]
-
1
]
...
...
@@ -338,8 +325,8 @@ class MockObject(object):
subImg_p1
=
starImg
.
array
[:,
0
:
subSlitPos
]
star_p1
=
galsim
.
Image
(
subImg_p1
)
origin_p1
=
origin_star
xcenter_p1
=
min
(
x_nominal
,
grating_split_pos_chip
-
1
)
-
0
ycenter_p1
=
y_nominal
-
0
xcenter_p1
=
min
(
self
.
x_nominal
,
grating_split_pos_chip
-
1
)
-
chip
.
bound
.
xmin
ycenter_p1
=
self
.
y_nominal
-
chip
.
bound
.
ymin
sdp_p1
=
SpecDisperser
(
orig_img
=
star_p1
,
xcenter
=
xcenter_p1
,
ycenter
=
ycenter_p1
,
origin
=
origin_p1
,
...
...
@@ -348,13 +335,13 @@ class MockObject(object):
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p1
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
real_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p1
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
)
subImg_p2
=
starImg
.
array
[:,
subSlitPos
+
1
:
starImg
.
array
.
shape
[
1
]]
star_p2
=
galsim
.
Image
(
subImg_p2
)
origin_p2
=
[
origin_star
[
0
],
grating_split_pos_chip
]
xcenter_p2
=
max
(
x_nominal
,
grating_split_pos_chip
-
1
)
-
0
ycenter_p2
=
y_nominal
-
0
xcenter_p2
=
max
(
self
.
x_nominal
,
grating_split_pos_chip
-
1
)
-
chip
.
bound
.
xmin
ycenter_p2
=
self
.
y_nominal
-
chip
.
bound
.
ymin
sdp_p2
=
SpecDisperser
(
orig_img
=
star_p2
,
xcenter
=
xcenter_p2
,
ycenter
=
ycenter_p2
,
origin
=
origin_p2
,
...
...
@@ -363,27 +350,27 @@ class MockObject(object):
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p2
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
real_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p2
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
)
del
sdp_p1
del
sdp_p2
elif
grating_split_pos_chip
<=
gal_origin
[
1
]:
sdp
=
SpecDisperser
(
orig_img
=
starImg
,
xcenter
=
x_nominal
-
0
,
ycenter
=
y_nominal
-
0
,
origin
=
origin_star
,
sdp
=
SpecDisperser
(
orig_img
=
starImg
,
xcenter
=
self
.
x_nominal
-
chip
.
bound
.
xmin
,
ycenter
=
self
.
y_nominal
-
chip
.
bound
.
ymin
,
origin
=
origin_star
,
tar_spec
=
normalSED
,
band_start
=
bandpass
.
blue_limit
*
10
,
band_end
=
bandpass
.
red_limit
*
10
,
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
real_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
)
del
sdp
elif
grating_split_pos_chip
>=
gal_end
[
1
]:
sdp
=
SpecDisperser
(
orig_img
=
starImg
,
xcenter
=
x_nominal
-
0
,
ycenter
=
y_nominal
-
0
,
origin
=
origin_star
,
sdp
=
SpecDisperser
(
orig_img
=
starImg
,
xcenter
=
self
.
x_nominal
-
chip
.
bound
.
xmin
,
ycenter
=
self
.
y_nominal
-
chip
.
bound
.
ymin
,
origin
=
origin_star
,
tar_spec
=
normalSED
,
band_start
=
bandpass
.
blue_limit
*
10
,
band_end
=
bandpass
.
red_limit
*
10
,
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
real_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
)
del
sdp
del
psf
return
True
,
pos_shear
...
...
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