LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint > Class Template Referencefinal

Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint, using an AST mapping. More...

#include <Transform.h>

Inheritance diagram for lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >:
lsst::afw::table::io::PersistableFacade< Transform< FromEndpoint, ToEndpoint > > lsst::afw::table::io::Persistable

Public Types

using FromArray = typename FromEndpoint::Array
 
using FromPoint = typename FromEndpoint::Point
 
using ToArray = typename ToEndpoint::Array
 
using ToPoint = typename ToEndpoint::Point
 

Public Member Functions

 Transform (Transform const &)=default
 
 Transform (Transform &&)=default
 
Transformoperator= (Transform const &)=delete
 
Transformoperator= (Transform &&)=delete
 
 ~Transform () override=default
 
 Transform (ast::Mapping const &mapping, bool simplify=true)
 Construct a Transform from a deep copy of an ast::Mapping. More...
 
 Transform (ast::FrameSet const &frameSet, bool simplify=true)
 Construct a Transform from a deep copy of a ast::FrameSet. More...
 
bool hasForward () const
 Test if this method has a forward transform. More...
 
bool hasInverse () const
 Test if this method has an inverse transform. More...
 
FromEndpoint getFromEndpoint () const
 Get the "from" endpoint. More...
 
std::shared_ptr< const ast::MappinggetMapping () const
 Get the contained mapping. More...
 
ToEndpoint getToEndpoint () const
 Get the "to" endpoint. More...
 
ToPoint applyForward (FromPoint const &point) const
 Transform one point in the forward direction ("from" to "to") More...
 
ToArray applyForward (FromArray const &array) const
 Transform an array of points in the forward direction ("from" to "to") More...
 
FromPoint applyInverse (ToPoint const &point) const
 Transform one point in the inverse direction ("to" to "from") More...
 
FromArray applyInverse (ToArray const &array) const
 Transform an array of points in the inverse direction ("to" to "from") More...
 
std::shared_ptr< Transform< ToEndpoint, FromEndpoint > > inverted () const
 The inverse of this Transform. More...
 
Eigen::MatrixXd getJacobian (FromPoint const &x) const
 The Jacobian matrix of this Transform. More...
 
template<class NextToEndpoint >
std::shared_ptr< Transform< FromEndpoint, NextToEndpoint > > then (Transform< ToEndpoint, NextToEndpoint > const &next, bool simplify=true) const
 Concatenate two Transforms. More...
 
void writeStream (std::ostream &os) const
 Serialize this Transform to an output stream. More...
 
std::string writeString () const
 Serialize this Transform to a string, using the same format as writeStream. More...
 
bool isPersistable () const noexcept override
 Whether the Transform is persistable via afw::table::io (always true). 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...
 

Static Public Member Functions

static std::string getShortClassName ()
 Return a short version of the class name with no punctuation. More...
 
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readStream (std::istream &is)
 Deserialize a Transform of this type from an input stream. More...
 
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readString (std::string &str)
 Deserialize a Transform of this type from a string, using the same format as readStream. More...
 
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readFits (fits::Fits &fitsfile)
 Read an object from an already open FITS object. More...
 
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU)
 Read an object from a regular FITS file. More...
 
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU)
 Read an object from a FITS file in memory. More...
 
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > dynamicCast (std::shared_ptr< Persistable > const &ptr)
 Dynamically cast a shared_ptr. More...
 

Protected Types

typedef io::OutputArchiveHandle OutputArchiveHandle
 

Protected Member Functions

 Transform (std::shared_ptr< ast::Mapping > mapping)
 Construct a Transform from a shared pointer to an ast::Mapping. More...
 
std::string getPersistenceName () const override
 Return the unique name used to persist this object and look up its factory. More...
 
std::string getPythonModule () const override
 Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More...
 
void write (OutputArchiveHandle &handle) const override
 Write the object to one or more catalogs. More...
 

Friends

class SkyWcs
 

Detailed Description

template<class FromEndpoint, class ToEndpoint>
class lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >

Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint, using an AST mapping.

