lsst.afw  16.0-51-gb4b4a8566+2
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.geom
23 import lsst.afw.geom
24 
25 __all__ = ["makePixelToTanPixel"]
26 
27 
28 def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm):
29  """!Make a Transform whose forward direction converts PIXELS to TAN_PIXELS 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.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.geom.Extent2D)
38  @return a TransformPoint2ToPoint2 whose forward direction converts PIXELS to TAN_PIXELS
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(lsst.geom.Point2D(0, 0))
49  tanPixToFieldAffine = lsst.afw.geom.linearizeTransform(pixelToField, pixAtFieldCtr)
50  fieldToTanPix = lsst.afw.geom.makeTransform(tanPixToFieldAffine.inverted())
51 
52  return pixelToField.then(fieldToTanPix)
lsst::geom::AffineTransform linearizeTransform(TransformPoint2ToPoint2 const &original, lsst::geom::Point2D const &inPoint)
Approximate a Transform by its local linearization.
def makePixelToTanPixel(bbox, orientation, focalPlaneToField, pixelSizeMm)
Make a Transform whose forward direction converts PIXELS to TAN_PIXELS for one detector.
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.