Skip to content

Commit

Permalink
Remove Detector.transform, Camera.transform
Browse files Browse the repository at this point in the history
and CameraPoint
  • Loading branch information
r-owen committed Feb 26, 2018
1 parent d3fc20b commit 864d052
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 604 deletions.
27 changes: 6 additions & 21 deletions doc/cameraGeom.dox
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ of known bad pixels in each detector. The cameraGeom package supports operations
- Assemble images from raw data (combining amplifier subregions and trimming overscan). CameraGeom does not
assemble an entire image (see ip_isr AssembleCcdTask for that) but includes functions in
\ref assembleImage "assembleImage" that do much of the work.
- Transform 2-d points between various \ref afwCameraGeomCoordSys "camera coordinate systems",
using \ref camera.Camera.transform "Camera.transform". This can be used as part of generating a
- Obtain transformations between various \ref afwCameraGeomCoordSys "camera coordinate systems",
using \ref camera.Camera.getTransform "Camera.getTransform". This can be used as part of generating a
\ref geom::SkyWcs "WCS" or to examine the effects of optical distortion.
- Create a graphic showing the layout of detectors on the focal plane, using utils.plotFocalPlane.
- Display a mosaic image that combines all detector images, using utils.showMosaic.
Expand Down Expand Up @@ -103,8 +103,8 @@ orientation in the focal plane and information about amplifiers (such as the ima
readout corner). Amplifier data is stored as records in an \ref table::AmpInfoTable "amp info table",
and Detector acts as a collection of \ref table::AmpInfoRecord "amp info records".

Detector also supports transforms between \ref afwCameraGeomFOCAL_PLANE "focal plane",
\ref afwCameraGeomPIXELS "pixels", and \ref afwCameraGeomACTUAL_PIXELS "actual pixels" coordinates.
Detector always supports \ref afwCameraGeomFOCAL_PLANE "focal plane" and \ref afwCameraGeomPIXELS "pixels"
coordinates and it may also support \ref afwCameraGeomACTUAL_PIXELS "actual pixels" coordinates.

### CameraSys and CameraSysPrefix

Expand All @@ -125,23 +125,8 @@ A constant is provided each \ref afwCameraGeomCoordSys "camera coordinate system

CameraSys and CameraSysPrefix are closely related and most methods that take one type
are overloaded to also take the other. For example
\ref camera.Camera.transform "Camera.transform(fromCameraPoint, toSys)" transforms a point from one
coordinate system to another. ToSys may be either a CameraSys or a CameraSysPrefix, and this affects
whether tranform will use the specified detector or search for a suitable detector.
See the \ref afwCameraGeomBasicUsage "basic usage" for for a concrete example.

### CameraPoint

A class that holds a 2-dimensional location and its associated
\ref afwCameraGeomCoordSys "camera coordinate system":
- point: a 2-dimensional location in some camera coordinate system (a geom::Point2D).
- cameraSys: the associated \ref afwCameraGeomCoordSys "camera coordinate system" (a CameraSys,
never a CameraSysPrefix)

The intent is to make transformation more robust and less confusing by keeping a 2-d point and its camera
coordinate system together. This is appropriate for transforming small numbers of points, but does not
scale well when transforming large numbers of points. For large numbers of points use
camera.getTransformMap().transform(pointList, fromSys, toSys).
\ref camera.Detector.getTransform "Detector.getTransform(fromSys, toSys)" returns a transform
from one coordinate system to another; fromSys and toSys may be either a CameraSys or a CameraSysPrefix.

### \anchor afwCameraGeomTransformMap TransformMap

Expand Down
28 changes: 6 additions & 22 deletions examples/cameraGeomExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,16 @@
det = camera["R:1,0 S:1,1"]

# Convert a 2-d point from PIXELS to both FOCAL_PLANE and FIELD_ANGLE coordinates.
detPoint = det.makeCameraPoint(afwGeom.Point2D(
25, 43.2), cameraGeom.PIXELS) # position on detector in pixels
pixelsToFocalPlane = det.getTransform(cameraGeom.PIXELS, cameraGeom.FOCAL_PLANE)
pixelsToFieldAngle = det.getTransform(cameraGeom.PIXELS, cameraGeom.FIELD_ANGLE)
pixelPos = afwGeom.Point2D(25, 43.2)
# position in focal plane in mm
fpPoint = det.transform(detPoint, cameraGeom.FOCAL_PLANE)
fpPoint = pixelsToFocalPlane.applyForward(pixelPos)
# position in field of view, in radians
fieldPoint = camera.transform(detPoint, cameraGeom.FIELD_ANGLE)
fieldPoint = pixelsToFieldAngle.applyForward(pixelPos)

# Find all detectors that overlap a specific point (in this case find the
# detector we already have)
detList = camera.findDetectors(fpPoint)
detList = camera.findDetectors(fpPoint, cameraGeom.FOCAL_PLANE)
assert len(detList) == 1
assert detList[0].getName() == det.getName()

# Convert a point from FIELD_ANGLE to PIXELS coordinates.
# For a detector-based coordinate system, such as PIXELS, may specify a particular detector
# or let the Camera find a detector:
# * To specify a particular detector, specify the target coordinate system as a CameraSys
# with the specified detectorName filled in (e.g. use detector.makeCameraSys).
# This is faster than finding a detector, and the resulting point is allowed to be off the detector.
# * To have the Camera find a detector, specify the target coordinate system as a CameraSysPrefix
# (e.g. cameraGeom.PIXELS). Camera will search for a detector that overlaps the point.
# If it finds exactly one detector then it will use that detector, and you can figure
# out which detector it used from the detector name in the returned CameraPoint.
# If it finds no detectors, or more than one detector, then it will raise
# an exception.
detPixelsSys = det.makeCameraSys(cameraGeom.PIXELS)
detPointOnSpecifiedDetector = camera.transform(fieldPoint, detPixelsSys)
detPointOnFoundDetector = camera.transform(fieldPoint, cameraGeom.PIXELS)
assert detPointOnFoundDetector.getCameraSys() == detPixelsSys # same detector
1 change: 0 additions & 1 deletion include/lsst/afw/cameraGeom.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#define LSST_AFW_CAMERAGEOM_H