This class contains two Endpoints, to specify the "from" and "to" LSST data type, and an ast::Mapping to specify the transformation.

Depending on the ast::FrameSet or ast::Mapping used to define it, a Transform may provide either a forward transform, an inverse transform, or both. In particular, the inverse of a forward-only transform is an inverse-only transform. The hasForward and hasInverse methods can be used to check which transforms are available.

Unless otherwise stated, all constructors and methods may throw std::runtime_error to indicate internal errors within AST.

Transforms are always immutable.

Note
You gain some safety by constructing a Transform from an ast::FrameSet, since the base and current frames in the FrameSet can be checked against by the appropriate endpoint.
"In place" versions of applyForward and applyInverse are not available because data must be copied when converting from LSST data types to the type used by astshim, so it didn't seem worth the bother.

Definition at line 67 of file Transform.h.

Member Typedef Documentation

◆ FromArray

template<class FromEndpoint, class ToEndpoint>
using lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::FromArray = typename FromEndpoint::Array

Definition at line 73 of file Transform.h.

◆ FromPoint

template<class FromEndpoint, class ToEndpoint>
using lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::FromPoint = typename FromEndpoint::Point

Definition at line 74 of file Transform.h.

◆ OutputArchiveHandle

typedef io::OutputArchiveHandle lsst::afw::table::io::Persistable::OutputArchiveHandle
protectedinherited

Definition at line 108 of file Persistable.h.

◆ ToArray

template<class FromEndpoint, class ToEndpoint>
using lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::ToArray = typename ToEndpoint::Array

Definition at line 75 of file Transform.h.

◆ ToPoint

template<class FromEndpoint, class ToEndpoint>
using lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::ToPoint = typename ToEndpoint::Point

Definition at line 76 of file Transform.h.

Constructor & Destructor Documentation

◆ Transform() [1/5]

template<class FromEndpoint, class ToEndpoint>
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::Transform ( Transform< FromEndpoint, ToEndpoint > const &  )
default

◆ Transform() [2/5]

template<class FromEndpoint, class ToEndpoint>
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::Transform ( Transform< FromEndpoint, ToEndpoint > &&  )
default

◆ ~Transform()

template<class FromEndpoint, class ToEndpoint>
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::~Transform ( )
overridedefault

◆ Transform() [3/5]

template<class FromEndpoint , class ToEndpoint >
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::Transform ( ast::Mapping const &  mapping,
bool  simplify = true 
)
explicit

Construct a Transform from a deep copy of an ast::Mapping.

Parameters
[in]mappingast::Mapping describing the desired transformation
[in]simplifySimplify the mapping? This combines component mappings where it is possible to do so without affecting accuracy.

Definition at line 45 of file Transform.cc.

46  : _fromEndpoint(mapping.getNIn()),
47  _mapping(simplify ? mapping.simplified() : mapping.copy()),
48  _toEndpoint(mapping.getNOut()) {}

◆ Transform() [4/5]

template<typename FromEndpoint , typename ToEndpoint >
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::Transform ( ast::FrameSet const &  frameSet,
bool  simplify = true 
)
explicit

Construct a Transform from a deep copy of a ast::FrameSet.

The result transforms from the "base" frame to the "current" frame of the provided FrameSet. The "from" endpoint is used to normalize the "base" frame and the "to" endpoint is used to normalize the "current" frame.

This is pickier than the constructor that takes an ast::Mapping in that:

  • SpherePointEndpoint must be associated with an ast::SkyFrame and the SkyFrame axes are transposed, if necessary, to give the standard order: longitude, latitude.
  • Point2Endpoint must be associated with an ast::Frame (not a subclass), because Frame is the only kind of Frame that is sure to be Cartesian.
Parameters
[in]frameSetast::FrameSet describing the desired transformation in the usual way: from "base" frame to "current" frame
[in]simplifySimplify the mapping? This combines component mappings where it is possible to do so without affecting accuracy.

Definition at line 51 of file Transform.cc.

