LSSTApplications  12.1-5-gbdcc3ab+2,15.0+13,15.0+26,15.0-1-g19261fa+17,15.0-1-g60afb23+26,15.0-1-g615e0bb+18,15.0-1-g788a293+26,15.0-1-ga91101e+26,15.0-1-gae1598d+12,15.0-1-gd076f1f+24,15.0-1-gdf18595+5,15.0-1-gf4f1c34+12,15.0-11-g7db6e543+4,15.0-12-g3681e7a+4,15.0-15-gc15de322,15.0-16-g83b84f4,15.0-2-g100d730+19,15.0-2-g1f9c9cf+4,15.0-2-g8aea5f4+1,15.0-2-gf38729e+21,15.0-29-ga12a2b06e,15.0-3-g11fe1a0+14,15.0-3-g707930d+3,15.0-3-g9103c06+12,15.0-3-gd3cbb57+3,15.0-4-g2d82b59,15.0-4-g535e784+10,15.0-4-g92ca6c3+4,15.0-4-gf906033+2,15.0-5-g23e394c+14,15.0-5-g4be42a9,15.0-6-g69628aa,15.0-6-g86e3f3d+1,15.0-6-gfa9b38f+4,15.0-7-g949993c+3,15.0-8-g67a62d3+1,15.0-8-gcf05001+1,15.0-9-g1e7c341+1,w.2018.21
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 :
68  public table::io::PersistableFacade<Transform<FromEndpoint,ToEndpoint>>,
70 {
71  // SkyWcs is a friend so it can call a protected Transform constructor
72  friend class SkyWcs;
73 
74 public:
75  using FromArray = typename FromEndpoint::Array;
76  using FromPoint = typename FromEndpoint::Point;
77  using ToArray = typename ToEndpoint::Array;
78  using ToPoint = typename ToEndpoint::Point;
79 
80  Transform(Transform const &) = default;
81  Transform(Transform &&) = default;
82  Transform &operator=(Transform const &) = delete;
83  Transform &operator=(Transform &&) = delete;
84  ~Transform() = default;
85 
93  explicit Transform(ast::Mapping const &mapping, bool simplify = true);
94 
113  explicit Transform(ast::FrameSet const &frameSet, bool simplify = true);
114 
120  bool hasForward() const { return _mapping->hasForward(); }
121 
127  bool hasInverse() const { return _mapping->hasInverse(); }
128 
132  FromEndpoint getFromEndpoint() const { return _fromEndpoint; }
133 
137  std::shared_ptr<const ast::Mapping> getMapping() const { return _mapping; }
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 
267  bool isPersistable() const override { return true; }
268 
269 protected:
274 
275  // implement afw::table::io::Persistable interface
276  std::string getPersistenceName() const override { return getShortClassName(); }
277 
278  // implement afw::table::io::Persistable interface
279  std::string getPythonModule() const override { return "lsst.afw.geom"; }
280 
281  // implement afw::table::io::Persistable interface
282  void write(OutputArchiveHandle &handle) const override;
283 
284 private:
285  FromEndpoint _fromEndpoint;
287  ToEndpoint _toEndpoint;
288 };
289 
297 template <class FromEndpoint, class ToEndpoint>
298 std::ostream &operator<<(std::ostream &os, Transform<FromEndpoint, ToEndpoint> const &transform);
299 
300 // typedefs for the most common transforms; names match Python names
301 
305 
306 } // namespace geom
307 } // namespace afw
308 } // namespace lsst
309 
310 #endif
ToEndpoint getToEndpoint() const
Get the "to" endpoint.
Definition: Transform.h:142
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:149
FromEndpoint getFromEndpoint() const
Get the "from" endpoint.
Definition: Transform.h:132
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
Definition: Transform.cc:77
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:113
bool hasInverse() const
Test if this method has an inverse transform.
Definition: Transform.h:127
std::shared_ptr< Transform< ToEndpoint, FromEndpoint > > getInverse() const
The inverse of this Transform.
Definition: Transform.cc:109
std::shared_ptr< Transform< FromEndpoint, NextToEndpoint > > then(Transform< ToEndpoint, NextToEndpoint > const &next, bool simplify=true) const
Concatenate two Transforms.
Definition: Transform.cc:169
Transform & operator=(Transform const &)=delete
An object passed to Persistable::write to allow it to persist itself.
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:279
std::shared_ptr< const ast::Mapping > getMapping() const
Get the contained mapping.
Definition: Transform.h:137
Transform(Transform const &)=default
static std::string getShortClassName()
Return a short version of the class name with no punctuation.
Definition: Transform.cc:136
table::Key< int > transform
An abstract base class for objects which transform one set of coordinates to another.
Definition: Mapping.h:59
STL class.
STL class.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
bool hasForward() const
Test if this method has a forward transform.
Definition: Transform.h:120
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: Transform.h:276
A base class for image defects.
Definition: cameraGeom.dox:3
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction ("to" to "from")
Definition: Transform.cc:93
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: Transform.cc:249
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readStream(std::istream &is)
Deserialize a Transform of this type from an input stream.
Definition: Transform.cc:143
double x
Eigen::MatrixXd getJacobian(FromPoint const &x) const
The Jacobian matrix of this Transform.
Definition: Transform.cc:121
bool isPersistable() const override
Whether the Transform is persistable via afw::table::io (always true).
Definition: Transform.h:267
void writeStream(std::ostream &os) const
Serialize this Transform to an output stream.
Definition: Transform.cc:156
std::string writeString() const
Serialize this Transform to a string, using the same format as writeStream.
Definition: Transform.cc:161
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
STL class.
A FrameSet consists of a set of one or more Frames (which describe coordinate systems), connected together by Mappings (which describe how the coordinate systems are inter-related).
Definition: FrameSet.h:99
std::ostream * os
Definition: Schema.cc:736
Transform LSST spatial data, such as Point2D and SpherePoint, using an AST mapping.
Definition: Transform.h:67