25 #include "lsst/pex/exceptions/Runtime.h"
32 template<
typename MatchT>
34 std::vector<MatchT>
const & matchList,
36 afw::math::StatisticsControl
const & sctrl
38 if (matchList.empty()) {
39 throw LSST_EXCEPT(pexExcept::RuntimeError,
"matchList is empty");
41 std::vector<double> val;
42 val.reserve(matchList.size());
44 for (
auto const & match: matchList) {
45 val.push_back(match.distance);
47 return afw::math::makeStatistics(val, flags, sctrl);
50 template<
typename MatchT>
52 afw::image::Wcs
const & wcs,
53 std::vector<MatchT>
const & matchList,
55 afw::math::StatisticsControl
const & sctrl
57 if (matchList.empty()) {
58 throw LSST_EXCEPT(pexExcept::RuntimeError,
"matchList is empty");
60 std::vector<double> val;
61 val.reserve(matchList.size());
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));
73 return afw::math::makeStatistics(val, flags, sctrl);
76 template<
typename MatchT>
78 afw::image::Wcs
const & wcs,
79 std::vector<MatchT>
const & matchList,
81 afw::math::StatisticsControl
const & sctrl
83 if (matchList.empty()) {
84 throw LSST_EXCEPT(pexExcept::RuntimeError,
"matchList is empty");
86 std::vector<double> val;
87 val.reserve(matchList.size());
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());
97 return afw::math::makeStatistics(val, flags, sctrl);
100 #define INSTANTIATE(MATCH) \
101 template afw::math::Statistics makeMatchStatistics<MATCH>( \
102 std::vector<MATCH> const & matchList, \
104 afw::math::StatisticsControl const & sctrl \
106 template afw::math::Statistics makeMatchStatisticsInPixels<MATCH>( \
107 afw::image::Wcs const & wcs, \
108 std::vector<MATCH> const & matchList, \
110 afw::math::StatisticsControl const & sctrl \
112 template afw::math::Statistics makeMatchStatisticsInRadians<MATCH>( \
113 afw::image::Wcs const & wcs, \
114 std::vector<MATCH> const & matchList, \
116 afw::math::StatisticsControl const & sctrl \
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.
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())
Compute statistics of on-detector radial separation for a match list, in pixels.
#define INSTANTIATE(MATCH)
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())
Compute statistics of on-sky radial separation for a match list, in radians.