52  : _fromEndpoint(frameSet.getNIn()), _mapping(), _toEndpoint(frameSet.getNOut()) {
53  auto frameSetCopy = frameSet.copy();
54  // Normalize the base and current frame in a way that affects its behavior as a mapping.
55  // To do this one must set the current frame to the frame to be normalized
56  // and normalize the frame set as a frame (i.e. normalize the frame "in situ").
57  // The obvious alternative of normalizing a shallow copy of the frame does not work;
58  // the frame is altered but not the associated mapping!
59 
60  // Normalize the current frame by normalizing the frameset as a frame
61  _toEndpoint.normalizeFrame(frameSetCopy);
62 
63  // Normalize the base frame by temporarily making it the current frame,
64  // normalizing the frameset as a frame, then making it the base frame again
65  const int baseIndex = frameSetCopy->getBase();
66  const int currentIndex = frameSetCopy->getCurrent();
67  frameSetCopy->setCurrent(baseIndex);
68  _fromEndpoint.normalizeFrame(frameSetCopy);
69  frameSetCopy->setBase(baseIndex);
70  frameSetCopy->setCurrent(currentIndex);
71  _mapping = simplify ? frameSetCopy->getMapping()->simplified() : frameSetCopy->getMapping();
72 }

◆ Transform() [5/5]

template<typename FromEndpoint , typename ToEndpoint >
lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::Transform ( std::shared_ptr< ast::Mapping mapping)
explicitprotected

Construct a Transform from a shared pointer to an ast::Mapping.

Definition at line 75 of file Transform.cc.

76  : _fromEndpoint(mapping->getNIn()), _mapping(mapping), _toEndpoint(mapping->getNOut()) {}

Member Function Documentation

◆ applyForward() [1/2]

template<class FromEndpoint , class ToEndpoint >
ToEndpoint::Point lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::applyForward ( FromPoint const &  point) const

Transform one point in the forward direction ("from" to "to")

Definition at line 79 of file Transform.cc.

80  {
81  auto const rawFromData = _fromEndpoint.dataFromPoint(point);
82  auto rawToData = _mapping->applyForward(rawFromData);
83  return _toEndpoint.pointFromData(rawToData);
84 }

◆ applyForward() [2/2]

template<class FromEndpoint , class ToEndpoint >
ToEndpoint::Array lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::applyForward ( FromArray const &  array) const

Transform an array of points in the forward direction ("from" to "to")

The first dimension of the array must match the number of input axes, and the data order is values for the first axis, then values for the next axis, and so on, e.g. for 2 axes: x0, x1, x2, ..., y0, y1, y2...

Definition at line 87 of file Transform.cc.

88  {
89  auto const rawFromData = _fromEndpoint.dataFromArray(array);
90  auto rawToData = _mapping->applyForward(rawFromData);
91  return _toEndpoint.arrayFromData(rawToData);
92 }

◆ applyInverse() [1/2]

template<class FromEndpoint , class ToEndpoint >
FromEndpoint::Point lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::applyInverse ( ToPoint const &  point) const

Transform one point in the inverse direction ("to" to "from")

Definition at line 95 of file Transform.cc.

96  {
97  auto const rawFromData = _toEndpoint.dataFromPoint(point);
98  auto rawToData = _mapping->applyInverse(rawFromData);
99  return _fromEndpoint.pointFromData(rawToData);
100 }

◆ applyInverse() [2/2]

template<class FromEndpoint , class ToEndpoint >
FromEndpoint::Array lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::applyInverse ( ToArray const &  array) const

Transform an array of points in the inverse direction ("to" to "from")

The first dimension of the array must match the number of output axes, and the data order is values for the first axis, then values for the next axis, and so on, e.g. for 2 axes: x0, x1, x2, ..., y0, y1, y2...

Definition at line 103 of file Transform.cc.

104  {
105  auto const rawFromData = _toEndpoint.dataFromArray(array);
106  auto rawToData = _mapping->applyInverse(rawFromData);
107  return _fromEndpoint.arrayFromData(rawToData);
108 }

