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
CreateWcsWithSip.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 
26 #ifndef CREATE_WCS_WITH_SIP
27 #define CREATE_WCS_WITH_SIP
28 
29 #include <vector>
30 
31 #include "boost/shared_ptr.hpp"
32 #include "lsst/base.h"
33 #include "Eigen/Core"
34 
35 #include "lsst/afw/table/Match.h"
36 #include "lsst/afw/geom/Box.h"
37 #include "lsst/afw/geom/Point.h"
38 #include "lsst/afw/geom/Angle.h"
39 #include "lsst/pex/logging/Log.h"
40 
41 namespace lsst {
42  namespace afw {
43  namespace image {
44  class Wcs;
45  class TanWcs;
46  }
47  }
48 
49 namespace meas {
50 namespace astrom {
51 namespace sip {
52 
53 
86 template<class MatchT>
88 public:
89 
90  typedef boost::shared_ptr<CreateWcsWithSip> Ptr;
91  typedef boost::shared_ptr<CreateWcsWithSip const> ConstPtr;
92 
94  std::vector<MatchT> const & matches,
95  afw::image::Wcs const & linearWcs,
96  int const order,
97  afw::geom::Box2I const& bbox = afw::geom::Box2I(),
98  int const ngrid=0
99  );
100 
102 
103  /*
104  Returns the median separation between points in this object's match list,
105  projecting reference sources from RA,Dec to pixels using the SIP WCS, and
106  comparing with the matched source pixel positions.
107  */
108  double getScatterInPixels();
109 
110  /*
111  Returns the median separation between points in this object's match list,
112  projecting sources from pixel space to RA,Dec using the SIP WCS, and
113  comparing with the reference source RA,Dec positions.
114  */
116 
117  /*
118  Returns the median separation between points in this object's match list,
119  projecting reference sources from RA,Dec to pixels using the input TAN
120  (linear) WCS, and comparing with the matched source pixel positions.
121  */
122  double getLinearScatterInPixels();
123 
124  /*
125  Returns the median separation between points in this object's match list,
126  projecting sources from pixel space to RA,Dec using the input TAN (linear)
127  WCS, and comparing with the reference source RA,Dec positions.
128  */
130 
132  int getOrder() const { return _sipA.rows(); }
134  int getNPoints() const { return _matches.size(); }
136  int getNGrid() const { return _ngrid; }
137 
138 private:
139 
141 
142  std::vector<MatchT> const _matches;
144  int _ngrid; // grid size to calculate inverse SIP coefficients (1-D)
146  // _sipOrder is polynomial order for forward transform.
147  // _reverseSipOrder is order for reverse transform, not necessarily the same.
149 
150  Eigen::MatrixXd _sipA, _sipB;
151  Eigen::MatrixXd _sipAp, _sipBp;
152 
153  PTR(afw::image::TanWcs) _newWcs;
154 
155  double _getScatterPixels(afw::image::Wcs const& wcs,
156  std::vector<MatchT> const & matches);
157  afw::geom::Angle _getScatterSky(afw::image::Wcs const& wcs,
158  std::vector<MatchT> const & matches);
159 
162 
163  afw::geom::Point2D _getCrvalAsGeomPoint();
164 };
165 
167 template<class MatchT>
169  std::vector<MatchT> const & matches,
170  afw::image::Wcs const& linearWcs,
171  int const order,
172  afw::geom::Box2I const& bbox = afw::geom::Box2I(),
173  int const ngrid=0
174 ) {
175  return CreateWcsWithSip<MatchT>(matches, linearWcs, order, bbox, ngrid);
176 }
177 
178 }}}}
179 
180 #endif
A coordinate class intended to represent absolute positions.
#define PTR(...)
Definition: base.h:41
int getOrder() const
Get the number of terms in the SIP matrix.
int getNPoints() const
Return the number of points in the catalogue.
#define CONST_PTR(...)
Definition: base.h:47
tbl::Key< int > wcs
boost::shared_ptr< afw::image::Wcs const > _linearWcs
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
a place to record messages and descriptions of the state of processing.
Definition: Log.h:154
int getNGrid() const
Return the number of grid points (on each axis) used in inverse SIP transform.
An integer coordinate rectangle.
Definition: Box.h:53
CreateWcsWithSip< MatchT > makeCreateWcsWithSip(std::vector< MatchT > const &matches, afw::image::Wcs const &linearWcs, int const order, afw::geom::Box2I const &bbox=afw::geom::Box2I(), int const ngrid=0)
Factory function for CreateWcsWithSip.
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
double _getScatterPixels(afw::image::Wcs const &wcs, std::vector< MatchT > const &matches)
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
CreateWcsWithSip(std::vector< MatchT > const &matches, afw::image::Wcs const &linearWcs, int const order, afw::geom::Box2I const &bbox=afw::geom::Box2I(), int const ngrid=0)
Constructor.
boost::shared_ptr< CreateWcsWithSip const > ConstPtr
boost::shared_ptr< CreateWcsWithSip > Ptr
boost::shared_ptr< afw::image::TanWcs > getNewWcs()
lsst::afw::geom::Angle Angle
Definition: misc.h:39
boost::shared_ptr< afw::image::TanWcs > _newWcs
Measure the distortions in an image plane and express them a SIP polynomials.
afw::geom::Angle _getScatterSky(afw::image::Wcs const &wcs, std::vector< MatchT > const &matches)
Point< double, 2 > Point2D
Definition: Point.h:286