lsst.meas.astrom
g91f025aaea+e2f0a7808d
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sip
MatchSrcToCatalogue.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
25
#include "
lsst/meas/astrom/sip/MatchSrcToCatalogue.h
"
26
#include "
lsst/geom/Angle.h
"
27
#include "
lsst/afw/geom/SkyWcs.h
"
28
29
namespace
lsst
{
30
namespace
meas
{
31
namespace
astrom
{
32
namespace
sip
{
33
49
MatchSrcToCatalogue::MatchSrcToCatalogue
(
afw::table::SimpleCatalog
const
& catSet,
50
afw::table::SourceCatalog
const
& imgSet,
51
std::shared_ptr<afw::geom::SkyWcs const>
wcs,
geom::Angle
dist) {
52
setImgSrcSet
(imgSet);
53
setCatSrcSet
(catSet);
54
setDist
(dist);
55
setWcs
(wcs);
56
}
57
59
void
MatchSrcToCatalogue::setDist
(
geom::Angle
dist) {
60
if
(dist <= 0) {
61
throw
LSST_EXCEPT
(
pex::exceptions::InvalidParameterError
,
"Distance must be > 0"
);
62
}
63
_dist = dist;
64
}
65
67
void
MatchSrcToCatalogue::setWcs
(
std::shared_ptr<afw::geom::SkyWcs const>
wcs) { _wcs = wcs; }
68
70
void
MatchSrcToCatalogue::setImgSrcSet
(
afw::table::SourceCatalog
const
& srcSet) { _imgSet = srcSet; }
71
72
void
MatchSrcToCatalogue::setCatSrcSet
(
afw::table::SimpleCatalog
const
& srcSet) { _catSet = srcSet; }
73
74
void
MatchSrcToCatalogue::findMatches
() {
75
if
(!_imgSet.getTable()->getCentroidSlot().isValid()) {
76
throw
LSST_EXCEPT
(
pex::exceptions::LogicError
,
77
"SourceTable passed to MatchSrcToCatalogue does not have its centroid slot set."
);
78
}
79
80
for
(
afw::table::SourceCatalog::const_iterator
i = _imgSet.begin(); i != _imgSet.end(); ++i) {
81
i->updateCoord(*_wcs);
82
}
83
84
_match =
afw::table::matchRaDec
(_catSet, _imgSet, _dist);
85
86
_removeOneToMany();
87
_removeManyToOne();
88
}
89
93
void
MatchSrcToCatalogue::_removeOneToMany() {
94
std::size_t
size = _match.
size
();
95
for
(
std::size_t
i = 0; i < size; ++i) {
96
for
(
std::size_t
j = i + 1; j < size; ++j) {
97
// If the same Source appears twice keep the one with the smaller separation from its match
98
if
(_match[i].first == _match[j].first) {
99
// Keep the one with the shorter match distance, and disgard the other
100
if
(_match[i].distance < _match[j].distance) {
101
_match.
erase
(_match.
begin
() + j);
102
size--;
103
j--;
104
}
else
{
105
_match.
erase
(_match.
begin
() + i);
106
size--;
107
i--;
108
break
;
109
}
110
}
111
}
112
}
113
}
114
117
void
MatchSrcToCatalogue::_removeManyToOne() {
118
std::size_t size = _match.size();
119
for
(std::size_t i = 0; i < size; ++i) {
120
for
(std::size_t j = i + 1; j < size; ++j) {
121
// If the same Source appears twice
122
if
(_match[i].second == _match[j].second) {
123
// Keep the one with the shorter match distance, and disgard the other
124
if
(_match[i].distance < _match[j].distance) {
125
_match.erase(_match.begin() + j);
126
size--;
127
j--;
128
}
else
{
129
_match.erase(_match.begin() + i);
130
size--;
131
i--;
132
break
;
133
}
134
}
135
}
136
}
137
}
138
139
afw::table::ReferenceMatchVector
MatchSrcToCatalogue::getMatches
() {
140
findMatches
();
141
return
_match;
142
}
143
144
}
// namespace sip
145
}
// namespace astrom
146
}
// namespace meas
147
}
// namespace lsst
Angle.h
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
MatchSrcToCatalogue.h
SkyWcs.h
std::vector::begin
T begin(T... args)
lsst::afw::table::SortedCatalogT< SourceRecord >::const_iterator
typename Base::const_iterator const_iterator
lsst::geom::Angle
lsst::meas::astrom::sip::MatchSrcToCatalogue::setWcs
void setWcs(std::shared_ptr< afw::geom::SkyWcs const > wcs)
Set a different Wcs solution.
Definition
MatchSrcToCatalogue.cc:67
lsst::meas::astrom::sip::MatchSrcToCatalogue::getMatches
afw::table::ReferenceMatchVector getMatches()
Definition
MatchSrcToCatalogue.cc:139
lsst::meas::astrom::sip::MatchSrcToCatalogue::setDist
void setDist(geom::Angle dist)
Set a new value for the maximum allowed distance between two matching objects (in ra/dec space).
Definition
MatchSrcToCatalogue.cc:59
lsst::meas::astrom::sip::MatchSrcToCatalogue::MatchSrcToCatalogue
MatchSrcToCatalogue(afw::table::SimpleCatalog const &catSet, afw::table::SourceCatalog const &imgSet, std::shared_ptr< afw::geom::SkyWcs const > wcs, geom::Angle dist)
Create a list of common objects from a catalogue and an image.
Definition
MatchSrcToCatalogue.cc:49
lsst::meas::astrom::sip::MatchSrcToCatalogue::findMatches
void findMatches()
Definition
MatchSrcToCatalogue.cc:74
lsst::meas::astrom::sip::MatchSrcToCatalogue::setCatSrcSet
void setCatSrcSet(afw::table::SimpleCatalog const &catSet)
Definition
MatchSrcToCatalogue.cc:72
lsst::meas::astrom::sip::MatchSrcToCatalogue::setImgSrcSet
void setImgSrcSet(afw::table::SourceCatalog const &srcSet)
sourceSet is a vector of pointers to Sources.
Definition
MatchSrcToCatalogue.cc:70
lsst::pex::exceptions::InvalidParameterError
lsst::pex::exceptions::LogicError
std::vector::erase
T erase(T... args)
lsst::afw::table::ReferenceMatchVector
std::vector< ReferenceMatch > ReferenceMatchVector
lsst::afw::table::SimpleCatalog
SortedCatalogT< SimpleRecord > SimpleCatalog
lsst::afw::table::SourceCatalog
SortedCatalogT< SourceRecord > SourceCatalog
lsst::afw::table::matchRaDec
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > matchRaDec(Cat1 const &cat1, Cat2 const &cat2, lsst::geom::Angle radius, MatchControl const &mc=MatchControl())
lsst::meas::astrom::sip
Definition
CreateWcsWithSip.h:41
lsst::meas::astrom
Definition
polynomialUtils.h:32
lsst::meas
Definition
polynomialUtils.h:31
lsst
std::shared_ptr
std::vector::size
T size(T... args)
std::size_t
Generated on
for lsst.meas.astrom by
1.17.0