◆ dynamicCast()

template std::shared_ptr< meas::extensions::psfex::PsfexPsf > lsst::afw::table::io::PersistableFacade< Transform< FromEndpoint, ToEndpoint > >::dynamicCast ( std::shared_ptr< Persistable > const &  ptr)
staticinherited

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 18 of file Persistable.cc.

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

◆ getFromEndpoint()

template<class FromEndpoint, class ToEndpoint>
FromEndpoint lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getFromEndpoint ( ) const
inline

Get the "from" endpoint.

Definition at line 130 of file Transform.h.

130 { return _fromEndpoint; }

◆ getJacobian()

template<class FromEndpoint , class ToEndpoint >
Eigen::MatrixXd lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getJacobian ( FromPoint const &  x) const

The Jacobian matrix of this Transform.

Radians are used for each axis of an SpherePointEndpoint.

The matrix is defined only if this object has a forward transform.

Parameters
xthe position at which the Jacobian shall be evaluated
Returns
a matrix J with getToEndpoint().getNAxes() rows and getFromEndpoint().getNAxes() columns. J(i,j) shall be the rate of change of the ith output coordinate with respect to the jth input coordinate, or NaN if the derivative cannot be calculated.
Exception Safety
Provides basic exception safety.
Note
The derivatives may be estimated by sampling and interpolating this Transform in the neighborhood of x. If the implementation requires interpolation, computation of the Jacobian may require hundreds of evaluations of applyForward.

Definition at line 123 of file Transform.cc.

123  {
124  int const nIn = _fromEndpoint.getNAxes();
125  int const nOut = _toEndpoint.getNAxes();
126  std::vector<double> const point = _fromEndpoint.dataFromPoint(x);
127 
128  Eigen::MatrixXd jacobian(nOut, nIn);
129  for (int i = 0; i < nOut; ++i) {
130  for (int j = 0; j < nIn; ++j) {
131  jacobian(i, j) = _mapping->rate(point, i + 1, j + 1);
132  }
133  }
134  return jacobian;
135 }
double x

◆ getMapping()

template<class FromEndpoint, class ToEndpoint>
std::shared_ptr<const ast::Mapping> lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getMapping ( ) const
inline

Get the contained mapping.

Definition at line 135 of file Transform.h.

135 { return _mapping; }

◆ getPersistenceName()

template<class FromEndpoint, class ToEndpoint>
std::string lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getPersistenceName ( ) const
inlineoverrideprotectedvirtual

Return the unique name used to persist this object and look up its factory.

Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.

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

Definition at line 274 of file Transform.h.

274 { return getShortClassName(); }
static std::string getShortClassName()
Return a short version of the class name with no punctuation.
Definition: Transform.cc:138

◆ getPythonModule()

template<class FromEndpoint, class ToEndpoint>
std::string lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getPythonModule ( ) const
inlineoverrideprotectedvirtual

Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.

Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.

Will be ignored if empty.

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

Definition at line 277 of file Transform.h.

277 { return "lsst.afw.geom"; }

◆ getShortClassName()

template<class FromEndpoint , class ToEndpoint >
std::string lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getShortClassName ( )
static

Return a short version of the class name with no punctuation.

Used as the Python class name and for persistence as a string

Returns "Transform" + fromEndpoint.getClassPrefix() + "To" + toEndpoint.getClassPrefix(), for example "TransformPoint2ToSpherePoint" or "TransformPoint2ToGeneric".

Definition at line 138 of file Transform.cc.

