LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
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 from .transformConfig import TransformMapConfig
27 
28 
29 class DetectorConfig(pexConfig.Config):
30  """A configuration that represents (and can be used to construct) a
31  Detector.
32  """
33  transformDict = pexConfig.ConfigField(
34  "Dictionary of camera transforms keyed on the transform type.", TransformMapConfig)
35  name = pexConfig.Field("Name of detector slot", str)
36  id = pexConfig.Field("ID of detector slot", int)
37  bbox_x0 = pexConfig.Field("x0 of pixel bounding box", int)
38  bbox_y0 = pexConfig.Field("y0 of pixel bounding box", int)
39  bbox_x1 = pexConfig.Field("x1 of pixel bounding box", int)
40  bbox_y1 = pexConfig.Field("y1 of pixel bounding box", int)
41  detectorType = pexConfig.Field(
42  "Detector type: SCIENCE=0, FOCUS=1, GUIDER=2, WAVEFRONT=3", int)
43  serial = pexConfig.Field(
44  "Serial string associated with this specific detector", str)
45  offset_x = pexConfig.Field(
46  "x offset from the origin of the camera in mm in the transposed system.", float)
47  offset_y = pexConfig.Field(
48  "y offset from the origin of the camera in mm in the transposed system.", float)
49  refpos_x = pexConfig.Field("x position of the reference point in the detector in pixels "
50  "in transposed coordinates.", float)
51  refpos_y = pexConfig.Field("y position of the reference point in the detector in pixels "
52  "in transposed coordinates.", float)
53  yawDeg = pexConfig.Field("yaw (rotation about z) of the detector in degrees. "
54  "This includes any necessary rotation to go from "
55  "detector coordinates to camera coordinates "
56  "after optional transposition.", float)
57  pitchDeg = pexConfig.Field(
58  "pitch (rotation about y) of the detector in degrees", float)
59  rollDeg = pexConfig.Field(
60  "roll (rotation about x) of the detector in degrees", float)
61  pixelSize_x = pexConfig.Field("Pixel size in the x dimension in mm", float)
62  pixelSize_y = pexConfig.Field("Pixel size in the y dimension in mm", float)
63 
64  # Depending on the choice of detector coordinates, the pixel grid may need
65  # to be transposed before rotation to put it in camera coordinates.
66  transposeDetector = pexConfig.Field(
67  "Transpose the pixel grid before orienting in focal plane?", bool)
68 
69  crosstalk = pexConfig.ListField(
70  dtype=float,
71  doc=("Flattened crosstalk coefficient matrix; should have nAmps x nAmps entries. "
72  "Once 'reshape'-ed, ``coeffs[i][j]`` is the fraction of the j-th amp present on the i-th amp."),
73  optional=True
74  )
75 
76  def getCrosstalk(self, numAmps):
77  """Return a 2-D numpy array of crosstalk coefficients of the proper shape"""
78  if not self.crosstalk:
79  return None
80  try:
81  return np.array(self.crosstalk, dtype=np.float32).reshape((numAmps, numAmps))
82  except Exception as e:
83  raise RuntimeError("Cannot reshape 'crosstalk' coefficients to square matrix: %s" % (e,))
84 
85 
86 class CameraConfig(pexConfig.Config):
87  """A configuration that represents (and can be used to construct) a Camera.
88  """
89  detectorList = pexConfig.ConfigDictField(
90  "List of detector configs", keytype=int, itemtype=DetectorConfig)
91  transformDict = pexConfig.ConfigField(
92  "Dictionary of camera transforms keyed on the transform type.", TransformMapConfig)
93  name = pexConfig.Field("Name of this camera", str)
94 
95  plateScale = pexConfig.Field(
96  "Plate scale of the camera in arcsec/mm", float)
97  # Note that the radial transform will also apply a scaling, so all coefficients should be
98  # scaled by the plate scale in appropriate units
99  radialCoeffs = pexConfig.ListField(
100  "Coefficients for radial distortion", float)