lsst.afw  14.0-27-gbdf48f848+1
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"
35 
36 namespace lsst {
37 namespace afw {
38 namespace geom {
39 
40 class SkyWcs;
41 
65 template <class FromEndpoint, class ToEndpoint>
66 class Transform final {
67  // SkyWcs is a friend so it can call a protected Transform constructor
68  friend class SkyWcs;
69 
70 public:
71  using FromArray = typename FromEndpoint::Array;
72  using FromPoint = typename FromEndpoint::Point;
73  using ToArray = typename ToEndpoint::Array;
74  using ToPoint = typename ToEndpoint::Point;
75 
76  Transform(Transform const &) = default;
77  Transform(Transform &&) = default;
78  Transform &operator=(Transform const &) = delete;
79  Transform &operator=(Transform &&) = delete;
80 
91  explicit Transform(ast::Mapping const &mapping, bool simplify = true);
92 
113  explicit Transform(ast::FrameSet const &frameSet, bool simplify = true);
114 
120  bool hasForward() const { return _frameSet->hasForward(); }
121 
127  bool hasInverse() const { return _frameSet->hasInverse(); }
128 
132  FromEndpoint getFromEndpoint() const { return _fromEndpoint; }
133 
137  std::shared_ptr<const ast::FrameSet> getFrameSet() const { return _frameSet; }
138 
142  ToEndpoint getToEndpoint() const { return _toEndpoint; }
143 
147  ToPoint applyForward(FromPoint const &point) const;
148 
156  ToArray applyForward(FromArray const &array) const;
157 
161  FromPoint applyInverse(ToPoint const &point) const;
162 
170  FromArray applyInverse(ToArray const &array) const;
171 
181 
203  Eigen::MatrixXd getJacobian(FromPoint const &x) const;
204 
225  template <class NextToEndpoint>
227  Transform<ToEndpoint, NextToEndpoint> const &next, bool simplify = true) const;
228 
238 
245 
248 
261  void writeStream(std::ostream &os) const;
262 
264  std::string writeString() const;
265 
266 protected:
273 
274 private:
275  FromEndpoint _fromEndpoint;
277  ToEndpoint _toEndpoint;
278 };
279 
287 template <class FromEndpoint, class ToEndpoint>
288 std::ostream &operator<<(std::ostream &os, Transform<FromEndpoint, ToEndpoint> const &transform);
289 
290 // typedefs for the most common transforms; names match Python names
291 
295 
296 } // namespace geom
297 } // namespace afw
298 } // namespace lsst
299 
300 #endif
ToEndpoint getToEndpoint() const
Get the "to" endpoint.
Definition: Transform.h:142
FromEndpoint getFromEndpoint() const
Get the "from" endpoint.
Definition: Transform.h:132
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:114
bool hasInverse() const
Test if this method has an inverse transform.
Definition: Transform.h:127
Transform & operator=(Transform const &)=delete
std::shared_ptr< Transform< ToEndpoint, FromEndpoint > > getInverse() const
The inverse of this Transform.
std::shared_ptr< const ast::FrameSet > getFrameSet() const
Get the contained frameset.
Definition: Transform.h:137
Transform(Transform const &)=default
STL class.
static std::string getShortClassName()
Return a short version of the class name with no punctuation.
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
STL class.
bool hasForward() const
Test if this method has a forward transform.
Definition: Transform.h:120
std::shared_ptr< Transform< FromEndpoint, NextToEndpoint > > then(Transform< ToEndpoint, NextToEndpoint > const &next, bool simplify=true) const
Concatenate two Transforms.
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readStream(std::istream &is)
Deserialize a Transform of this type from an input stream.
A base class for image defects.
table::Key< table::Array< std::uint8_t > > frameSet
double x
Eigen::MatrixXd getJacobian(FromPoint const &x) const
The Jacobian matrix of this Transform.
void writeStream(std::ostream &os) const
Serialize this Transform to an output stream.
std::string writeString() const
Serialize this Transform to a string, using the same format as writeStream.
STL class.
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.
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction ("to" to "from")
Transform LSST spatial data, such as Point2D and IcrsCoord, using an AST transform.
Definition: Transform.h:66