lsst.afw  14.0-23-g38c323faa+1
makePixelToTanPixel.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, print_function
2 #
3 # LSST Data Management System
4 # Copyright 2014 LSST Corporation.
5 #
6 # This product includes software developed by the
7 # LSST Project (http://www.lsst.org/).
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 LSST License Statement and
20 # the GNU General Public License along with this program. If not,
21 # see <http://www.lsstcorp.org/LegalNotices/>.
22 #
23 import lsst.afw.geom as afwGeom
24 
25 __all__ = ["makePixelToTanPixel"]
26 
27 
28 def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm):
29  """!Make a Transform whose forward direction converts PIXEL to TAN_PIXEL for one detector
30 
31  PIXELS and TAN_PIXELS are defined in @ref afwCameraGeomCoordSys in doc/cameraGeom.dox
32 
33  @param[in] bbox detector bounding box (an lsst.afw.geom.Box2I)
34  @param[in] orientation orientation of detector in focal plane (an lsst.afw.cameraGeom.Orientation)
35  @param[in] focalPlaneToField an lsst.afw.geom.Transform that converts from focal plane (mm)
36  to field angle coordinates (radians) in the forward direction
37  @param[in] pixelSizeMm size of the pixel in mm in X and Y (an lsst.afw.geom.Extent2D)
38  @return a TransformPoint2ToPoint2 whose forward direction converts PIXEL to TAN_PIXEL
39  """
40  pixelToFocalPlane = orientation.makePixelFpTransform(pixelSizeMm)
41  pixelToField = pixelToFocalPlane.then(focalPlaneToField)
42  # fieldToTanPix is affine and matches fieldToPix at field center
43  # Note: focal plane to field angle is typically a radial transform,
44  # and linearizing the inverse transform of that may fail,
45  # so linearize the forward direction instead. (pixelToField is pixelToFocalPlane,
46  # an affine transform, followed by focalPlaneToField,
47  # so the same consideration applies to pixelToField)
48  pixAtFieldCtr = pixelToField.applyInverse(afwGeom.Point2D(0, 0))
49  tanPixToFieldAffine = afwGeom.linearizeTransform(pixelToField,
50  pixAtFieldCtr)
51  fieldToTanPix = afwGeom.makeTransform(tanPixToFieldAffine.invert())
52 
53  return pixelToField.then(fieldToTanPix)
TransformPoint2ToPoint2 makeTransform(AffineTransform const &affine)
Wrap an AffineTransform as a Transform.
AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, Point2D const &inPoint)
Approximate a Transform by its local linearization.
def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm)
Make a Transform whose forward direction converts PIXEL to TAN_PIXEL for one detector.