#include "lsst/afw/cameraGeom/CameraSys.h"
#include "lsst/afw/cameraGeom/CameraPoint.h"
#include "lsst/afw/cameraGeom/Detector.h"
#include "lsst/afw/cameraGeom/Orientation.h"

Expand Down
64 changes: 0 additions & 64 deletions include/lsst/afw/cameraGeom/CameraPoint.h

This file was deleted.

59 changes: 3 additions & 56 deletions include/lsst/afw/cameraGeom/Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "lsst/base.h"
#include "lsst/afw/table/AmpInfo.h"
#include "lsst/afw/cameraGeom/CameraSys.h"
#include "lsst/afw/cameraGeom/CameraPoint.h"
#include "lsst/afw/cameraGeom/Orientation.h"
#include "lsst/afw/cameraGeom/TransformMap.h"

Expand All @@ -50,7 +49,7 @@ enum DetectorType {
/**
* Information about a CCD or other imaging detector
*
* Supports conversion of CameraPoint between FOCAL_PLANE and pixel-based coordinate systems.
* Supports transformation of points between FOCAL_PLANE and pixel-based coordinate systems.
* Also an iterator over amplifiers (in C++ use begin(), end(), in Python use "for amplifier in detector").
*
* @todo: this would probably be a bit more robust if it used a ConstAmpInfoCatalog
Expand Down Expand Up @@ -123,10 +122,10 @@ class Detector {
std::vector<geom::Point2D> getCorners(CameraSysPrefix const &cameraSysPrefix) const;

/** Get the center of the detector in the specified camera coordinate system */
CameraPoint getCenter(CameraSys const &cameraSys) const;
geom::Point2D getCenter(CameraSys const &cameraSys) const;

/** Get the center of the detector in the specified camera coordinate system prefix */
CameraPoint getCenter(CameraSysPrefix const &cameraSysPrefix) const;
geom::Point2D getCenter(CameraSysPrefix const &cameraSysPrefix) const;

/** Get the amplifier information catalog */
lsst::afw::table::AmpInfoCatalog const getAmpInfoCatalog() const { return _ampInfoCatalog; }
Expand Down Expand Up @@ -221,30 +220,6 @@ class Detector {
std::shared_ptr<geom::TransformPoint2ToPoint2> getTransform(FromSysT const &fromSys,
ToSysT const &toSys) const;

/**
* Make a CameraPoint from a point and a camera system
*
* @param[in] point 2D point
* @param[in] cameraSys Camera coordinate system
*
* @note the CameraSysPrefix version needs the detector name, which is why this is not static.
*/
CameraPoint makeCameraPoint(geom::Point2D const &point, ///< 2-d point
CameraSys const &cameraSys ///< coordinate system
) const {
return CameraPoint(point, cameraSys);
}

/**
* Make a CameraPoint from a point and a camera system prefix
*
* @param[in] point 2D point
* @param[in] cameraSysPrefix Camera coordinate system prefix
*/
CameraPoint makeCameraPoint(geom::Point2D const &point, CameraSysPrefix const &cameraSysPrefix) const {
return CameraPoint(point, makeCameraSys(cameraSysPrefix));
}

/**
* Get a coordinate system from a coordinate system (return input unchanged and untested)
*
Expand All @@ -265,34 +240,6 @@ class Detector {
return CameraSys(cameraSysPrefix, _name);
}

/**
* Convert a CameraPoint from one coordinate system to another
*
* @param[in] fromCameraPoint Camera point to transform
* @param[in] toSys To camera coordinate system
* @return The transformed camera point
*
* @throws pex::exceptions::InvalidParameterError if from or to coordinate system is unknown
*/
CameraPoint transform(CameraPoint const &fromCameraPoint, CameraSys const &toSys) const {
return CameraPoint(
_transformMap.transform(fromCameraPoint.getPoint(), fromCameraPoint.getCameraSys(), toSys),
toSys);
}

/**
* Convert a CameraPoint from one coordinate system to a coordinate system prefix
*
* @param[in] fromCameraPoint Camera point to transform
* @param[in] toSys To camera coordinate system prefix (this detector is used)
* @return The transformed camera point; the detector will be this detector
*
* @throws pex::exceptions::InvalidParameterError if from or to coordinate system is unknown
*/
CameraPoint transform(CameraPoint const &fromCameraPoint, CameraSysPrefix const &toSys) const {
return transform(fromCameraPoint, makeCameraSys(toSys));
}

/// The "native" coordinate system of this detector.
CameraSys getNativeCoordSys() const { return _nativeSys; }

Expand Down
3 changes: 1 addition & 2 deletions python/lsst/afw/cameraGeom/SConscript
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## -*- python -*-
from lsst.sconsUtils import scripts
scripts.BasicSConscript.pybind11(['cameraPoint',
'cameraSys',
scripts.BasicSConscript.pybind11(['cameraSys',
'detector',
'orientation',
'transformMap'])
Expand Down

0 comments on commit 864d052

Please sign in to comment.