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
885d85b2
Commit
885d85b2
authored
Apr 28, 2024
by
JX
😵
Browse files
Merge remote-tracking branch 'origin/develop'
parents
c48d8742
228262c4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
885d85b2
...
...
@@ -7,4 +7,6 @@ dist/*
*interp.c
!*libshao.so
*.out
pnodes
\ No newline at end of file
pnodes
.coverage
coverage
\ No newline at end of file
ObservationSim/Instrument/Chip/Chip.py
View file @
885d85b2
This diff is collapsed.
Click to expand it.
ObservationSim/Instrument/FocalPlane.py
View file @
885d85b2
import
galsim
import
numpy
as
np
class
FocalPlane
(
object
):
def
__init__
(
self
,
config
=
None
,
chip_list
=
None
,
survey_type
=
'Photometric'
,
bad_chips
=
None
):
def
__init__
(
self
,
chip_list
=
None
,
survey_type
=
'Photometric'
,
bad_chips
=
None
):
"""Get the focal plane layout
"""
self
.
nchips
=
42
...
...
@@ -14,7 +15,7 @@ class FocalPlane(object):
self
.
bad_chips
=
bad_chips
for
chip_id
in
bad_chips
:
self
.
ignore_chips
.
append
(
chip_id
)
if
chip_list
is
not
None
:
for
i
in
range
(
42
):
if
not
(
i
+
1
in
chip_list
):
...
...
@@ -39,25 +40,25 @@ class FocalPlane(object):
for
i
in
range
(
1
,
31
):
self
.
ignore_chips
.
append
(
i
)
if
config
is
not
None
:
self
.
nchip_x
=
config
[
"nchip_x"
]
self
.
nchip_y
=
config
[
"nchip_y"
]
self
.
npix_tot_x
=
config
[
"npix_tot_x"
]
self
.
npix_tot_y
=
config
[
"npix_tot_y"
]
self
.
npix_gap_x
=
config
[
"npix_gap_x"
]
self
.
npix_gap_y
=
config
[
"npix_gap_y"
]
if
"chipLabelIDs"
in
config
:
self
.
chipLabelIDs
=
config
[
"chipLabelIDs"
]
if
"bad_chips"
in
config
:
self
.
bad_chips
=
config
[
"bad_chips"
]
else
:
self
.
nchip_x
=
6
self
.
nchip_y
=
5
self
.
npix_tot_x
=
59516
self
.
npix_tot_y
=
49752
self
.
npix_gap_x
=
(
534
,
1309
)
self
.
npix_gap_y
=
898
#
if config is not None:
#
self.nchip_x = config["nchip_x"]
#
self.nchip_y = config["nchip_y"]
#
self.npix_tot_x = config["npix_tot_x"]
#
self.npix_tot_y = config["npix_tot_y"]
#
self.npix_gap_x = config["npix_gap_x"]
#
self.npix_gap_y = config["npix_gap_y"]
#
if "chipLabelIDs" in config:
#
self.chipLabelIDs = config["chipLabelIDs"]
#
if "bad_chips" in config:
#
self.bad_chips = config["bad_chips"]
#
else:
self
.
nchip_x
=
6
self
.
nchip_y
=
5
self
.
npix_tot_x
=
59516
self
.
npix_tot_y
=
49752
self
.
npix_gap_x
=
(
534
,
1309
)
self
.
npix_gap_y
=
898
self
.
_getCenter
()
def
_getCenter
(
self
):
...
...
@@ -65,7 +66,7 @@ class FocalPlane(object):
self
.
cen_pix_y
=
0
def
getChipLabel
(
self
,
chipID
):
return
str
(
"0%d"
%
chipID
)[
-
2
:]
return
str
(
"0%d"
%
chipID
)[
-
2
:]
def
isBadChip
(
self
,
chipID
):
"""Check if chip #(chipID) on the focal plane is bad or not
...
...
@@ -89,7 +90,8 @@ class FocalPlane(object):
WCS of the focal plane
"""
if
logger
is
not
None
:
logger
.
info
(
" Construct the wcs of the entire image mosaic using Gnomonic/TAN projection"
)
logger
.
info
(
" Construct the wcs of the entire image mosaic using Gnomonic/TAN projection"
)
if
(
xcen
==
None
)
or
(
ycen
==
None
):
xcen
=
self
.
cen_pix_x
ycen
=
self
.
cen_pix_y
...
...
@@ -98,13 +100,14 @@ class FocalPlane(object):
# dvdx = -np.sin(img_rot.rad) * pix_scale
# dvdy = +np.cos(img_rot.rad) * pix_scale
dudx
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
dudy
=
+
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dvdx
=
-
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dvdy
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
dudx
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
dudy
=
+
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dvdx
=
-
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dvdy
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
moscen
=
galsim
.
PositionD
(
x
=
xcen
,
y
=
ycen
)
sky_center
=
galsim
.
CelestialCoord
(
ra
=
ra
*
galsim
.
degrees
,
dec
=
dec
*
galsim
.
degrees
)
sky_center
=
galsim
.
CelestialCoord
(
ra
=
ra
*
galsim
.
degrees
,
dec
=
dec
*
galsim
.
degrees
)
affine
=
galsim
.
AffineTransform
(
dudx
,
dudy
,
dvdx
,
dvdy
,
origin
=
moscen
)
WCS
=
galsim
.
TanWCS
(
affine
,
sky_center
,
units
=
galsim
.
arcsec
)
...
...
@@ -115,10 +118,10 @@ class FocalPlane(object):
The sky coverage of an area
"""
r2d
=
180.0
/
np
.
pi
s1
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y0
))
s2
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y1
))
s3
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y0
))
s4
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y1
))
s1
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y0
))
s2
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y1
))
s3
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y0
))
s4
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y1
))
ra
=
[
s1
.
ra
.
rad
*
r2d
,
s2
.
ra
.
rad
*
r2d
,
s3
.
ra
.
rad
*
r2d
,
s4
.
ra
.
rad
*
r2d
]
dec
=
[
s1
.
dec
.
rad
*
r2d
,
s2
.
dec
.
rad
*
r2d
,
s3
.
dec
.
rad
*
r2d
,
s4
.
dec
.
rad
*
r2d
]
...
...
tests/.coverage
deleted
100644 → 0
View file @
c48d8742
}q(U collectorqUcoverage v3.6b3qUlinesq}u.
\ No newline at end of file
tests/test_focalplane.py
0 → 100644
View file @
885d85b2
import
unittest
import
os
import
galsim
from
ObservationSim.Instrument
import
FocalPlane
,
Chip
class
TestFocalPlane
(
unittest
.
TestCase
):
def
__init__
(
self
,
methodName
=
'runTest'
):
super
(
TestFocalPlane
,
self
).
__init__
(
methodName
)
self
.
dataPath
=
os
.
path
.
join
(
os
.
getenv
(
'UNIT_TEST_DATA_ROOT'
),
'csst_msc_sim/csst_fz_msc'
)
self
.
focal_plane
=
FocalPlane
(
chip_list
=
[
'8'
])
self
.
assertTrue
(
self
.
focal_plane
.
cen_pix_x
==
0
)
self
.
assertTrue
(
self
.
focal_plane
.
cen_pix_y
==
0
)
test_focal_plane_phot
=
FocalPlane
(
survey_type
=
'Photometric'
)
test_focal_plane_spec
=
FocalPlane
(
survey_type
=
'Spectroscopic'
)
test_focal_plane_FGS
=
FocalPlane
(
survey_type
=
'FGS'
)
test_focal_plane_bad_chips
=
FocalPlane
(
bad_chips
=
[
"1"
])
def
test_fp_method
(
self
):
wcs
=
self
.
focal_plane
.
getTanWCS
(
192.8595
,
0.
,
0.
*
galsim
.
degrees
,
0.0074
)
sky_coverage
=
self
.
focal_plane
.
getSkyCoverage
(
wcs
,
x0
=-
1
,
x1
=
0
,
y0
=-
1
,
y1
=
0
)
print
(
sky_coverage
.
area
())
self
.
assertTrue
(
abs
(
sky_coverage
.
area
()
-
0.0074
**
2
/
(
3600.
**
2
))
<
1e13
)
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