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
Show whitespace changes
Inline
Side-by-side
.gitignore
View file @
885d85b2
...
@@ -8,3 +8,5 @@ dist/*
...
@@ -8,3 +8,5 @@ dist/*
!*libshao.so
!*libshao.so
*.out
*.out
pnodes
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
galsim
import
numpy
as
np
import
numpy
as
np
class
FocalPlane
(
object
):
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
"""Get the focal plane layout
"""
"""
self
.
nchips
=
42
self
.
nchips
=
42
...
@@ -39,18 +40,18 @@ class FocalPlane(object):
...
@@ -39,18 +40,18 @@ class FocalPlane(object):
for
i
in
range
(
1
,
31
):
for
i
in
range
(
1
,
31
):
self
.
ignore_chips
.
append
(
i
)
self
.
ignore_chips
.
append
(
i
)
if
config
is
not
None
:
#
if config is not None:
self
.
nchip_x
=
config
[
"nchip_x"
]
#
self.nchip_x = config["nchip_x"]
self
.
nchip_y
=
config
[
"nchip_y"
]
#
self.nchip_y = config["nchip_y"]
self
.
npix_tot_x
=
config
[
"npix_tot_x"
]
#
self.npix_tot_x = config["npix_tot_x"]
self
.
npix_tot_y
=
config
[
"npix_tot_y"
]
#
self.npix_tot_y = config["npix_tot_y"]
self
.
npix_gap_x
=
config
[
"npix_gap_x"
]
#
self.npix_gap_x = config["npix_gap_x"]
self
.
npix_gap_y
=
config
[
"npix_gap_y"
]
#
self.npix_gap_y = config["npix_gap_y"]
if
"chipLabelIDs"
in
config
:
#
if "chipLabelIDs" in config:
self
.
chipLabelIDs
=
config
[
"chipLabelIDs"
]
#
self.chipLabelIDs = config["chipLabelIDs"]
if
"bad_chips"
in
config
:
#
if "bad_chips" in config:
self
.
bad_chips
=
config
[
"bad_chips"
]
#
self.bad_chips = config["bad_chips"]
else
:
#
else:
self
.
nchip_x
=
6
self
.
nchip_x
=
6
self
.
nchip_y
=
5
self
.
nchip_y
=
5
self
.
npix_tot_x
=
59516
self
.
npix_tot_x
=
59516
...
@@ -65,7 +66,7 @@ class FocalPlane(object):
...
@@ -65,7 +66,7 @@ class FocalPlane(object):
self
.
cen_pix_y
=
0
self
.
cen_pix_y
=
0
def
getChipLabel
(
self
,
chipID
):
def
getChipLabel
(
self
,
chipID
):
return
str
(
"0%d"
%
chipID
)[
-
2
:]
return
str
(
"0%d"
%
chipID
)[
-
2
:]
def
isBadChip
(
self
,
chipID
):
def
isBadChip
(
self
,
chipID
):
"""Check if chip #(chipID) on the focal plane is bad or not
"""Check if chip #(chipID) on the focal plane is bad or not
...
@@ -89,7 +90,8 @@ class FocalPlane(object):
...
@@ -89,7 +90,8 @@ class FocalPlane(object):
WCS of the focal plane
WCS of the focal plane
"""
"""
if
logger
is
not
None
:
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
):
if
(
xcen
==
None
)
or
(
ycen
==
None
):
xcen
=
self
.
cen_pix_x
xcen
=
self
.
cen_pix_x
ycen
=
self
.
cen_pix_y
ycen
=
self
.
cen_pix_y
...
@@ -104,7 +106,8 @@ class FocalPlane(object):
...
@@ -104,7 +106,8 @@ class FocalPlane(object):
dvdy
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
dvdy
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
moscen
=
galsim
.
PositionD
(
x
=
xcen
,
y
=
ycen
)
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
)
affine
=
galsim
.
AffineTransform
(
dudx
,
dudy
,
dvdx
,
dvdy
,
origin
=
moscen
)
WCS
=
galsim
.
TanWCS
(
affine
,
sky_center
,
units
=
galsim
.
arcsec
)
WCS
=
galsim
.
TanWCS
(
affine
,
sky_center
,
units
=
galsim
.
arcsec
)
...
@@ -115,10 +118,10 @@ class FocalPlane(object):
...
@@ -115,10 +118,10 @@ class FocalPlane(object):
The sky coverage of an area
The sky coverage of an area
"""
"""
r2d
=
180.0
/
np
.
pi
r2d
=
180.0
/
np
.
pi
s1
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y0
))
s1
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y0
))
s2
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y1
))
s2
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x0
,
y1
))
s3
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y0
))
s3
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y0
))
s4
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y1
))
s4
=
wcs
.
toWorld
(
galsim
.
PositionD
(
x1
,
y1
))
ra
=
[
s1
.
ra
.
rad
*
r2d
,
s2
.
ra
.
rad
*
r2d
,
s3
.
ra
.
rad
*
r2d
,
s4
.
ra
.
rad
*
r2d
]
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
]
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