LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | List of all members
lsst::afw::cameraGeom::TransformMap Class Referencefinal

A registry of 2-dimensional coordinate transforms for a specific camera. More...

#include <TransformMap.h>

Inheritance diagram for lsst::afw::cameraGeom::TransformMap:
lsst::afw::table::io::PersistableFacade< TransformMap > lsst::afw::table::io::Persistable

Classes

struct  Connection
 Representation of a single edge in the graph defined by a TransformMap. More...
 
class  Factory
 

Public Types

using Transforms = std::unordered_map< CameraSys, std::shared_ptr< geom::TransformPoint2ToPoint2 > >
 
using CameraSysIterator = boost::transform_iterator< GetKey, CameraSysFrameIdMap::const_iterator >
 

Public Member Functions

 ~TransformMap () noexcept
 
lsst::geom::Point2D transform (lsst::geom::Point2D const &point, CameraSys const &fromSys, CameraSys const &toSys) const
 Convert a point from one camera coordinate system to another. More...
 
std::vector< lsst::geom::Point2Dtransform (std::vector< lsst::geom::Point2D > const &pointList, CameraSys const &fromSys, CameraSys const &toSys) const
 Convert a list of points from one coordinate system to another. More...
 
CameraSysIterator begin () const
 
CameraSysIterator end () const
 
bool contains (CameraSys const &system) const noexcept
 Can this transform to and from the specified coordinate system? More...
 
std::shared_ptr< geom::TransformPoint2ToPoint2getTransform (CameraSys const &fromSys, CameraSys const &toSys) const
 Get a Transform from one camera coordinate system to another. More...
 
size_t size () const noexcept
 Get the number of supported coordinate systems. More...
 
std::vector< ConnectiongetConnections () const
 Return the sequence of connections used to construct this Transform. More...
 
bool isPersistable () const noexcept override
 TransformMaps should always be Persistable. More...
 
void writeFits (std::string const &fileName, std::string const &mode="w") const
 Write the object to a regular FITS file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w") const
 Write the object to a FITS image in memory. More...
 
void writeFits (fits::Fits &fitsfile) const
 Write the object to an already-open FITS object. More...
 
 TransformMap (TransformMap const &other)=delete
 
 TransformMap (TransformMap &&other)=delete
 
TransformMapoperator= (TransformMap const &)=delete
 
TransformMapoperator= (TransformMap &&)=delete
 

Static Public Member Functions

static std::shared_ptr< TransformMap const > make (CameraSys const &reference, Transforms const &transforms)
 Construct a TransformMap with all transforms relative to a single reference CameraSys. More...
 
static std::shared_ptr< TransformMap const > make (CameraSys const &reference, std::vector< Connection > const &connections)
 Construct a TransformMap from a sequence of Connections. More...
 
static std::shared_ptr< TransformMapreadFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< TransformMapreadFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< TransformMapreadFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< TransformMapdynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr. More...
 

Protected Types

using OutputArchiveHandle = io::OutputArchiveHandle
 

Detailed Description

A registry of 2-dimensional coordinate transforms for a specific camera.

Represents the interrelationships between camera coordinate systems for a particular camera. It can be seen as a mapping between a pair of CameraSys and a Transform between them (though it does not conform to either the C++ map or Python dictionary APIs).

TransformMap supports:

TransformMap is immutable and must always be held by shared_ptr; this is enforced by making all non-deleted constructors private, and instead providing static make member functions for construction (in Python, these are exposed as regular constructors).

Exception Safety
Unless otherwise specified, all methods guarantee only basic exception safety.

Definition at line 62 of file TransformMap.h.

Member Typedef Documentation

◆ CameraSysIterator

using lsst::afw::cameraGeom::TransformMap::CameraSysIterator = boost::transform_iterator<GetKey, CameraSysFrameIdMap::const_iterator>

Definition at line 75 of file TransformMap.h.

◆ OutputArchiveHandle

using lsst::afw::table::io::Persistable::OutputArchiveHandle = io::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

◆ Transforms

Definition at line 74 of file TransformMap.h.

Constructor & Destructor Documentation

◆ TransformMap() [1/2]

lsst::afw::cameraGeom::TransformMap::TransformMap ( TransformMap const &  other)
delete

TransformMap is immutable, so both moving and copying are prohibited. It is also always held by shared_ptr, so there is no good reason to copy it.

◆ TransformMap() [2/2]

lsst::afw::cameraGeom::TransformMap::TransformMap ( TransformMap &&  other)
delete

TransformMap is immutable, so both moving and copying are prohibited. It is also always held by shared_ptr, so there is no good reason to copy it.

◆ ~TransformMap()

lsst::afw::cameraGeom::TransformMap::~TransformMap ( )
defaultnoexcept

Member Function Documentation

◆ begin()

CameraSysIterator lsst::afw::cameraGeom::TransformMap::begin ( ) const
inline

Definition at line 164 of file TransformMap.h.

