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
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 
26 #include "lsst/afw/image/Wcs.h"
27 
28 namespace lsst { namespace meas { namespace astrom { namespace sip {
29 
46  afw::table::SourceCatalog const& imgSet,
48  afw::geom::Angle dist)
49 {
50  setImgSrcSet(imgSet);
51  setCatSrcSet(catSet);
52  setDist(dist);
53  setWcs(wcs);
54 }
55 
58  if (dist <= 0) {
59  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Distance must be > 0");
60  }
61  _dist = dist;
62 }
63 
66  _wcs = wcs;
67 }
68 
71  _imgSet = srcSet;
72 }
73 
75  _catSet = srcSet;
76 }
77 
79  if (!_imgSet.getTable()->hasCentroidSlot()) {
80  throw LSST_EXCEPT(
81  pex::exceptions::LogicError,
82  "SourceTable passed to MatchSrcToCatalogue does not have its centroid slot set."
83  );
84  }
85 
87  i->updateCoord(*_wcs);
88  }
89 
91 
94 }
95 
96 
101  std::size_t size = _match.size();
102  for (std::size_t i=0; i<size; ++i) {
103  for (std::size_t j=i+1; j<size; ++j) {
104  //If the same Source appears twice keep the one with the smaller separation from its match
105  if ( _match[i].first == _match[j].first ) {
106  //Keep the one with the shorter match distance, and disgard the other
107  if (_match[i].distance < _match[j].distance) {
108  _match.erase(_match.begin() + j);
109  size--;
110  j--;
111  } else {
112  _match.erase(_match.begin() + i);
113  size--;
114  i--;
115  break;
116  }
117  }
118  }
119  }
120 }
121 
122 
126  std::size_t size = _match.size();
127  for (std::size_t i=0; i<size; ++i) {
128  for (std::size_t j=i+1; j<size; ++j) {
129  //If the same Source appears twice
130  if (_match[i].second == _match[j].second) {
131  //Keep the one with the shorter match distance, and disgard the other
132  if (_match[i].distance < _match[j].distance) {
133  _match.erase(_match.begin() + j);
134  size--;
135  j--;
136  } else {
137  _match.erase(_match.begin() + i);
138  size--;
139  i--;
140  break;
141  }
142  }
143  }
144  }
145 }
146 
147 
149  findMatches();
150  return _match;
151 }
152 
153 }}}} // namespace lsst::meas::astrom::sip
afw::table::SimpleCatalog _catSet
Copy of input catalog.
lsst::afw::geom::Angle _dist
How close must two objects be to match.
afw::table::ReferenceMatchVector _match
tbl::Key< int > wcs
std::vector< ReferenceMatch > ReferenceMatchVector
Definition: fwd.h:97
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
void setWcs(boost::shared_ptr< afw::image::Wcs const > wcs)
Set a different Wcs solution.
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > matchRaDec(Cat1 const &cat1, Cat2 const &cat2, Angle radius, bool closest=true)
MatchSrcToCatalogue(afw::table::SimpleCatalog const &catSet, afw::table::SourceCatalog const &imgSet, boost::shared_ptr< afw::image::Wcs const > wcs, afw::geom::Angle dist)
Create a list of common objects from a catalogue and an image.
boost::shared_ptr< lsst::afw::image::Wcs const > _wcs
List of tuples of matching indices.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55
void setDist(afw::geom::Angle dist)
Set a new value for the maximum allowed distance between two matching objects (in ra/dec space) ...
afw::table::ReferenceMatchVector getMatches()
Iterator class for CatalogT.
Definition: Catalog.h:34
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void setImgSrcSet(afw::table::SourceCatalog const &srcSet)
sourceSet is a vector of pointers to Sources.
boost::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:111
#define CONST_PTR(...)
Definition: base.h:47
afw::table::SourceCatalog _imgSet
Copy of input catalog.
void setCatSrcSet(afw::table::SimpleCatalog const &catSet)