138  {
140  os << "Transform" << FromEndpoint::getClassPrefix() << "To" << ToEndpoint::getClassPrefix();
141  return os.str();
142 }
T str(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ getToEndpoint()

template<class FromEndpoint, class ToEndpoint>
ToEndpoint lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::getToEndpoint ( ) const
inline

Get the "to" endpoint.

Definition at line 140 of file Transform.h.

140 { return _toEndpoint; }

◆ hasForward()

template<class FromEndpoint, class ToEndpoint>
bool lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::hasForward ( ) const
inline

Test if this method has a forward transform.

Exception Safety
Provides basic exception safety.

Definition at line 118 of file Transform.h.

118 { return _mapping->hasForward(); }

◆ hasInverse()

template<class FromEndpoint, class ToEndpoint>
bool lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::hasInverse ( ) const
inline

Test if this method has an inverse transform.

Exception Safety
Provides basic exception safety.

Definition at line 125 of file Transform.h.

125 { return _mapping->hasInverse(); }

◆ inverted()

template<class FromEndpoint , class ToEndpoint >
std::shared_ptr< Transform< ToEndpoint, FromEndpoint > > lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::inverted ( ) const

The inverse of this Transform.

Returns
a Transform whose applyForward is equivalent to this Transform's applyInverse, and vice versa.
Exception Safety
Provides basic exception safety.

Definition at line 111 of file Transform.cc.

111  {
112  auto inverse = std::dynamic_pointer_cast<ast::Mapping>(_mapping->inverted());
113  if (!inverse) {
114  // don't throw std::bad_cast because it doesn't let you provide debugging info
115  std::ostringstream buffer;
116  buffer << "Mapping.inverted() does not return a Mapping. Called from: " << _mapping;
117  throw LSST_EXCEPT(pex::exceptions::LogicError, buffer.str());
118  }
119  return std::make_shared<Transform<ToEndpoint, FromEndpoint>>(*inverse);
120 }
An abstract base class for objects which transform one set of coordinates to another.
Definition: Mapping.h:59
T str(T... args)
T dynamic_pointer_cast(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ isPersistable()

template<class FromEndpoint, class ToEndpoint>
bool lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::isPersistable ( ) const
inlineoverridevirtualnoexcept

Whether the Transform is persistable via afw::table::io (always true).

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

Definition at line 265 of file Transform.h.

265 { return true; }

◆ operator=() [1/2]

template<class FromEndpoint, class ToEndpoint>
Transform& lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::operator= ( Transform< FromEndpoint, ToEndpoint > const &  )
delete

◆ operator=() [2/2]

template<class FromEndpoint, class ToEndpoint>
Transform& lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::operator= ( Transform< FromEndpoint, ToEndpoint > &&  )
delete

◆ readFits() [1/3]

static std::shared_ptr<Transform< FromEndpoint, ToEndpoint > > lsst::afw::table::io::PersistableFacade< Transform< FromEndpoint, ToEndpoint > >::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< Transform< FromEndpoint, ToEndpoint > > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ readFits() [2/3]

static std::shared_ptr<Transform< FromEndpoint, ToEndpoint > > lsst::afw::table::io::PersistableFacade< Transform< FromEndpoint, ToEndpoint > >::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  }
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ readFits() [3/3]

static std::shared_ptr<Transform< FromEndpoint, ToEndpoint > > lsst::afw::table::io::PersistableFacade< Transform< FromEndpoint, ToEndpoint > >::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  }
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18

◆ readStream()

template<class FromEndpoint , class ToEndpoint >
std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::readStream ( std::istream is)
static

Deserialize a Transform of this type from an input stream.

Parameters
[in]isinput stream from which to deserialize this Transform

Definition at line 145 of file Transform.cc.

146  {
147  return detail::readStream<Transform<FromEndpoint, ToEndpoint>>(is);
148 }

◆ readString()

template<class FromEndpoint , class ToEndpoint >
std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::readString ( std::string str)
static

Deserialize a Transform of this type from a string, using the same format as readStream.

Definition at line 151 of file Transform.cc.

152  {
153  std::istringstream is(str);
155 }
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readStream(std::istream &is)
Deserialize a Transform of this type from an input stream.
Definition: Transform.cc:145

◆ then()

template<class FromEndpoint , class ToEndpoint>
template<class NextToEndpoint >
template std::shared_ptr< Transform< SpherePointEndpoint, SpherePointEndpoint > > lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::then< SpherePointEndpoint > ( Transform< ToEndpoint, NextToEndpoint > const &  next,
bool  simplify = true 
) const

