lsst.afw  15.0-29-ga12a2b06e
makePixelToTanPixel.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2014 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 import lsst.afw.geom as afwGeom
23 
24 __all__ = ["makePixelToTanPixel"]
25 
26 
27 def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm):
28  """!Make a Transform whose forward direction converts PIXELS to TAN_PIXELS for one detector
29 
30  PIXELS and TAN_PIXELS are defined in @ref afwCameraGeomCoordSys in doc/cameraGeom.dox
31 
32  @param[in] bbox detector bounding box (an lsst.afw.geom.Box2I)
33  @param[in] orientation orientation of detector in focal plane (an lsst.afw.cameraGeom.Orientation)
34  @param[in] focalPlaneToField an lsst.afw.geom.Transform that converts from focal plane (mm)
35  to field angle coordinates (radians) in the forward direction
36  @param[in] pixelSizeMm size of the pixel in mm in X and Y (an lsst.afw.geom.Extent2D)
37  @return a TransformPoint2ToPoint2 whose forward direction converts PIXELS to TAN_PIXELS
38  """
39  pixelToFocalPlane = orientation.makePixelFpTransform(pixelSizeMm)
40  pixelToField = pixelToFocalPlane.then(focalPlaneToField)
41  # fieldToTanPix is affine and matches fieldToPix at field center
42  # Note: focal plane to field angle is typically a radial transform,
43  # and linearizing the inverse transform of that may fail,
44  # so linearize the forward direction instead. (pixelToField is pixelToFocalPlane,
45  # an affine transform, followed by focalPlaneToField,
46  # so the same consideration applies to pixelToField)
47  pixAtFieldCtr = pixelToField.applyInverse(afwGeom.Point2D(0, 0))
48  tanPixToFieldAffine = afwGeom.linearizeTransform(pixelToField,
49  pixAtFieldCtr)
50  fieldToTanPix = afwGeom.makeTransform(tanPixToFieldAffine.invert())
51 
52  return pixelToField.then(fieldToTanPix)
AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, Point2D const &inPoint)
Approximate a Transform by its local linearization.
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(AffineTransform const &affine)
Wrap an AffineTransform as a Transform.
def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm)
Make a Transform whose forward direction converts PIXELS to TAN_PIXELS for one detector.