LSSTApplications  11.0-22-g33de520,13.0+153,14.0+52,14.0+57,14.0-1-g013352c+36,14.0-1-g13ef843+9,14.0-1-g4b114ac+14,14.0-1-g7257b6a+12,14.0-1-g8b7e855+51,14.0-13-g7a60b79+2,14.0-14-g87d16e8+10,14.0-14-gbf7a6f8a,14.0-17-g4f4ea82+5,14.0-2-g319577b+11,14.0-2-ga5af9b6+10,14.0-22-gc48c03f+3,14.0-3-g20413be+3,14.0-46-g76222d5f+3,14.0-47-g0a51fac97,14.0-5-g744ff5f+2,14.0-5-g86eb1bd+31,14.0-6-gd5b81a9+6,14.0-6-ge2c9487+42,14.0-8-g7f6dd6b+6,14.0-8-gb81b6e9+4,14.0-9-g11010eb,14.0-9-g330837b+5
LSSTDataManagementBasePackage
TanWcs.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008, 2009, 2010 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_IMAGE_TANWCS_H
25 #define LSST_AFW_IMAGE_TANWCS_H
26 
27 #include "Eigen/Core"
28 #include "lsst/daf/base/Citizen.h"
30 #include "lsst/afw/image/Image.h"
32 #include "lsst/afw/image/Wcs.h"
33 #include "lsst/afw/geom/Point.h"
34 #include "lsst/afw/geom/Extent.h"
35 
36 struct wcsprm; // defined in wcs.h
37 
38 namespace lsst {
39 namespace daf {
40 namespace base {
41 class PropertySet;
42 }
43 }
44 namespace afw {
45 namespace formatters {
46 class TanWcsFormatter;
47 }
48 namespace image {
49 
69 public:
71  static void decodeSipHeader(daf::base::PropertySet const &fitsMetadata, std::string const &which,
72  Eigen::MatrixXd &m);
73 
85  TanWcs(geom::Point2D const &crval, geom::Point2D const &crpix, Eigen::Matrix2d const &cd,
86  double equinox = 2000, std::string const &raDecSys = "FK5", std::string const &cunits1 = "deg",
87  std::string const &cunits2 = "deg");
88 
104  TanWcs(geom::Point2D const &crval, geom::Point2D const &crpix, Eigen::Matrix2d const &cd,
105  Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB, Eigen::MatrixXd const &sipAp,
106  Eigen::MatrixXd const &sipBp, double equinox = 2000, std::string const &raDecSys = "FK5",
107  std::string const &cunits1 = "deg", std::string const &cunits2 = "deg");
108 
109  virtual ~TanWcs() = default;
110 
112  std::shared_ptr<Wcs> clone() const override;
113 
115  geom::Angle pixelScale() const;
116 
118  // NOTE that this accepts and returns FITS-style 1-indexed pixel coords, NOT LSST style 0-indexed
119  geom::Point2D distortPixel(geom::Point2D const &pixel) const;
120 
122  // NOTE that this accepts and returns FITS-style 1-indexed pixel coords, NOT LSST style 0-indexed
123  geom::Point2D undistortPixel(geom::Point2D const &pixel) const;
124 
125  bool hasDistortion() const override { return _hasDistortion; };
126 
127  void flipImage(int flipLR, int flipTB, lsst::afw::geom::Extent2I dimensions) const override;
128 
129  void rotateImageBy90(int nQuarter, lsst::afw::geom::Extent2I dimensions) const override;
130 
131  std::shared_ptr<daf::base::PropertyList> getFitsMetadata() const override;
132 
145  void setDistortionMatrices(Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB,
146  Eigen::MatrixXd const &sipAp, Eigen::MatrixXd const &sipBp);
147 
149  Eigen::MatrixXd const &getSipA() const { return _sipA; }
150 
152  Eigen::MatrixXd const &getSipB() const { return _sipB; }
153 
155  Eigen::MatrixXd const &getSipAp() const { return _sipAp; }
156 
158  Eigen::MatrixXd const &getSipBp() const { return _sipBp; }
159 
161  bool isPersistable() const override;
162 
163  TanWcs &operator=(const TanWcs &) = delete;
164  TanWcs &operator=(TanWcs &&) = delete;
165 
166 protected:
167  TanWcs(TanWcs const &rhs);
168  TanWcs(TanWcs &&rhs);
169 
170  void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const override;
171  geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const override;
172 
173 private:
175 
176  friend class TanWcsFactory;
177 
178  std::string getPersistenceName() const override;
179 
180  void write(OutputArchiveHandle &handle) const override;
181 
182  bool _isSubset(Wcs const &) const override;
183 
184  // Create an empty, invalid TanWcs. Only used by TanWcsFormatter.
185  TanWcs();
186 
187  /*
188  * Create a Wcs from a fits header.
189  *
190  * Don't call this directly. Use makeWcs() instead, which will figure out which (if any)
191  * sub-class of Wcs is appropriate.
192  */
194 
196 
197  // Allow the formatter to access private goo
199 
200  bool _hasDistortion;
201  Eigen::MatrixXd _sipA, _sipB, _sipAp, _sipBp;
202 };
203 }
204 }
205 } // namespace lsst::afw::image
206 
207 #endif
Interface for Persistable base class.
Eigen::MatrixXd const & getSipBp() const
Return the SIP reverse distortion matrix for y pixel coordinates.
Definition: TanWcs.h:158
std::shared_ptr< ImageT > flipImage(ImageT const &inImage, bool flipLR, bool flipTB)
Flip an image left–right and/or top–bottom.
Definition: rotateImage.cc:92
An object passed to Persistable::write to allow it to persist itself.
std::shared_ptr< Wcs > makeWcs(std::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
Create a Wcs object from a fits header.
Definition: makeWcs.cc:37
table::PointKey< double > crval
Definition: Wcs.cc:934
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:104
Eigen::MatrixXd const & getSipA() const
Return the SIP forward distortion matrix for the 1st intermediate world coordinate system axis...
Definition: TanWcs.h:149
STL class.
Eigen::MatrixXd const & getSipB() const
Return the SIP forward distortion matrix for the 2st intermediate world coordinate system axis...
Definition: TanWcs.h:152
bool hasDistortion() const override
Definition: TanWcs.h:125
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:44
A class representing an angle.
Definition: Angle.h:102
A base class for image defects.
Definition: cameraGeom.dox:3
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
table::Key< double > equinox
Definition: Wcs.cc:939
std::shared_ptr< ImageT > rotateImageBy90(ImageT const &image, int nQuarter)
Rotate an image by an integral number of quarter turns.
Definition: rotateImage.cc:39
Base class for all records.
Definition: BaseRecord.h:29
Class for storing generic metadata.
Definition: PropertySet.h:73
table::PointKey< int > pixel
table::Key< table::Array< double > > cd
Definition: Wcs.cc:936
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Definition: Persistable.h:98
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
Class implementing persistence and retrieval for TanWcs objects.
Eigen::MatrixXd const & getSipAp() const
Return the SIP reverse distortion matrix for x pixel coordinates.
Definition: TanWcs.h:155
table::PointKey< double > crpix
Definition: Wcs.cc:935