Concatenate two Transforms.

Template Parameters
NextToEndpointthe "to" Endpoint of next
Parameters
nextthe Transform to apply after this one
simplifyif true then produce a transform containing a single simplified mapping with no intermediate frames.
Returns
a Transform that first applies this transform to its input, and then next to the result. Its inverse shall first apply the inverse of next, and then the inverse of this transform.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if getToEndpoint() and next.getFromEndpoint() do not have the same number of axes.
Exception Safety
Provides basic exception safety.

More than two Transforms can be combined in series. For example:

auto pixelsToSky = pixelsToFp.then(fpToField)->then(fieldToSky);

Definition at line 171 of file Transform.cc.

172  {
173  if (_toEndpoint.getNAxes() == next.getFromEndpoint().getNAxes()) {
174  auto nextMapping = next.getMapping();
175  auto combinedMapping = getMapping()->then(*next.getMapping());
176  if (simplify) {
177  return std::make_shared<Transform<FromEndpoint, NextToEndpoint>>(*combinedMapping.simplified());
178  } else {
179  return std::make_shared<Transform<FromEndpoint, NextToEndpoint>>(combinedMapping);
180  }
181  } else {
182  auto message = "Cannot match " + std::to_string(_toEndpoint.getNAxes()) + "-D to-endpoint to " +
183  std::to_string(next.getFromEndpoint().getNAxes()) + "-D from-endpoint.";
184  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, message);
185  }
186 }
std::shared_ptr< const ast::Mapping > getMapping() const
Get the contained mapping.
Definition: Transform.h:135
T to_string(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ write()

template<class FromEndpoint , class ToEndpoint >
void lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::write ( OutputArchiveHandle handle) const
overrideprotectedvirtual

Write the object to one or more catalogs.

The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.

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

Definition at line 241 of file Transform.cc.

241  {
242  auto const &keys = TransformPersistenceHelper::get();
243  table::BaseCatalog cat = handle.makeCatalog(keys.schema);
244  std::shared_ptr<table::BaseRecord> record = cat.addNew();
245  record->set(keys.bytes, formatters::stringToBytes(writeString()));
246  handle.saveCatalog(cat);
247 }
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
std::string writeString() const
Serialize this Transform to a string, using the same format as writeStream.
Definition: Transform.cc:163
ndarray::Array< std::uint8_t, 1, 1 > stringToBytes(std::string const &str)
Encode a std::string as a vector of uint8.
Definition: Utils.cc:162

◆ writeFits() [1/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 }
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() [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 ( 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 }

◆ writeStream()

template<class FromEndpoint , class ToEndpoint >
void lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::writeStream ( std::ostream os) const

Serialize this Transform to an output stream.

Version 1 format is as follows:

  • The version number (an integer)
  • A space
  • The short class name, as obtained from getShortClassName
  • A space
  • The contained ast::FrameSet written using FrameSet.show(os, false)
Parameters
[out]osoutpu stream to which to serialize this Transform

Definition at line 158 of file Transform.cc.

158  {
159  detail::writeStream<Transform<FromEndpoint, ToEndpoint>>(*this, os);
160 }
std::ostream * os
Definition: Schema.cc:746

◆ writeString()

template<class FromEndpoint , class ToEndpoint >
std::string lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >::writeString ( ) const

Serialize this Transform to a string, using the same format as writeStream.

Definition at line 163 of file Transform.cc.

163  {
165  writeStream(os);
166  return os.str();
167 }
T str(T... args)
void writeStream(std::ostream &os) const
Serialize this Transform to an output stream.
Definition: Transform.cc:158
std::ostream * os
Definition: Schema.cc:746

Friends And Related Function Documentation

◆ SkyWcs

template<class FromEndpoint, class ToEndpoint>
friend class SkyWcs
friend

Definition at line 70 of file Transform.h.


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