164 { return boost::make_transform_iterator(_frameIds.begin(), GetKey()); }
T begin(T... args)

◆ contains()

bool lsst::afw::cameraGeom::TransformMap::contains ( CameraSys const &  system) const
noexcept

Can this transform to and from the specified coordinate system?

Parameters
systemThe coordinate system to search for
Returns
true if system is supported, false otherwise
Exception Safety
Shall not throw exceptions.

Definition at line 215 of file TransformMap.cc.

215 { return _frameIds.count(system) > 0; }
T count(T... args)

◆ dynamicCast()

Dynamically cast a shared_ptr.

Dynamically cast a shared pointer and raise on failure.

You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;

Exceptions
lsst::pex::exceptions::LogicErrorif the cast fails

param[in] ptr The pointer to be cast.

Returns
The cast pointer.
Exceptions
lsst::pex::exceptions::TypeErrorIf the dynamic cast fails.

Definition at line 218 of file Persistable.cc.

18  {
19  auto result = std::dynamic_pointer_cast<T>(ptr);
20  if (!result) {
21  throw LSST_EXCEPT(pex::exceptions::TypeError, "Dynamic pointer cast failed");
22  }
23  return result;
24 }
py::object result
Definition: _schema.cc:429
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
uint64_t * ptr
Definition: RangeSet.cc:88

◆ end()

CameraSysIterator lsst::afw::cameraGeom::TransformMap::end ( ) const
inline

Definition at line 166 of file TransformMap.h.

166 { return boost::make_transform_iterator(_frameIds.end(), GetKey()); }
T end(T... args)

◆ getConnections()

std::vector< TransformMap::Connection > lsst::afw::cameraGeom::TransformMap::getConnections ( ) const

Return the sequence of connections used to construct this Transform.

The order of the connections may differ from the original order, but is guaranteed to yield the same TransformMap when passed to make with the same reference system.

Definition at line 278 of file TransformMap.cc.

278 { return _connections; }

◆ getTransform()

std::shared_ptr< geom::TransformPoint2ToPoint2 > lsst::afw::cameraGeom::TransformMap::getTransform ( CameraSys const &  fromSys,
CameraSys const &  toSys 
) const

Get a Transform from one camera coordinate system to another.

Parameters
fromSys,toSysCamera coordinate systems between which to transform
Returns
a Transform that converts from fromSys to toSys in the forward direction. The Transform will be invertible.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorThrown if either fromSys or toSys is not supported.

Definition at line 217 of file TransformMap.cc.

218  {
219  return std::make_shared<geom::TransformPoint2ToPoint2>(*_getMapping(fromSys, toSys));
220 }

◆ isPersistable()

bool lsst::afw::cameraGeom::TransformMap::isPersistable ( ) const
inlineoverridevirtualnoexcept

TransformMaps should always be Persistable.

Reimplemented from lsst::afw::table::io::Persistable.

Definition at line 210 of file TransformMap.h.

210 { return true; }

◆ make() [1/2]

std::shared_ptr< TransformMap const > lsst::afw::cameraGeom::TransformMap::make ( CameraSys const &  reference,
std::vector< Connection > const &  connections 
)
static

Construct a TransformMap from a sequence of Connections.

Parameters
referenceInitial coordinate system that must be connected to all other coordinate systems in the map.
connectionsSequence of Connection structs, each of which relates two CameraSys via the Transform that connects them.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorThrown if the graph defined by the given connections does not define a single unique path (which may involve multiple Connections) between any CameraSys and the reference CameraSys.

This method is wrapped as a regular constructor in Python.

Definition at line 188 of file TransformMap.cc.

191  {
192  // We can't use make_shared because TransformMap ctor is private.
194  new TransformMap(standardizeConnections(reference, connections))
195  );
196 }
TransformMap(TransformMap const &other)=delete

◆ make() [2/2]

std::shared_ptr< TransformMap const > lsst::afw::cameraGeom::TransformMap::make ( CameraSys const &  reference,
Transforms const &  transforms 
)
static

Construct a TransformMap with all transforms relative to a single reference CameraSys.

Parameters
referenceCoordinate system from which each Transform in transforms converts.
transformsA map whose keys are camera coordinate systems, and whose values point to Transforms that convert from reference to the corresponding key. All Transforms must be invertible.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorThrown if transforms contains the reference camera system as a key, or if any Transform is not invertible.

This method is wrapped as a regular constructor in Python.

Definition at line 173 of file TransformMap.cc.

176  {
177  std::vector<Connection> connections;
178  connections.reserve(transforms.size());
179  for (auto const & pair : transforms) {
180  connections.push_back(Connection{pair.second, reference, pair.first});
181  }
182  // We can't use make_shared because TransformMap ctor is private.
184  new TransformMap(standardizeConnections(reference, std::move(connections)))
185  );
186 }
T move(T... args)
T push_back(T... args)
T reserve(T... args)

◆ operator=() [1/2]

TransformMap& lsst::afw::cameraGeom::TransformMap::operator= ( TransformMap &&  )
delete

