LSSTApplications  11.0-24-g0a022a1,14.0+77,15.0,15.0+1
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  }
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::geom::SkyWcs 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  }
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::geom::SkyWcs 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  }
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::geom::SkyWcs 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::geom::SkyWcs 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())
Compute statistics of the distance field of a match list.
T empty(T... args)
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:114
#define INSTANTIATE(MATCH)
tbl::Key< int > wcs
A class to evaluate image statistics.
Definition: Statistics.h:215
T push_back(T... args)
Pass parameters to a Statistics object.
Definition: Statistics.h:93
A base class for image defects.
Definition: cameraGeom.dox:3
afw::math::Statistics makeMatchStatisticsInPixels(afw::geom::SkyWcs const &wcs, std::vector< MatchT > const &matchList, int const flags, afw::math::StatisticsControl const &sctrl=afw::math::StatisticsControl())
Compute statistics of on-detector radial separation for a match list, in pixels.
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition: Statistics.h:354
Match< SimpleRecord, SourceRecord > ReferenceMatch
Definition: fwd.h:104
lsst::afw::geom::Angle angularSeparation(Coord const &c) const
compute the angular separation between two Coords
Definition: Coord.cc:506
coord::IcrsCoord pixelToSky(Point2D const &pixel) const
Compute sky position(s) from pixel position(s)
Definition: SkyWcs.h:324
Point2D skyToPixel(coord::IcrsCoord const &sky) const
Compute pixel position(s) from sky position(s)
Definition: SkyWcs.h:335
T size(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
afw::math::Statistics makeMatchStatisticsInRadians(afw::geom::SkyWcs const &wcs, std::vector< MatchT > const &matchList, int const flags, afw::math::StatisticsControl const &sctrl=afw::math::StatisticsControl())
Compute statistics of on-sky radial separation for a match list, in radians.
Match< SourceRecord, SourceRecord > SourceMatch
Definition: fwd.h:105
ImageT val
Definition: CR.cc:158
T reserve(T... args)