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
makeMatchStatistics.cc
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 
27 
28 namespace lsst {
29 namespace meas {
30 namespace astrom {
31 
32 template<typename MatchT>
34  std::vector<MatchT> const & matchList,
35  int const flags,
36  afw::math::StatisticsControl const & sctrl
37 ) {
38  if (matchList.empty()) {
39  throw LSST_EXCEPT(pexExcept::RuntimeError, "matchList is empty");
40  }
41  std::vector<double> val;
42  val.reserve(matchList.size());
43 
44  for (auto const & match: matchList) {
45  val.push_back(match.distance);
46  }
47  return afw::math::makeStatistics(val, flags, sctrl);
48 }
49 
50 template<typename MatchT>
52  afw::image::Wcs const & wcs,
53  std::vector<MatchT> const & matchList,
54  int const flags,
55  afw::math::StatisticsControl const & sctrl
56 ) {
57  if (matchList.empty()) {
58  throw LSST_EXCEPT(pexExcept::RuntimeError, "matchList is empty");
59  }
60  std::vector<double> val;
61  val.reserve(matchList.size());
62 
63  for (auto const & match: matchList) {
64  auto refPtr = match.first;
65  auto srcPtr = match.second;
66  auto srcX = srcPtr->getX();
67  auto srcY = srcPtr->getY();
68  auto refPos = wcs.skyToPixel(refPtr->getCoord());
69  auto refX = refPos[0];
70  auto refY = refPos[1];
71  val.push_back(::hypot(srcX - refX, srcY - refY));
72  }
73  return afw::math::makeStatistics(val, flags, sctrl);
74 }
75 
76 template<typename MatchT>
78  afw::image::Wcs const & wcs,
79  std::vector<MatchT> const & matchList,
80  int const flags,
81  afw::math::StatisticsControl const & sctrl
82 ) {
83  if (matchList.empty()) {
84  throw LSST_EXCEPT(pexExcept::RuntimeError, "matchList is empty");
85  }
86  std::vector<double> val;
87  val.reserve(matchList.size());
88 
89  for (auto const & match: matchList) {
90  auto refPtr = match.first;
91  auto srcPtr = match.second;
92  auto refCoord = refPtr->getCoord();
93  auto srcCoord = wcs.pixelToSky(srcPtr->getCentroid());
94  auto angSep = refCoord.angularSeparation(*srcCoord);
95  val.push_back(angSep.asRadians());
96  }
97  return afw::math::makeStatistics(val, flags, sctrl);
98 }
99 
100 #define INSTANTIATE(MATCH) \
101  template afw::math::Statistics makeMatchStatistics<MATCH>( \
102  std::vector<MATCH> const & matchList, \
103  int const flags, \
104  afw::math::StatisticsControl const & sctrl \
105  ); \
106  template afw::math::Statistics makeMatchStatisticsInPixels<MATCH>( \
107  afw::image::Wcs const & wcs, \
108  std::vector<MATCH> const & matchList, \
109  int const flags, \
110  afw::math::StatisticsControl const & sctrl \
111  ); \
112  template afw::math::Statistics makeMatchStatisticsInRadians<MATCH>( \
113  afw::image::Wcs const & wcs, \
114  std::vector<MATCH> const & matchList, \
115  int const flags, \
116  afw::math::StatisticsControl const & sctrl \
117  );
118 
121 
122 }}}
123 
124 
afw::math::Statistics makeMatchStatistics(std::vector< MatchT > const &matchList, int const flags, afw::math::StatisticsControl const &sctrl=afw::math::StatisticsControl())
geom::Point2D skyToPixel(geom::Angle sky1, geom::Angle sky2) const
Convert from sky coordinates (e.g. RA/dec) to pixel positions.
Definition: Wcs.cc:782
#define INSTANTIATE(MATCH)
tbl::Key< int > wcs
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
boost::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Convert from pixel position to sky coordinates (e.g. RA/dec)
Definition: Wcs.cc:858
bool val
Pass parameters to a Statistics objectA class to pass parameters which control how the stats are calc...
Definition: Statistics.h:92
Match< SimpleRecord, SourceRecord > ReferenceMatch
Definition: fwd.h:93
afw::math::Statistics makeMatchStatisticsInPixels(afw::image::Wcs const &wcs, std::vector< MatchT > const &matchList, int const flags, afw::math::StatisticsControl const &sctrl=afw::math::StatisticsControl())
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
afw::math::Statistics makeMatchStatisticsInRadians(afw::image::Wcs const &wcs, std::vector< MatchT > const &matchList, int const flags, afw::math::StatisticsControl const &sctrl=afw::math::StatisticsControl())
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082
Match< SourceRecord, SourceRecord > SourceMatch
Definition: fwd.h:94