TransformMap is immutable, so both moving and copying are prohibited. It is also always held by shared_ptr, so there is no good reason to copy it.

◆ operator=() [2/2]

TransformMap& lsst::afw::cameraGeom::TransformMap::operator= ( TransformMap const &  )
delete

TransformMap is immutable, so both moving and copying are prohibited. It is also always held by shared_ptr, so there is no good reason to copy it.

◆ readFits() [1/3]

static std::shared_ptr<TransformMap > lsst::afw::table::io::PersistableFacade< TransformMap >::readFits ( fits::Fits fitsfile)
inlinestaticinherited

Read an object from an already open FITS object.

Parameters
[in]fitsfileFITS object to read from, already positioned at the desired HDU.

Definition at line 183 of file Persistable.h.

183  {
184  return dynamicCast(Persistable::_readFits(fitsfile));
185  }
static std::shared_ptr< TransformMap > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ readFits() [2/3]

static std::shared_ptr<TransformMap > lsst::afw::table::io::PersistableFacade< TransformMap >::readFits ( fits::MemFileManager manager,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a FITS file in memory.

Parameters
[in]managerManager for the memory to read from.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 205 of file Persistable.h.

205  {
206  return dynamicCast(Persistable::_readFits(manager, hdu));
207  }

◆ readFits() [3/3]

static std::shared_ptr<TransformMap > lsst::afw::table::io::PersistableFacade< TransformMap >::readFits ( std::string const &  fileName,
int  hdu = fits::DEFAULT_HDU 
)
inlinestaticinherited

Read an object from a regular FITS file.

Parameters
[in]fileNameName of the file to read.
[in]hduHDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty.

Definition at line 194 of file Persistable.h.

194  {
195  return dynamicCast(Persistable::_readFits(fileName, hdu));
196  }

◆ size()

size_t lsst::afw::cameraGeom::TransformMap::size ( ) const
noexcept

Get the number of supported coordinate systems.

Exception Safety
Shall not throw exceptions.

Definition at line 237 of file TransformMap.cc.

237 { return _frameIds.size(); }
T size(T... args)

◆ transform() [1/2]

lsst::geom::Point2D lsst::afw::cameraGeom::TransformMap::transform ( lsst::geom::Point2D const &  point,
CameraSys const &  fromSys,
CameraSys const &  toSys 
) const

Convert a point from one camera coordinate system to another.

Parameters
pointPoint from which to transform
fromSys,toSysCamera coordinate systems between which to transform
Returns
the transformed value. Equivalent to getTransform(fromSys, toSys).applyForward(point).
Exceptions
lsst::pex::exceptions::InvalidParameterErrorThrown if either fromSys or toSys is not supported.

Definition at line 202 of file TransformMap.cc.

203  {
204  auto mapping = _getMapping(fromSys, toSys);
205  return POINT2_ENDPOINT.pointFromData(mapping->applyForward(POINT2_ENDPOINT.dataFromPoint(point)));
206 }

◆ transform() [2/2]

std::vector< lsst::geom::Point2D > lsst::afw::cameraGeom::TransformMap::transform ( std::vector< lsst::geom::Point2D > const &  pointList,
CameraSys const &  fromSys,
CameraSys const &  toSys 
) const

Convert a list of points from one coordinate system to another.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 208 of file TransformMap.cc.

210  {
211  auto mapping = _getMapping(fromSys, toSys);
212  return POINT2_ENDPOINT.arrayFromData(mapping->applyForward(POINT2_ENDPOINT.dataFromArray(pointList)));
213 }

◆ writeFits() [1/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::Fits fitsfile) const
inherited

Write the object to an already-open FITS object.

Parameters
[in]fitsfileOpen FITS object to write to.

Definition at line 18 of file Persistable.cc.

18  {
19  OutputArchive archive;
20  archive.put(this);
21  archive.writeFits(fitsfile);
22 }

◆ writeFits() [2/3]

void lsst::afw::table::io::Persistable::writeFits ( fits::MemFileManager manager,
std::string const &  mode = "w" 
) const
inherited

Write the object to a FITS image in memory.

Parameters
[in]managerName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 29 of file Persistable.cc.

29  {
30  fits::Fits fitsfile(manager, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
31  writeFits(fitsfile);
32 }
void writeFits(std::string const &fileName, std::string const &mode="w") const
Write the object to a regular FITS file.
Definition: Persistable.cc:24

◆ writeFits() [3/3]

void lsst::afw::table::io::Persistable::writeFits ( std::string const &  fileName,
std::string const &  mode = "w" 
) const
inherited

Write the object to a regular FITS file.

Parameters
[in]fileNameName of the file to write to.
[in]modeIf "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file.

Definition at line 24 of file Persistable.cc.

24  {
25  fits::Fits fitsfile(fileName, mode, fits::Fits::AUTO_CLOSE | fits::Fits::AUTO_CHECK);
26  writeFits(fitsfile);
27 }

The documentation for this class was generated from the following files: