LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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:
70  typedef boost::shared_ptr<lsst::afw::image::TanWcs> Ptr;
71  typedef boost::shared_ptr<lsst::afw::image::TanWcs const> ConstPtr;
72 
74  static void decodeSipHeader(
75  daf::base::PropertySet const & fitsMetadata,
76  std::string const & which,
77  Eigen::MatrixXd & m
78  );
79 
91  TanWcs(
92  geom::Point2D const & crval, geom::Point2D const & crpix,
93  Eigen::Matrix2d const & cd,
94  double equinox=2000, std::string const & raDecSys="FK5",
95  std::string const & cunits1="deg", std::string const & cunits2="deg"
96  );
97 
113  TanWcs(
114  geom::Point2D const & crval, geom::Point2D const & crpix,
115  Eigen::Matrix2d const & cd,
116  Eigen::MatrixXd const & sipA,
117  Eigen::MatrixXd const & sipB,
118  Eigen::MatrixXd const & sipAp,
119  Eigen::MatrixXd const & sipBp,
120  double equinox=2000, std::string const & raDecSys="FK5",
121  std::string const & cunits1="deg", std::string const & cunits2="deg"
122  );
123 
124  virtual ~TanWcs() {};
125 
127  virtual PTR(Wcs) clone() const;
128 
130  geom::Angle pixelScale() const;
131 
133  // NOTE that this accepts and returns FITS-style 1-indexed pixel coords, NOT LSST style 0-indexed
134  geom::Point2D distortPixel(geom::Point2D const & pixel) const;
135 
137  // NOTE that this accepts and returns FITS-style 1-indexed pixel coords, NOT LSST style 0-indexed
138  geom::Point2D undistortPixel(geom::Point2D const & pixel) const;
139 
140  bool hasDistortion() const { return _hasDistortion;};
141 
143 
144 
158  Eigen::MatrixXd const & sipA,
159  Eigen::MatrixXd const & sipB,
160  Eigen::MatrixXd const & sipAp,
161  Eigen::MatrixXd const & sipBp
162  );
163 
164 private:
165 
166  friend PTR(Wcs) makeWcs(PTR(daf::base::PropertySet) const& metadata, bool);
167 
168  friend class TanWcsFactory;
169 
170  virtual std::string getPersistenceName() const;
171 
172  virtual void write(OutputArchiveHandle & handle) const;
173 
174  virtual bool _isSubset(Wcs const &) const;
175 
176  // Create an empty, invalid TanWcs. Only used by TanWcsFormatter.
177  TanWcs();
178 
179  /*
180  * Create a Wcs from a fits header.
181  *
182  * Don't call this directly. Use makeWcs() instead, which will figure out which (if any)
183  * sub-class of Wcs is appropriate.
184  */
185  TanWcs(CONST_PTR(daf::base::PropertySet) const & fitsMetadata);
186 
187  TanWcs(TanWcs const & rhs);
188 
189  TanWcs(afw::table::BaseRecord const & mainRecord, CONST_PTR(afw::table::BaseRecord) sipRecord);
190 
191  TanWcs & operator = (const TanWcs &);
192 
193  virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const;
194  virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const;
195 
196  //Allow the formatter to access private goo
197  LSST_PERSIST_FORMATTER(lsst::afw::formatters::TanWcsFormatter)
198 
200  Eigen::MatrixXd _sipA, _sipB, _sipAp, _sipBp;
201 
202 };
203 
204 }}} // namespace lsst::afw::image
205 
206 #endif
friend class TanWcsFactory
Definition: TanWcs.h:168
virtual bool _isSubset(Wcs const &) const
A coordinate class intended to represent absolute positions.
#define PTR(...)
Definition: base.h:41
lsst::afw::geom::Angle Angle
Definition: misc.h:37
table::Key< table::Array< double > > cd
Definition: Wcs.cc:1087
An object passed to Persistable::write to allow it to persist itself.
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
Eigen::MatrixXd _sipAp
Definition: TanWcs.h:200
Point< double, 2 > Point2D
Definition: Point.h:277
static void decodeSipHeader(daf::base::PropertySet const &fitsMetadata, std::string const &which, Eigen::MatrixXd &m)
Decode the SIP headers for a given matrix, if present.
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
Interface for Persistable base class.
bool hasDistortion() const
Definition: TanWcs.h:140
virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const
#define LSST_PERSIST_FORMATTER(formatter...)
Definition: Persistable.h:98
table::Key< table::Point< double > > crval
Definition: Wcs.cc:1085
table::Key< table::Point< int > > pixel
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:93
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
boost::shared_ptr< daf::base::PropertyList > getFitsMetadata() const
Return a PropertyList containing FITS header keywords that can be used to save the Wcs...
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:1090
table::Key< table::Point< double > > crpix
Definition: Wcs.cc:1086
virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const
boost::shared_ptr< lsst::afw::image::TanWcs const > ConstPtr
Definition: TanWcs.h:71
geom::Point2D undistortPixel(geom::Point2D const &pixel) const
Applies the SIP A and B un-distortion (used in the pixelToSky direction)
Support for 2-D images.
friend boost::shared_ptr< Wcs > makeWcs(boost::shared_ptr< daf::base::PropertySet > const &metadata, bool)
#define CONST_PTR(...)
Definition: base.h:47
Eigen::MatrixXd _sipB
Definition: TanWcs.h:200
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Eigen::MatrixXd _sipA
Definition: TanWcs.h:200
Class for storing generic metadata.
Definition: PropertySet.h:82
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
boost::shared_ptr< lsst::afw::image::TanWcs > Ptr
Definition: TanWcs.h:70
geom::Angle pixelScale() const
Returns the pixel scale, in Angle/pixel.
virtual boost::shared_ptr< Wcs > clone() const
Polymorphic deep-copy.
A coordinate class intended to represent offsets and dimensions.
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:182
void setDistortionMatrices(Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB, Eigen::MatrixXd const &sipAp, Eigen::MatrixXd const &sipBp)
Set the distortion matrices.
Eigen::MatrixXd _sipBp
Definition: TanWcs.h:200
geom::Point2D distortPixel(geom::Point2D const &pixel) const
Applies the SIP AP and BP distortion (used in the skyToPixel direction)