lsst.afw  14.0-23-g38c323faa+3
SkyWcs.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2017 AURA/LSST.
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_SKYWCS_H
25 #define LSST_AFW_GEOM_SKYWCS_H
26 
27 #include <memory>
28 #include <utility>
29 #include <vector>
30 
31 #include "Eigen/Core"
32 #include "astshim.h"
33 #include "ndarray.h"
34 
35 #include "lsst/afw/coord/Coord.h"
36 #include "lsst/afw/geom/Angle.h"
37 #include "lsst/afw/geom/Point.h"
38 #include "lsst/afw/geom/Endpoint.h"
41 
42 namespace lsst {
43 namespace afw {
44 namespace geom {
45 
59 Eigen::Matrix2d makeCdMatrix(Angle const &scale, Angle const &orientation = 0 * degrees, bool flipX = false);
60 
98 public:
99  SkyWcs(SkyWcs const &) = default;
100  SkyWcs(SkyWcs &&) = default;
101  SkyWcs &operator=(SkyWcs const &) = delete;
102  SkyWcs &operator=(SkyWcs &&) = delete;
103 
113  explicit SkyWcs(Point2D const &crpix, coord::IcrsCoord const &crval, Eigen::Matrix2d const &cdMatrix);
114 
126  explicit SkyWcs(daf::base::PropertyList &metadata, bool strip = true);
127 
137  explicit SkyWcs(ast::FrameSet const &frameSet);
138 
139  ~SkyWcs(){};
140 
146  Angle getPixelScale(Point2D const &pixel) const;
147 
153  Angle getPixelScale() const;
154 
158  Point2D getPixelOrigin() const;
159 
164 
168  Eigen::Matrix2d getCdMatrix(Point2D const &pixel) const;
169 
173  Eigen::Matrix2d getCdMatrix() const;
174 
178  SkyWcs getTanWcs(Point2D const &pixel) const;
179 
183  SkyWcs copyAtShiftedPixelOrigin(Extent2D const &shift) const;
184 
191  std::pair<Angle, Angle> pixelToSky(double x, double y) const;
192  coord::IcrsCoord pixelToSky(Point2D const &pixel) const { return applyForward(pixel); };
194  return applyForward(pixels);
195  }
197 
204  std::pair<double, double> skyToPixel(Angle const &ra, Angle const &dec) const;
205  Point2D skyToPixel(coord::IcrsCoord const &sky) const { return applyInverse(sky); }
207  return applyInverse(sky);
208  }
210 
212 
218  static SkyWcs readStream(std::istream & is);
219 
221  static SkyWcs readString(std::string & str);
222 
235  void writeStream(std::ostream & os) const override;
236 
238  std::string writeString() const override;
239 
240 private:
241  // Construct a SkyWcs from a shared pointer to an ast::FrameSet
242  explicit SkyWcs(std::shared_ptr<ast::FrameSet> &&frameSet);
243 
244  // Check a FrameSet to see if it can safely be used for a SkyWcs
245  // Return a copy so that it can be used as an argument to the SkyWcs(shared_ptr<FrameSet>) constructor
246  std::shared_ptr<ast::FrameSet> _checkFrameSet(ast::FrameSet const &frameSet) const;
247 };
248 
264 
265 } // namespace geom
266 } // namespace afw
267 } // namespace lsst
268 
269 #endif
TransformPoint2ToPoint2 makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
coord::IcrsCoord getSkyOrigin() const
Get CRVAL, the sky origin or celestial fiducial point.
A WCS that transform pixels to ICRS RA/Dec using the LSST standard for pixels.
Definition: SkyWcs.h:97
lsst::afw::geom::Angle Angle
Definition: misc.h:36
SkyWcs copyAtShiftedPixelOrigin(Extent2D const &shift) const
Return a copy of this SkyWcs with the pixel origin by the specified amount.
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:117
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
static SkyWcs readString(std::string &str)
Deserialize a SkyWcs from a string, using the same format as readStream.
table::PointKey< double > crval
Definition: Wcs.cc:929
STL class.
std::vector< coord::IcrsCoord > pixelToSky(std::vector< Point2D > const &pixels) const
Compute sky position(s) from pixel position(s)
Definition: SkyWcs.h:193
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
STL class.
Eigen::Matrix2d getCdMatrix() const
Get the 2x2 CD matrix at the pixel origin.
A class representing an angle.
Definition: Angle.h:102
A base class for image defects.
Angle getPixelScale() const
Get the pixel scale at the pixel origin.
table::Key< table::Array< std::uint8_t > > frameSet
static std::string getShortClassName()
void writeStream(std::ostream &os) const override
Serialize this SkyWcs to an output stream.
double x
coord::IcrsCoord pixelToSky(Point2D const &pixel) const
Compute sky position(s) from pixel position(s)
Definition: SkyWcs.h:192
Point2D skyToPixel(coord::IcrsCoord const &sky) const
Compute pixel position(s) from sky position(s)
Definition: SkyWcs.h:205
std::vector< Point2D > skyToPixel(std::vector< coord::IcrsCoord > const &sky) const
Compute pixel position(s) from sky position(s)
Definition: SkyWcs.h:206
Point2D getPixelOrigin() const
Get CRPIX, the pixel origin, using the LSST convention.
static SkyWcs readStream(std::istream &is)
Deserialize a SkyWcs from an input stream.
STL class.
std::pair< double, double > skyToPixel(Angle const &ra, Angle const &dec) const
Compute pixel position(s) from sky position(s)
SkyWcs(SkyWcs const &)=default
SkyWcs getTanWcs(Point2D const &pixel) const
Get a local TAN WCS approximation to this WCS at the specified pixel position.
std::string writeString() const override
Serialize this SkyWcs to a string, using the same format as writeStream.
Eigen::Matrix2d makeCdMatrix(Angle const &scale, Angle const &orientation=0 *degrees, bool flipX=false)
Make a WCS CD matrix.
table::PointKey< int > pixel
SkyWcs & operator=(SkyWcs const &)=delete
STL class.
A class to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:288
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:64
std::pair< Angle, Angle > pixelToSky(double x, double y) const
Compute sky position(s) from pixel position(s)
table::PointKey< double > crpix
Definition: Wcs.cc:930