LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
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
36
37namespace lsst {
38namespace afw {
39namespace geom {
40
41class SkyWcs;
42
66template <class FromEndpoint, class ToEndpoint>
67class Transform final : public table::io::PersistableFacade<Transform<FromEndpoint, ToEndpoint>>,
69 // SkyWcs is a friend so it can call a protected Transform constructor
70 friend class SkyWcs;
71
72public:
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;
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
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
263
265 bool isPersistable() const noexcept override { return true; }
266
267protected:
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
282private:
283 FromEndpoint _fromEndpoint;
285 ToEndpoint _toEndpoint;
286};
287
295template <class FromEndpoint, class ToEndpoint>
297
298// typedefs for the most common transforms; names match Python names
299
303
304// Instances defined in Transform.cc need to be declared here as external.
305// Otherwise The implementations are not found in the shared library.
306// with newer compiler/linker versions on osx.
307
317
318} // namespace geom
319} // namespace afw
320} // namespace lsst
321
322#endif
A FrameSet consists of a set of one or more Frames (which describe coordinate systems),...
Definition FrameSet.h:99
An abstract base class for objects which transform one set of coordinates to another.
Definition Mapping.h:59
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition SkyWcs.h:118
Transform LSST spatial data, such as lsst::geom::Point2D and lsst::geom::SpherePoint,...
Definition Transform.h:68
Transform(ast::FrameSet const &frameSet, bool simplify=true)
Construct a Transform from a deep copy of a ast::FrameSet.
Definition Transform.cc:50
~Transform() override=default
Transform(ast::Mapping const &mapping, bool simplify=true)
Construct a Transform from a deep copy of an ast::Mapping.
Definition Transform.cc:44
typename FromEndpoint::Point FromPoint
Definition Transform.h:74
std::shared_ptr< const ast::Mapping > getMapping() const
Get the contained mapping.
Definition Transform.h:135
FromEndpoint getFromEndpoint() const
Get the "from" endpoint.
Definition Transform.h:130
static std::shared_ptr< Transform< FromEndpoint, ToEndpoint > > readStream(std::istream &is)
Deserialize a Transform of this type from an input stream.
Definition Transform.cc:144
Transform(Transform &&)=default
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition Transform.h:274
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction ("to" to "from")
typename ToEndpoint::Array ToArray
Definition Transform.h:75
static std::string getShortClassName()
Return a short version of the class name with no punctuation.
Definition Transform.cc:137
std::shared_ptr< Transform< ToEndpoint, FromEndpoint > > inverted() const
The inverse of this Transform.
Definition Transform.cc:110
Transform(std::shared_ptr< ast::Mapping > mapping)
Construct a Transform from a shared pointer to an ast::Mapping.
Definition Transform.cc:74
ToEndpoint getToEndpoint() const
Get the "to" endpoint.
Definition Transform.h:140
bool hasInverse() const
Test if this method has an inverse transform.
Definition Transform.h:125
typename ToEndpoint::Point ToPoint
Definition Transform.h:76
bool isPersistable() const noexcept override
Whether the Transform is persistable via afw::table::io (always true).
Definition Transform.h:265
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition Transform.cc:240
bool hasForward() const
Test if this method has a forward transform.
Definition Transform.h:118
Eigen::MatrixXd getJacobian(FromPoint const &x) const
The Jacobian matrix of this Transform.
Definition Transform.cc:122
std::string writeString() const
Serialize this Transform to a string, using the same format as writeStream.
Definition Transform.cc:162
typename FromEndpoint::Array FromArray
Definition Transform.h:73
FromArray applyInverse(ToArray const &array) const
Transform an array of points in the inverse direction ("to" to "from")
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
Transform(Transform const &)=default
ToArray applyForward(FromArray const &array) const
Transform an array of points in the forward direction ("from" to "to")
Transform & operator=(Transform const &)=delete
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:150
std::shared_ptr< Transform< FromEndpoint, NextToEndpoint > > then(Transform< ToEndpoint, NextToEndpoint > const &next, bool simplify=true) const
Concatenate two Transforms.
Definition Transform.cc:170
Transform & operator=(Transform &&)=delete
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
void writeStream(std::ostream &os) const
Serialize this Transform to an output stream.
Definition Transform.cc:157
A CRTP facade class for subclasses of Persistable.
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition Persistable.h:74
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:239
Transform< Point2Endpoint, SpherePointEndpoint > TransformPoint2ToSpherePoint
Definition Transform.h:302
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition Transform.h:300
Transform< Point2Endpoint, GenericEndpoint > TransformPoint2ToGeneric
Definition Transform.h:301