LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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 
165  virtual bool isPersistable() const;
166 
167 protected:
168 
169  TanWcs(TanWcs const & rhs);
170 
171  virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const;
172  virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const;
173 
174 private:
175 
176  friend PTR(Wcs) makeWcs(PTR(daf::base::PropertySet) const& metadata, bool);
177 
178  friend class TanWcsFactory;
179 
180  virtual std::string getPersistenceName() const;
181 
182  virtual void write(OutputArchiveHandle & handle) const;
183 
184  virtual bool _isSubset(Wcs const &) const;
185 
186  // Create an empty, invalid TanWcs. Only used by TanWcsFormatter.
187  TanWcs();
188 
189  /*
190  * Create a Wcs from a fits header.
191  *
192  * Don't call this directly. Use makeWcs() instead, which will figure out which (if any)
193  * sub-class of Wcs is appropriate.
194  */
195  TanWcs(CONST_PTR(daf::base::PropertySet) const & fitsMetadata);
196 
197  TanWcs(afw::table::BaseRecord const & mainRecord, CONST_PTR(afw::table::BaseRecord) sipRecord);
198 
199  TanWcs & operator = (const TanWcs &);
200 
201  //Allow the formatter to access private goo
202  LSST_PERSIST_FORMATTER(lsst::afw::formatters::TanWcsFormatter)
203 
205  Eigen::MatrixXd _sipA, _sipB, _sipAp, _sipBp;
206 
207 };
208 
209 }}} // namespace lsst::afw::image
210 
211 #endif
friend class TanWcsFactory
Definition: TanWcs.h:178
virtual bool _isSubset(Wcs const &) const
A coordinate class intended to represent absolute positions.
lsst::afw::geom::Angle Angle
Definition: misc.h:39
table::Key< table::Array< double > > cd
Definition: Wcs.cc:1037
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:205
virtual bool isPersistable() const
Whether the object is persistable using afw::table::io archives.
table::PointKey< double > crval
Definition: Wcs.cc:1035
#define PTR(...)
Definition: base.h:41
Point< double, 2 > Point2D
Definition: Point.h:286
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
bool hasDistortion() const
Definition: TanWcs.h:140
virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const
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:1040
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 LSST_PERSIST_FORMATTER(formatter...)
Definition: Persistable.h:98
Eigen::MatrixXd _sipB
Definition: TanWcs.h:205
Interface for Persistable base class.
tuple m
Definition: lsstimport.py:48
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Eigen::MatrixXd _sipA
Definition: TanWcs.h:205
Class for storing generic metadata.
Definition: PropertySet.h:82
#define CONST_PTR(...)
Definition: base.h:47
table::PointKey< int > pixel
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:205
geom::Point2D distortPixel(geom::Point2D const &pixel) const
Applies the SIP AP and BP distortion (used in the skyToPixel direction)
table::PointKey< double > crpix
Definition: Wcs.cc:1036