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
2166c80e
Commit
2166c80e
authored
Oct 26, 2024
by
Zhang Xin
Browse files
pep8
parent
45682570
Pipeline
#7118
failed with stage
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
observation_sim/mock_objects/Galaxy.py
View file @
2166c80e
...
...
@@ -325,23 +325,25 @@ class Galaxy(MockObject):
galImg_List
=
[]
try
:
pos_img_local
=
[
0
,
0
]
pos_img_local
=
[
0
,
0
]
x_start
=
chip
.
x_cen
/
chip
.
pix_size
-
chip
.
npix_x
/
2.
y_start
=
chip
.
y_cen
/
chip
.
pix_size
-
chip
.
npix_y
/
2.
pos_img_local
[
0
]
=
pos_img
.
x
-
x_start
pos_img_local
[
1
]
=
pos_img
.
y
-
y_start
nnx
=
0
nny
=
0
for
order
in
[
"A"
,
"B"
]:
for
order
in
[
"A"
,
"B"
]:
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
,
pos_img_local
=
pos_img_local
,
bandNo
=
i
+
1
,
galsimGSObject
=
True
,
g_order
=
order
,
grating_split_pos
=
grating_split_pos
)
star_p
=
galsim
.
Convolve
(
psf
,
gal
)
if
nnx
==
0
:
galImg
=
star_p
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
galImg
=
star_p
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
nnx
=
galImg
.
xmax
-
galImg
.
xmin
+
1
nny
=
galImg
.
ymax
-
galImg
.
ymin
+
1
else
:
galImg
=
star_p
.
drawImage
(
nx
=
nnx
,
ny
=
nny
,
wcs
=
chip_wcs_local
,
offset
=
offset
)
galImg
=
star_p
.
drawImage
(
nx
=
nnx
,
ny
=
nny
,
wcs
=
chip_wcs_local
,
offset
=
offset
)
galImg
.
setOrigin
(
0
,
0
)
# n1 = np.sum(np.isinf(galImg.array))
# n2 = np.sum(np.isnan(galImg.array))
...
...
@@ -351,7 +353,7 @@ class Galaxy(MockObject):
# ERROR happens
return
2
,
pos_shear
galImg_List
.
append
(
galImg
)
for
order
in
[
"C"
,
"D"
,
"E"
]:
for
order
in
[
"C"
,
"D"
,
"E"
]:
galImg_List
.
append
(
galImg
)
except
:
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
)
...
...
@@ -361,7 +363,7 @@ class Galaxy(MockObject):
if
np
.
sum
(
np
.
isnan
(
galImg
.
array
))
>
0
:
# ERROR happens
return
2
,
pos_shear
for
order
in
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
]:
for
order
in
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
]:
galImg_List
.
append
(
galImg
)
# starImg = gal.drawImage(
...
...
@@ -378,7 +380,7 @@ class Galaxy(MockObject):
subSlitPos
=
int
(
grating_split_pos_chip
-
gal_origin
[
1
])
# part img disperse
star_p1s
=
[]
star_p1s
=
[]
for
galImg
in
galImg_List
:
subImg_p1
=
galImg
.
array
[:,
0
:
subSlitPos
]
...
...
@@ -397,13 +399,14 @@ class Galaxy(MockObject):
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p1
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p1
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p1, chip=chip, pos_img_local=[xcenter_p1, ycenter_p1],
# psf_model=psf_model, bandNo=i + 1,
# grating_split_pos=grating_split_pos,
# local_wcs=chip_wcs_local, pos_img=pos_img)
star_p2s
=
[]
star_p2s
=
[]
for
galImg
in
galImg_List
:
subImg_p2
=
galImg
.
array
[:,
...
...
@@ -423,7 +426,8 @@ class Galaxy(MockObject):
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p2
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p2
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p2, chip=chip, pos_img_local=[xcenter_p2, ycenter_p2],
# psf_model=psf_model, bandNo=i + 1,
# grating_split_pos=grating_split_pos,
...
...
@@ -439,7 +443,8 @@ class Galaxy(MockObject):
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
# psf_model=psf_model, bandNo=i + 1,
# grating_split_pos=grating_split_pos,
...
...
@@ -453,7 +458,8 @@ class Galaxy(MockObject):
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
# psf_model=psf_model, bandNo=i + 1,
# grating_split_pos=grating_split_pos,
...
...
observation_sim/mock_objects/MockObject.py
View file @
2166c80e
...
...
@@ -242,7 +242,7 @@ class MockObject(object):
print
(
"DEBUG: specImg nan num is"
,
img_s
[
nan_ids
].
shape
[
0
])
#########################################################
# img_s, orig_off = convolveImg(img_s, psf_img_m)
orig_off
=
[
0
,
0
]
orig_off
=
[
0
,
0
]
origin_order_x
=
v
[
1
]
-
orig_off
[
0
]
origin_order_y
=
v
[
2
]
-
orig_off
[
1
]
...
...
@@ -257,15 +257,18 @@ class MockObject(object):
continue
# orders = {'A': 'order1', 'B': 'order0', 'C': 'order2', 'D': 'order-1', 'E': 'order-2'}
orders
=
{
'A'
:
'order1'
,
'B'
:
'order0'
,
'C'
:
'order0'
,
'D'
:
'order0'
,
'E'
:
'order0'
}
orders
=
{
'A'
:
'order1'
,
'B'
:
'order0'
,
'C'
:
'order0'
,
'D'
:
'order0'
,
'E'
:
'order0'
}
gratingN
=
chip_utils
.
getChipSLSGratingID
(
chip
.
chipID
)[
1
]
if
pos_img_local
[
0
]
<
grating_split_pos
:
gratingN
=
chip_utils
.
getChipSLSGratingID
(
chip
.
chipID
)[
0
]
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)].
setOrigin
(
0
,
0
)
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)][
bounds
]
=
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)][
bounds
]
+
specImg
[
bounds
]
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)].
setOrigin
(
chip
.
bound
.
xmin
,
chip
.
bound
.
ymin
)
chip
.
img_stack
[
gratingN
][
orders
[
k
]
][
'w'
+
str
(
bandNo
)].
setOrigin
(
0
,
0
)
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)][
bounds
]
=
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)][
bounds
]
+
specImg
[
bounds
]
chip
.
img_stack
[
gratingN
][
orders
[
k
]][
'w'
+
str
(
bandNo
)].
setOrigin
(
chip
.
bound
.
xmin
,
chip
.
bound
.
ymin
)
else
:
for
k
,
v
in
spec_orders
.
items
():
...
...
@@ -330,9 +333,11 @@ class MockObject(object):
specImg
.
wcs
=
local_wcs
specImg
.
setOrigin
(
origin_order_x
,
origin_order_y
)
try
:
specImg
=
psf_model
.
get_PSF_AND_convolve_withsubImg
(
chip
,
cutImg
=
specImg
,
pos_img_local
=
pos_img_local
,
bandNo
=
bandNo
,
g_order
=
k
,
grating_split_pos
=
grating_split_pos
)
specImg
=
psf_model
.
get_PSF_AND_convolve_withsubImg
(
chip
,
cutImg
=
specImg
,
pos_img_local
=
pos_img_local
,
bandNo
=
bandNo
,
g_order
=
k
,
grating_split_pos
=
grating_split_pos
)
except
:
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
)
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
)
psf_img
=
psf
.
drawImage
(
nx
=
100
,
ny
=
100
,
wcs
=
local_wcs
)
...
...
@@ -425,34 +430,36 @@ class MockObject(object):
# star = galsim.DeltaFunction(gsparams=gsp)
# star = star.withFlux(tel.pupil_area * exptime)
#psf list :["A","B","C","D","E"]
#
psf list :["A","B","C","D","E"]
starImg_List
=
[]
try
:
pos_img_local
=
[
0
,
0
]
pos_img_local
=
[
0
,
0
]
x_start
=
chip
.
x_cen
/
chip
.
pix_size
-
chip
.
npix_x
/
2.
y_start
=
chip
.
y_cen
/
chip
.
pix_size
-
chip
.
npix_y
/
2.
pos_img_local
[
0
]
=
pos_img
.
x
-
x_start
pos_img_local
[
1
]
=
pos_img
.
y
-
y_start
nnx
=
0
nny
=
0
for
order
in
[
"A"
,
"B"
]:
for
order
in
[
"A"
,
"B"
]:
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
,
pos_img_local
=
pos_img_local
,
bandNo
=
i
+
1
,
galsimGSObject
=
True
,
g_order
=
order
,
grating_split_pos
=
grating_split_pos
)
# star_p = galsim.Convolve(psf, star)
star_p
=
psf
.
withFlux
(
tel
.
pupil_area
*
exptime
)
if
nnx
==
0
:
starImg
=
star_p
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
starImg
=
star_p
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
nnx
=
starImg
.
xmax
-
starImg
.
xmin
+
1
nny
=
starImg
.
ymax
-
starImg
.
ymin
+
1
else
:
starImg
=
star_p
.
drawImage
(
nx
=
nnx
,
ny
=
nny
,
wcs
=
chip_wcs_local
,
offset
=
offset
)
starImg
=
star_p
.
drawImage
(
nx
=
nnx
,
ny
=
nny
,
wcs
=
chip_wcs_local
,
offset
=
offset
)
# n1 = np.sum(np.isinf(starImg.array))
# n2 = np.sum(np.isnan(starImg.array))
# if n1>0 or n2 > 0:
# print("DEBUG: MockObject, inf:%d, nan:%d"%(n1, n2))
starImg
.
setOrigin
(
0
,
0
)
starImg_List
.
append
(
starImg
)
for
order
in
[
"C"
,
"D"
,
"E"
]:
for
order
in
[
"C"
,
"D"
,
"E"
]:
starImg_List
.
append
(
starImg
)
except
:
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
)
...
...
@@ -460,10 +467,9 @@ class MockObject(object):
star_p
=
psf
.
withFlux
(
tel
.
pupil_area
*
exptime
)
starImg
=
star_p
.
drawImage
(
wcs
=
chip_wcs_local
,
offset
=
offset
)
starImg
.
setOrigin
(
0
,
0
)
for
order
in
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
]:
for
order
in
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
]:
starImg_List
.
append
(
starImg
)
# psf_tmp = galsim.Gaussian(sigma=0.002)
# star = galsim.Convolve(psf_tmp, star)
...
...
@@ -479,7 +485,7 @@ class MockObject(object):
if
gal_origin
[
1
]
<
grating_split_pos_chip
<
gal_end
[
1
]:
subSlitPos
=
int
(
grating_split_pos_chip
-
gal_origin
[
1
])
# part img disperse
star_p1s
=
[]
star_p1s
=
[]
for
starImg
in
starImg_List
:
subImg_p1
=
starImg
.
array
[:,
0
:
subSlitPos
]
...
...
@@ -498,13 +504,13 @@ class MockObject(object):
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p1
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p1
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p1, chip=chip, pos_img_local=[xcenter_p1, ycenter_p1],
# psf_model=psf_model, bandNo=i+1, grating_split_pos=grating_split_pos,
# local_wcs=chip_wcs_local, pos_img=pos_img)
star_p2s
=
[]
star_p2s
=
[]
for
starImg
in
starImg_List
:
subImg_p2
=
starImg
.
array
[:,
...
...
@@ -524,7 +530,8 @@ class MockObject(object):
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p2
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp_p2
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp_p2, chip=chip, pos_img_local=[xcenter_p2, ycenter_p2],
# psf_model=psf_model, bandNo=i + 1, grating_split_pos=grating_split_pos,
# local_wcs=chip_wcs_local, pos_img=pos_img)
...
...
@@ -539,7 +546,8 @@ class MockObject(object):
conf
=
chip
.
sls_conf
[
1
],
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
# psf_model=psf_model, bandNo=i + 1, grating_split_pos=grating_split_pos,
# local_wcs=chip_wcs_local, pos_img=pos_img)
...
...
@@ -552,7 +560,8 @@ class MockObject(object):
conf
=
chip
.
sls_conf
[
0
],
isAlongY
=
0
,
flat_cube
=
flat_cube
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
self
.
addSLStoChipImage
(
sdp
=
sdp
,
chip
=
chip
,
xOrderSigPlus
=
xOrderSigPlus
,
local_wcs
=
chip_wcs_local
)
# pos_shear = self.addSLStoChipImageWithPSF(sdp=sdp, chip=chip, pos_img_local=[x_nominal, y_nominal],
# psf_model=psf_model, bandNo=i + 1, grating_split_pos=grating_split_pos,
# local_wcs=chip_wcs_local, pos_img=pos_img)
...
...
observation_sim/psf/PSFInterpSLS.py
View file @
2166c80e
...
...
@@ -30,7 +30,7 @@ NPSF = 900 # ***# 30*30
PIX_SIZE_MICRON
=
5.
# ***# in microns
##
# find neighbors-KDtree
###
# find neighbors-KDtree
# def findNeighbors(tx, ty, px, py, dr=0.1, dn=1, OnlyDistance=True):
# """
# find nearest neighbors by 2D-KDTree
...
...
@@ -212,7 +212,7 @@ PIX_SIZE_MICRON = 5. # ***# in microns
# return psfMaker
##
# define PSFInterp
###
# define PSFInterp
class
PSFInterpSLS
(
PSFModel
):
def
__init__
(
self
,
chip
,
filt
,
PSF_data_prefix
=
""
,
sigSpin
=
0
,
psfRa
=
0.15
,
pix_size
=
0.005
):
if
LOG_DEBUG
:
...
...
tools/get_pointing.py
View file @
2166c80e
...
...
@@ -60,7 +60,7 @@ class Chip(object):
if
logger
is
not
None
:
logger
.
info
(
" Construct the wcs of the entire image mosaic using Gnomonic/TAN projection"
)
if
(
xcen
==
None
)
or
(
ycen
==
None
):
if
(
xcen
is
None
)
or
(
ycen
is
None
):
xcen
=
self
.
cen_pix_x
ycen
=
self
.
cen_pix_y
if
pix_scale
==
None
:
...
...
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