LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
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  physicalType = pexConfig.Field(
44  "How this specific detector is constructed; e.g. CCD, E2V, HgCdTe ", str, default="CCD")
45  serial = pexConfig.Field(
46  "Serial string associated with this specific detector", str)
47  offset_x = pexConfig.Field(
48  "x offset from the origin of the camera in mm in the transposed system.", float)
49  offset_y = pexConfig.Field(
50  "y offset from the origin of the camera in mm in the transposed system.", float)
51  refpos_x = pexConfig.Field("x position of the reference point in the detector in pixels "
52  "in transposed coordinates.", float)
53  refpos_y = pexConfig.Field("y position of the reference point in the detector in pixels "
54  "in transposed coordinates.", float)
55  yawDeg = pexConfig.Field("yaw (rotation about z) of the detector in degrees. "
56  "This includes any necessary rotation to go from "
57  "detector coordinates to camera coordinates "
58  "after optional transposition.", float)
59  pitchDeg = pexConfig.Field(
60  "pitch (rotation about y) of the detector in degrees", float)
61  rollDeg = pexConfig.Field(
62  "roll (rotation about x) of the detector in degrees", float)
63  pixelSize_x = pexConfig.Field("Pixel size in the x dimension in mm", float)
64  pixelSize_y = pexConfig.Field("Pixel size in the y dimension in mm", float)
65 
66  # Depending on the choice of detector coordinates, the pixel grid may need
67  # to be transposed before rotation to put it in camera coordinates.
68  transposeDetector = pexConfig.Field(
69  "Transpose the pixel grid before orienting in focal plane?", bool)
70 
71  crosstalk = pexConfig.ListField(
72  dtype=float,
73  doc=("Flattened crosstalk coefficient matrix; should have nAmps x nAmps entries. "
74  "Once 'reshape'-ed, ``coeffs[i][j]`` is the fraction of the j-th amp present on the i-th amp."),
75  optional=True
76  )
77 
78  def getCrosstalk(self, numAmps):
79  """Return a 2-D numpy array of crosstalk coefficients of the proper shape"""
80  if not self.crosstalk:
81  return None
82  try:
83  return np.array(self.crosstalk, dtype=np.float32).reshape((numAmps, numAmps))
84  except Exception as e:
85  raise RuntimeError("Cannot reshape 'crosstalk' coefficients to square matrix: %s" % (e,))
86 
87 
88 class CameraConfig(pexConfig.Config):
89  """A configuration that represents (and can be used to construct) a Camera.
90  """
91  detectorList = pexConfig.ConfigDictField(
92  "List of detector configs", keytype=int, itemtype=DetectorConfig)
93  transformDict = pexConfig.ConfigField(
94  "Dictionary of camera transforms keyed on the transform type.", TransformMapConfig)
95  name = pexConfig.Field("Name of this camera", str)
96 
97  plateScale = pexConfig.Field(
98  "Plate scale of the camera in arcsec/mm", float)
99  # Note that the radial transform will also apply a scaling, so all coefficients should be
100  # scaled by the plate scale in appropriate units
101  radialCoeffs = pexConfig.ListField(
102  "Coefficients for radial distortion", float)