LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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
virtual bool isPersistable() const
Whether the object is persistable using afw::table::io archives.
friend class TanWcsFactory
Definition: TanWcs.h:178
A coordinate class intended to represent absolute positions.
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< daf::base::PropertyList > getFitsMetadata() const
Return a PropertyList containing FITS header keywords that can be used to save the Wcs...
virtual geom::Point2D skyToPixelImpl(geom::Angle sky1, geom::Angle sky2) const
table::Key< table::Array< double > > cd
Definition: Wcs.cc:1037
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.
Eigen::MatrixXd _sipBp
Definition: TanWcs.h:205
An object passed to Persistable::write to allow it to persist itself.
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
#define CONST_PTR(...)
Definition: base.h:47
geom::Angle pixelScale() const
Returns the pixel scale, in Angle/pixel.
table::PointKey< double > crval
Definition: Wcs.cc:1035
geom::Point2D undistortPixel(geom::Point2D const &pixel) const
Applies the SIP A and B un-distortion (used in the pixelToSky direction)
Eigen::MatrixXd _sipB
Definition: TanWcs.h:205
virtual ~TanWcs()
Definition: TanWcs.h:124
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
std::map< Citizen const *, CitizenInfo > table
Definition: Citizen.h:93
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
virtual boost::shared_ptr< Wcs > clone() const
Polymorphic deep-copy.
table::Key< double > equinox
Definition: Wcs.cc:1040
bool hasDistortion() const
Definition: TanWcs.h:140
Support for 2-D images.
friend boost::shared_ptr< Wcs > makeWcs(boost::shared_ptr< daf::base::PropertySet > const &metadata, bool)
Interface for Persistable base class.
#define LSST_PERSIST_FORMATTER(formatter...)
Definition: Persistable.h:98
tuple m
Definition: lsstimport.py:48
virtual bool _isSubset(Wcs const &) const
lsst::afw::geom::Angle Angle
Definition: misc.h:39
Class for storing generic metadata.
Definition: PropertySet.h:82
boost::shared_ptr< lsst::afw::image::TanWcs const > ConstPtr
Definition: TanWcs.h:71
Eigen::MatrixXd _sipAp
Definition: TanWcs.h:205
Point< double, 2 > Point2D
Definition: Point.h:286
table::PointKey< int > pixel
Eigen::MatrixXd _sipA
Definition: TanWcs.h:205
geom::Point2D distortPixel(geom::Point2D const &pixel) const
Applies the SIP AP and BP distortion (used in the skyToPixel direction)
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.
boost::shared_ptr< lsst::afw::image::TanWcs > Ptr
Definition: TanWcs.h:70
virtual void pixelToSkyImpl(double pixel1, double pixel2, geom::Angle skyTmp[2]) const
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
table::PointKey< double > crpix
Definition: Wcs.cc:1036