lsst.meas.astrom  14.0-7-g0d69b06+3
ScaledPolynomialTransformFitter.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2016 LSST/AURA
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 #ifndef LSST_MEAS_ASTROM_TanSipFitter_INCLUDED
25 #define LSST_MEAS_ASTROM_TanSipFitter_INCLUDED
26 
27 #include "lsst/pex/config.h"
29 #include "lsst/afw/geom/SkyWcs.h"
30 #include "lsst/afw/table/Catalog.h"
34 
35 namespace lsst { namespace meas { namespace astrom {
36 
37 
44 public:
45 
47  nSigma(3), nClipMin(1), nClipMax(5)
48  {}
49 
50  LSST_CONTROL_FIELD(nSigma, double, "Number of sigma to clip at.");
51 
52  LSST_CONTROL_FIELD(nClipMin, int, "Always clip at least this many matches.");
53 
54  LSST_CONTROL_FIELD(nClipMax, int, "Never clip more than this many matches.");
55 
56 };
57 
58 
105 public:
106 
141  static ScaledPolynomialTransformFitter fromMatches(
142  int maxOrder,
143  afw::table::ReferenceMatchVector const & matches,
144  afw::geom::SkyWcs const & initialWcs,
145  double intrinsicScatter
146  );
147 
176  static ScaledPolynomialTransformFitter fromGrid(
177  int maxOrder,
178  afw::geom::Box2D const & bbox,
179  int nGridX, int nGridY,
180  ScaledPolynomialTransform const & toInvert
181  );
182 
195  void fit(int order=-1);
196 
204  void updateModel();
205 
218  double updateIntrinsicScatter();
219 
229  double getIntrinsicScatter() const { return _intrinsicScatter; }
230 
249  std::pair<double,size_t> rejectOutliers(OutlierRejectionControl const & ctrl);
250 
259  afw::table::BaseCatalog const & getData() const { return _data; }
260 
270  ScaledPolynomialTransform const & getTransform() const { return _transform; }
271 
275  PolynomialTransform const & getPoly() const { return _transform.getPoly(); }
276 
280  afw::geom::AffineTransform const & getInputScaling() const { return _transform.getInputScaling(); }
281 
285  afw::geom::AffineTransform const & getOutputScaling() const { return _outputScaling; }
286 
287 private:
288 
289  class Keys;
290 
292  afw::table::BaseCatalog const & data,
293  Keys const & keys,
294  int maxOrder,
295  double intrinsicScatter,
296  afw::geom::AffineTransform const & inputScaling,
297  afw::geom::AffineTransform const & outputScaling
298  );
299 
300  double computeIntrinsicScatter() const;
301 
302  // Normally it's not safe to use a reference as a data member because the
303  // class holding it can't control when the referenced object gets
304  // destroyed, but this points to one of two singletons (which never get
305  // destroyed).
306  Keys const & _keys;
307  double _intrinsicScatter;
309  afw::geom::AffineTransform _outputScaling;
310  ScaledPolynomialTransform _transform;
311  // 2-d generalization of the Vandermonde matrix: evaluates polynomial at
312  // all data points when multiplied by a vector of packed polynomial
313  // coefficients.
314  Eigen::MatrixXd _vandermonde;
315 };
316 
317 }}} // namespace lsst::meas::astrom
318 
319 #endif // !LSST_MEAS_ASTROM_TanSipFitter_INCLUDEDtr
ScaledPolynomialTransform const & getTransform() const
Return the best-fit transform.
int nClipMax
"Never clip more than this many matches." ;
int nClipMin
"Always clip at least this many matches." ;
double getIntrinsicScatter() const
Return the current estimate of the intrinsic scatter.
A fitter class for scaled polynomial transforms.
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
afw::geom::AffineTransform const & getOutputScaling() const
Return the output scaling transform that maps output data points to [-1, 1].
afw::table::BaseCatalog const & getData() const
Return a catalog of data points and model values for diagnostic purposes.
A 2-d coordinate transform represented by a lazy composition of an AffineTransform, a PolynomialTransform, and another AffineTransform.
table::Box2IKey bbox
PolynomialTransform const & getPoly() const
Return the polynomial part of the best-fit transform.
Control object for outlier rejection in ScaledPolynomialTransformFitter.
afw::geom::AffineTransform const & getInputScaling() const
Return the input scaling transform that maps input data points to [-1, 1].
A 2-d coordinate transform represented by a pair of standard polynomials (one for each coordinate)...