LSSTApplications  19.0.0-16-gf391218+0d4bdb7e99,20.0.0-11-g973f35b+fc3da11c03,20.0.0-18-g2b8c1f54+f8fc1aa9fb,20.0.0-2-g103fe59+1a747c5cf5,20.0.0-2-g1367e85+b8fe48c8a0,20.0.0-2-g7f82c8f+cb8155b8e8,20.0.0-2-g8dde007+aaa4e16c0f,20.0.0-2-ga326454+cb8155b8e8,20.0.0-2-ga51b5d4+6432c6fd8d,20.0.0-2-gde069b7+44dbdb3492,20.0.0-2-gfc62afb+b8fe48c8a0,20.0.0-20-g54e6697de+ce03d725a7,20.0.0-22-g54e2caa+e2d4a7822a,20.0.0-25-g5eafb0f+f4a3e7a5aa,20.0.0-28-g73474ed+96410ea1f8,20.0.0-3-g5242d73+b8fe48c8a0,20.0.0-3-ga63a54e+af87b3138b,20.0.0-30-g597c966+cf8eea114e,20.0.0-4-g2909d54+37efb4748c,20.0.0-4-g35ce6d5+f4a3e7a5aa,20.0.0-4-g45278ab+d529cf1a41,20.0.0-4-g4bc9b9f+a7376eab67,20.0.0-4-g66bcc37+f4a3e7a5aa,20.0.0-4-ge17e5af+b8fe48c8a0,20.0.0-4-gecfae73+77584f1b13,20.0.0-4-gf910f65+37efb4748c,20.0.0-46-gd70f10e1+f17cbaf3d1,20.0.0-5-g8f08a60+4fac22bdb7,20.0.0-5-ga885a99+c1363b8d99,20.0.0-5-gc738bc1+47717dd73f,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-gd222c45+88b21af515,20.0.0-6-gdef485e+46cd8289a4,20.0.0-7-gaa929c8+96410ea1f8,20.0.0-74-g0218c7a+939693069d,20.0.0-8-g5dd23de+1834535a4e,20.0.0-8-ge712728+fb4ad641b9,20.0.0-9-g5051ac2+d529cf1a41,w.2020.48-1-gdf601d2
LSSTDataManagementBasePackage
Transform.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2017 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 
24 #ifndef LSST_AFW_GEOM_TRANSFORM_H
25 #define LSST_AFW_GEOM_TRANSFORM_H
26 
27 #include <memory>
28 #include <vector>
29 
30 #include "astshim.h"
31 #include "Eigen/Core"
32 #include "ndarray.h"
33 
34 #include "lsst/afw/geom/Endpoint.h"
36 
37 namespace lsst {
38 namespace afw {
39 namespace geom {
40 
41 class SkyWcs;
42 
66 template <class FromEndpoint, class ToEndpoint>
67 class Transform final : public table::io::PersistableFacade<Transform<FromEndpoint, ToEndpoint>>,
68  public table::io::Persistable {
69  // SkyWcs is a friend so it can call a protected Transform constructor
70  friend class SkyWcs;
71 
72 public:
73  using FromArray = typename FromEndpoint::Array;
74  using FromPoint = typename FromEndpoint::Point;
75  using ToArray = typename ToEndpoint::Array;
76  using ToPoint = typename ToEndpoint::Point;
77 
78  Transform(Transform const &) = default;
79  Transform(Transform &&) = default;
80  Transform &operator=(Transform const &) = delete;
81  Transform &operator=(Transform &&) = delete;
82  ~Transform() override = default;
83 
91  explicit Transform(ast::Mapping const &mapping, bool simplify = true);
92 
111  explicit Transform(ast::FrameSet const &frameSet, bool simplify = true);
112 
118  bool hasForward() const { return _mapping->hasForward(); }
119 
125  bool hasInverse() const { return _mapping->hasInverse(); }
126 
130  FromEndpoint getFromEndpoint() const { return _fromEndpoint; }
131 
135  std::shared_ptr<const ast::Mapping> getMapping() const { return _mapping; }
136 
140  ToEndpoint getToEndpoint() const { return _toEndpoint; }
141 
145  ToPoint applyForward(FromPoint const &point) const;
146 
154  ToArray applyForward(FromArray const &array) const;
155 
159  FromPoint applyInverse(ToPoint const &point) const;
160 
168  FromArray applyInverse(ToArray const &array) const;
169 
179 
201  Eigen::MatrixXd getJacobian(FromPoint const &x) const;
202 
223  template <class NextToEndpoint>
225  Transform<ToEndpoint, NextToEndpoint> const &next, bool simplify = true) const;
226 
236 
243 
246 
259  void writeStream(std::ostream &os) const;
260 
262  std::string writeString() const;
263 
265  bool isPersistable() const noexcept override { return true; }
266 
267 protected:
271  explicit Transform(std::shared_ptr<ast::Mapping> mapping);
272 
273  // implement afw::table::io::Persistable interface
274  std::string getPersistenceName() const override { return getShortClassName(); }
275 
276  // implement afw::table::io::Persistable interface
277  std::string getPythonModule() const override { return "lsst.afw.geom"; }
278 
279  // implement afw::table::io::Persistable interface
280  void write(OutputArchiveHandle &handle) const override;
281 
282 private:
283  FromEndpoint _fromEndpoint;
285  ToEndpoint _toEndpoint;
286 };
287 
295 template <class FromEndpoint, class ToEndpoint>
296 std::ostream &operator<<(std::ostream &os, Transform<FromEndpoint, ToEndpoint> const &transform);
297 
298 // typedefs for the most common transforms; names match Python names
299 
303 
304 } // namespace geom
305 } // namespace afw
306 } // namespace lsst
307 
308 #endif
lsst::afw::geom::Transform::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: Transform.cc:241
lsst::afw::geom::Transform::~Transform
~Transform() override=default
lsst::afw::geom::Transform::operator=
Transform & operator=(Transform const &)=delete
astshim.fitsChanContinued.next
def next(self)
Definition: fitsChanContinued.py:105
lsst::afw::geom::Transform::hasInverse
bool hasInverse() const
Test if this method has an inverse transform.
Definition: Transform.h:125
lsst::afw::geom::Transform::operator=
Transform & operator=(Transform &&)=delete
lsst::afw::geom::Transform::getFromEndpoint
FromEndpoint getFromEndpoint() const
Get the "from" endpoint.
Definition: Transform.h:130
ast::FrameSet
A FrameSet consists of a set of one or more Frames (which describe coordinate systems),...
Definition: FrameSet.h:99
std::string
STL class.
std::shared_ptr< const ast::Mapping >
lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >::FromArray
typename FromEndpoint::Array FromArray
Definition: Transform.h:73
lsst::afw::geom::Transform
Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint,...
Definition: Transform.h:68
ast::Mapping
An abstract base class for objects which transform one set of coordinates to another.
Definition: Mapping.h:59
lsst::afw::geom::Transform::hasForward
bool hasForward() const
Test if this method has a forward transform.
Definition: Transform.h:118
lsst::afw::geom::Transform::getShortClassName
static std::string getShortClassName()
Return a short version of the class name with no punctuation.
Definition: Transform.cc:138
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::geom::Transform::applyForward
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
Definition: Transform.cc:79
Persistable.h
lsst::afw::geom::Transform::getToEndpoint
ToEndpoint getToEndpoint() const
Get the "to" endpoint.
Definition: Transform.h:140
lsst::afw::geom::SkyWcs
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
Endpoint.h
ast::Mapping::hasInverse
bool hasInverse() const
Is the inverse transform available?
Definition: Mapping.h:123
astshim.h
lsst::afw::geom::Transform::getPythonModule
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition: Transform.h:277
ast::Mapping::hasForward
bool hasForward() const
Is the forward transform available?
Definition: Mapping.h:114
lsst::afw::geom::Transform::writeStream
void writeStream(std::ostream &os) const
Serialize this Transform to an output stream.
Definition: Transform.cc:158
lsst::afw::geom::Transform::Transform
Transform(Transform &&)=default
lsst::afw::geom::operator<<
std::ostream & operator<<(std::ostream &os, GenericEndpoint const &endpoint)
Print "GenericEndpoint(_n_)" to the ostream where _n_ is the number of axes, e.g. "GenericAxes(4)".
Definition: Endpoint.cc:240
lsst::afw::geom::Transform::isPersistable
bool isPersistable() const noexcept override
Whether the Transform is persistable via afw::table::io (always true).
Definition: Transform.h:265
lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >::ToArray
typename ToEndpoint::Array ToArray
Definition: Transform.h:75
std::ostream
STL class.
lsst::afw::geom::Transform::readStream
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
x
double x
Definition: ChebyshevBoundedField.cc:277
frameSet
table::Key< table::Array< std::uint8_t > > frameSet
Definition: TransformBoundedField.cc:91
lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >::FromPoint
typename FromEndpoint::Point FromPoint
Definition: Transform.h:74
lsst::afw::geom::Transform::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: Transform.h:274
lsst::afw::geom::Transform::readString
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.
Definition: Transform.cc:151
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::geom::Transform::getMapping
std::shared_ptr< const ast::Mapping > getMapping() const
Get the contained mapping.
Definition: Transform.h:135
lsst::geom
Definition: AffineTransform.h:36
lsst::afw::table::io::Persistable
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
os
std::ostream * os
Definition: Schema.cc:746
lsst::afw::geom::Transform::Transform
Transform(Transform const &)=default
lsst::afw::geom::Transform::inverted
std::shared_ptr< Transform< ToEndpoint, FromEndpoint > > inverted() const
The inverse of this Transform.
Definition: Transform.cc:111
lsst::afw::geom::Transform::writeString
std::string writeString() const
Serialize this Transform to a string, using the same format as writeStream.
Definition: Transform.cc:163
lsst::afw::table::io::PersistableFacade
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >::ToPoint
typename ToEndpoint::Point ToPoint
Definition: Transform.h:76
transform
table::Key< int > transform
Definition: TransformMap.cc:299
lsst::afw::geom::Transform::getJacobian
Eigen::MatrixXd getJacobian(FromPoint const &x) const
The Jacobian matrix of this Transform.
Definition: Transform.cc:123
lsst::afw::geom::Transform::applyInverse
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction ("to" to "from")
Definition: Transform.cc:95
std::istream
STL class.
lsst::afw::table::io::Persistable::OutputArchiveHandle
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:108
lsst::afw::geom::Transform::then
std::shared_ptr< Transform< FromEndpoint, NextToEndpoint > > then(Transform< ToEndpoint, NextToEndpoint > const &next, bool simplify=true) const
Concatenate two Transforms.
Definition: Transform.cc:171