lsst.afw  13.0-100-ge0459d59f+6
cameraConfig.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, print_function
2 
3 import numpy as np
4 import lsst.pex.config as pexConfig
5 from .transformConfig import TransformMapConfig
6 
7 __all__ = ["CameraConfig", "DetectorConfig"]
8 
9 
10 class DetectorConfig(pexConfig.Config):
11  """!A configuration that represents (and can be used to construct) a Detector
12  """
13  transformDict = pexConfig.ConfigField(
14  "Dictionary of camera transforms keyed on the transform type.", TransformMapConfig)
15  name = pexConfig.Field("Name of detector slot", str)
16  id = pexConfig.Field("ID of detector slot", int)
17  bbox_x0 = pexConfig.Field("x0 of pixel bounding box", int)
18  bbox_y0 = pexConfig.Field("y0 of pixel bounding box", int)
19  bbox_x1 = pexConfig.Field("x1 of pixel bounding box", int)
20  bbox_y1 = pexConfig.Field("y1 of pixel bounding box", int)
21  detectorType = pexConfig.Field(
22  "Detector type: SCIENCE=0, FOCUS=1, GUIDER=2, WAVEFRONT=3", int)
23  serial = pexConfig.Field(
24  "Serial string associated with this specific detector", str)
25  offset_x = pexConfig.Field(
26  "x offset from the origin of the camera in mm in the transposed system.", float)
27  offset_y = pexConfig.Field(
28  "y offset from the origin of the camera in mm in the transposed system.", float)
29  refpos_x = pexConfig.Field("x position of the reference point in the detector in pixels " +
30  "in transposed coordinates.", float)
31  refpos_y = pexConfig.Field("y position of the reference point in the detector in pixels " +
32  "in transposed coordinates.", float)
33  yawDeg = pexConfig.Field("yaw (rotation about z) of the detector in degrees. " +
34  "This includes any necessary rotation to go from " +
35  "detector coordinates to camera coordinates " +
36  "after optional transposition.", float)
37  pitchDeg = pexConfig.Field(
38  "pitch (rotation about y) of the detector in degrees", float)
39  rollDeg = pexConfig.Field(
40  "roll (rotation about x) of the detector in degrees", float)
41  pixelSize_x = pexConfig.Field("Pixel size in the x dimension in mm", float)
42  pixelSize_y = pexConfig.Field("Pixel size in the y dimension in mm", float)
43 
44  # Depending on the choice of detector coordinates, the pixel grid may need
45  # to be transposed before rotation to put it in camera coordinates.
46  transposeDetector = pexConfig.Field(
47  "Transpose the pixel grid before orienting in focal plane?", bool)
48 
49  crosstalk = pexConfig.ListField(
50  dtype=float,
51  doc=("Flattened crosstalk coefficient matrix; should have nAmps x nAmps entries. "
52  "Once 'reshape'-ed, ``coeffs[i][j]`` is the fraction of the j-th amp present on the i-th amp."),
53  optional=True
54  )
55 
56  def getCrosstalk(self, numAmps):
57  """Return a 2-D numpy array of crosstalk coefficients of the proper shape"""
58  if not self.crosstalk:
59  return None
60  try:
61  return np.array(self.crosstalk, dtype=np.float32).reshape((numAmps, numAmps))
62  except:
63  raise RuntimeError("Cannot reshape 'crosstalk' coefficients to square matrix")
64 
65 
66 class CameraConfig(pexConfig.Config):
67  """!A configuration that represents (and can be used to construct) a Camera
68  """
69  detectorList = pexConfig.ConfigDictField(
70  "List of detector configs", keytype=int, itemtype=DetectorConfig)
71  transformDict = pexConfig.ConfigField(
72  "Dictionary of camera transforms keyed on the transform type.", TransformMapConfig)
73  name = pexConfig.Field("Name of this camera", str)
74 
75  plateScale = pexConfig.Field(
76  "Plate scale of the camera in arcsec/mm", float)
77  # Note that the radial transform will also apply a scaling, so all coefficients should be
78  # scaled by the plate scale in appropriate units
79  radialCoeffs = pexConfig.ListField(
80  "Coefficients for radial distortion", float)
A configuration that represents (and can be used to construct) a Detector.
Definition: cameraConfig.py:10
A configuration that represents (and can be used to construct) a Camera.
Definition: cameraConfig.py:66