lsst.afw
g3a5ebb7d8a+28b83bf6a5
Toggle main menu visibility
Loading...
Searching...
No Matches
python
lsst
afw
cameraGeom
cameraConfig.py
Go to the documentation of this file.
1
# This file is part of afw.
2
#
3
# Developed for the LSST Data Management System.
4
# This product includes software developed by the LSST Project
5
# (https://www.lsst.org).
6
# See the COPYRIGHT file at the top-level directory of this distribution
7
# for details of code ownership.
8
#
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
13
#
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with this program. If not, see <https://www.gnu.org/licenses/>.
21
22
__all__ = [
"CameraConfig"
,
"DetectorConfig"
]
23
24
import
numpy
as
np
25
import
lsst.pex.config
as
pexConfig
26
import
lsst.geom
as
geom
27
from
._cameraGeom
import
Orientation
28
from
._transformConfig
import
TransformMapConfig
29
30
31
class
DetectorConfig
(pexConfig.Config):
32
"""A configuration that represents (and can be used to construct) a
33
Detector.
34
"""
35
transformDict = pexConfig.ConfigField(
36
"Dictionary of camera transforms keyed on the transform type."
, TransformMapConfig)
37
name = pexConfig.Field(
"Name of detector slot"
, str)
38
id = pexConfig.Field(
"ID of detector slot"
, int)
39
bbox_x0 = pexConfig.Field(
"x0 of pixel bounding box"
, int)
40
bbox_y0 = pexConfig.Field(
"y0 of pixel bounding box"
, int)
41
bbox_x1 = pexConfig.Field(
"x1 of pixel bounding box"
, int)
42
bbox_y1 = pexConfig.Field(
"y1 of pixel bounding box"
, int)
43
detectorType = pexConfig.Field(
44
"Detector type: SCIENCE=0, FOCUS=1, GUIDER=2, WAVEFRONT=3"
, int)
45
physicalType = pexConfig.Field(
46
"How this specific detector is constructed; e.g. CCD, E2V, HgCdTe "
, str, default=
"CCD"
)
47
serial = pexConfig.Field(
48
"Serial string associated with this specific detector"
, str)
49
offset_x = pexConfig.Field(
50
"x offset from the origin of the camera in mm in the transposed system."
, float)
51
offset_y = pexConfig.Field(
52
"y offset from the origin of the camera in mm in the transposed system."
, float)
53
offset_z = pexConfig.Field(
54
"z offset from the origin of the camera in mm in the transposed system."
, float, default=0.0)
55
refpos_x = pexConfig.Field(
"x position of the reference point in the detector in pixels "
56
"in transposed coordinates."
, float)
57
refpos_y = pexConfig.Field(
"y position of the reference point in the detector in pixels "
58
"in transposed coordinates."
, float)
59
yawDeg = pexConfig.Field(
"yaw (rotation about z) of the detector in degrees. "
60
"This includes any necessary rotation to go from "
61
"detector coordinates to camera coordinates "
62
"after optional transposition."
, float)
63
pitchDeg = pexConfig.Field(
64
"pitch (rotation about y) of the detector in degrees"
, float)
65
rollDeg = pexConfig.Field(
66
"roll (rotation about x) of the detector in degrees"
, float)
67
pixelSize_x = pexConfig.Field(
"Pixel size in the x dimension in mm"
, float)
68
pixelSize_y = pexConfig.Field(
"Pixel size in the y dimension in mm"
, float)
69
70
# Depending on the choice of detector coordinates, the pixel grid may need
71
# to be transposed before rotation to put it in camera coordinates.
72
transposeDetector = pexConfig.Field(
73
"Transpose the pixel grid before orienting in focal plane?"
, bool)
74
75
crosstalk = pexConfig.ListField(
76
dtype=float,
77
doc=(
"Flattened crosstalk coefficient matrix; should have nAmps x nAmps entries. "
78
"Once 'reshape'-ed, ``coeffs[i][j]`` is the fraction of the j-th amp present on the i-th amp."
),
79
optional=
True
80
)
81
82
# Accessors to get "compiled" versions of parameters.
83
def
getCrosstalk
(self, numAmps):
84
"""Return a 2-D numpy array of crosstalk coefficients of the proper shape"""
85
if
not
self.
crosstalk
:
86
return
None
87
88
if
numAmps != int(np.sqrt(len(self.
crosstalk
))):
89
numAmps = int(np.sqrt(len(self.
crosstalk
)))
90
try
:
91
return
np.array(self.
crosstalk
, dtype=np.float32).reshape((numAmps, numAmps))
92
except
Exception
as
e:
93
raise
RuntimeError(f
"Cannot reshape 'crosstalk' coefficients to square matrix: {e}"
)
94
95
@property
96
def
bbox
(self):
97
"""Return the detector bounding box from the separate box endpoint
98
values.
99
"""
100
return
geom.BoxI
(
geom.PointI
(self.
bbox_x0
, self.
bbox_y0
),
101
geom.PointI
(self.
bbox_x1
, self.
bbox_y1
))
102
103
@property
104
def
offset
(self):
105
"""Return the detector offset as a Point3D from the separate config
106
values.
107
"""
108
return
geom.Point3D
(self.
offset_x
, self.
offset_y
, self.
offset_z
)
109
110
@property
111
def
refPos
(self):
112
"""Return the detector reference position as a Point2D from the
113
separate config values.
114
"""
115
return
geom.Point2D
(self.
refpos_x
, self.
refpos_y
)
116
117
@property
118
def
orientation
(self):
119
"""Return the cameraGeom.Orientation() object defined by the
120
configuration values.
121
"""
122
return
Orientation
(self.
offset
, self.
refPos
,
123
geom.Angle
(self.
yawDeg
, geom.degrees),
124
geom.Angle
(self.
pitchDeg
, geom.degrees),
125
geom.Angle
(self.
rollDeg
, geom.degrees))
126
127
@property
128
def
pixelSize
(self):
129
"""Return the pixel size as an Extent2D from the separate values.
130
"""
131
return
geom.Extent2D
(self.
pixelSize_x
, self.
pixelSize_y
)
132
133
134
class
CameraConfig
(pexConfig.Config):
135
"""A configuration that represents (and can be used to construct) a Camera.
136
"""
137
detectorList = pexConfig.ConfigDictField(
138
"List of detector configs"
,
139
keytype=int,
140
itemtype=DetectorConfig,
141
)
142
transformDict = pexConfig.ConfigField(
143
"Dictionary of camera transforms keyed on the transform type."
,
144
TransformMapConfig,
145
)
146
name = pexConfig.Field(
"Name of this camera"
, str)
147
plateScale = pexConfig.Field(
"Plate scale of the camera in arcsec/mm"
, float)
148
# Note that the radial transform will also apply a scaling, so all coefficients should be
149
# scaled by the plate scale in appropriate units
150
radialCoeffs = pexConfig.ListField(
"Coefficients for radial distortion"
, float)
151
focalPlaneParity = pexConfig.Field(
152
"Whether the FOCAL_PLANE <-> FIELD_ANGLE transform should flip the X axis."
,
153
dtype=bool,
154
default=
False
,
155
)
lsst::afw::cameraGeom::Orientation
Describe a detector's orientation in the focal plane.
Definition
Orientation.h:51
lsst::afw::cameraGeom.cameraConfig.CameraConfig
Definition
cameraConfig.py:134
lsst::afw::cameraGeom.cameraConfig.DetectorConfig
Definition
cameraConfig.py:31
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.bbox_y1
bbox_y1
Definition
cameraConfig.py:42
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.pixelSize_x
pixelSize_x
Definition
cameraConfig.py:67
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.pixelSize
pixelSize(self)
Definition
cameraConfig.py:128
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.refpos_x
refpos_x
Definition
cameraConfig.py:55
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.pitchDeg
pitchDeg
Definition
cameraConfig.py:63
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.crosstalk
crosstalk
Definition
cameraConfig.py:75
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.offset_y
offset_y
Definition
cameraConfig.py:51
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.offset_z
offset_z
Definition
cameraConfig.py:53
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.refpos_y
refpos_y
Definition
cameraConfig.py:57
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.getCrosstalk
getCrosstalk(self, numAmps)
Definition
cameraConfig.py:83
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.bbox_x0
bbox_x0
Definition
cameraConfig.py:39
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.bbox_x1
bbox_x1
Definition
cameraConfig.py:41
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.bbox_y0
bbox_y0
Definition
cameraConfig.py:40
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.bbox
bbox(self)
Definition
cameraConfig.py:96
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.offset_x
offset_x
Definition
cameraConfig.py:49
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.offset
offset
Definition
cameraConfig.py:122
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.yawDeg
yawDeg
Definition
cameraConfig.py:59
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.pixelSize_y
pixelSize_y
Definition
cameraConfig.py:68
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.orientation
orientation(self)
Definition
cameraConfig.py:118
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.refPos
refPos
Definition
cameraConfig.py:122
lsst::afw::cameraGeom.cameraConfig.DetectorConfig.rollDeg
rollDeg
Definition
cameraConfig.py:65
lsst::geom::Angle
lsst::geom::Box2I
lsst::geom::Extent< double, 2 >
lsst::geom::Point< int, 2 >
lsst::geom
lsst::pex::config
Generated on
for lsst.afw by
1.17.0