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
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::meas.astrom.sip::MatchSrcToCatalogue Class Reference

#include <MatchSrcToCatalogue.h>

Public Types

typedef boost::shared_ptr
< MatchSrcToCatalogue
Ptr
 
typedef boost::shared_ptr
< MatchSrcToCatalogue const > 
ConstPtr
 

Public Member Functions

 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. More...
 
void setDist (afw::geom::Angle dist)
 Set a new value for the maximum allowed distance between two matching objects (in ra/dec space) More...
 
void setWcs (boost::shared_ptr< afw::image::Wcs const > wcs)
 Set a different Wcs solution. More...
 
void setCatSrcSet (afw::table::SimpleCatalog const &catSet)
 
void setImgSrcSet (afw::table::SourceCatalog const &srcSet)
 sourceSet is a vector of pointers to Sources. More...
 
void findMatches ()
 
afw::table::ReferenceMatchVector getMatches ()
 

Private Member Functions

void _removeOneToMany ()
 
void _removeManyToOne ()
 

Private Attributes

afw::table::SimpleCatalog _catSet
 Copy of input catalog. More...
 
afw::table::SourceCatalog _imgSet
 Copy of input catalog. More...
 
afw::table::ReferenceMatchVector _match
 
boost::shared_ptr
< lsst::afw::image::Wcs const > 
_wcs
 List of tuples of matching indices. More...
 
lsst::afw::geom::Angle _dist
 How close must two objects be to match. More...
 

Detailed Description

Match a SourceSet of objects with known ra/dec with a SourceSet of objects with known xy positions Take a catalogue of objects with known positions, a catalogue of objects with known xy, and a wcs to convert one xy <–> ra/dec. This class then finds the set of objects with common ra/dec.

The simplest usage is to create an object of this class, then access the corresponence sets with getMatchedImgSet() and getMatchedCatSet(). Creating the object automatically calculates the sets of corresponences for you. If you are unhappy with these matches, you can change one or more of your input arguments and redo the match with findMatches()

Using this class has the side effect of updating the coord field of the input SourceCatalog (which may be desirable).

Definition at line 58 of file MatchSrcToCatalogue.h.

Member Typedef Documentation

Definition at line 62 of file MatchSrcToCatalogue.h.

Definition at line 61 of file MatchSrcToCatalogue.h.

Constructor & Destructor Documentation

lsst::meas.astrom.sip::MatchSrcToCatalogue::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.

Take a catSet, i.e a SimpleCatalog giving the true positions of objects in ra/dec space, and an imageSet, i.e. a SourceCatalog of the pixel positions of sources detected on a CCD image. Use the Wcs to calculate the ra/dec of the image source, and then find the subset of objects withcommon positions in the two sets. The returned list of matches is one-to-one, i.e no object in the catalogue is matched twice, and no object in the imageSet is matched twice.

Parameters
catSetList of catalogue positions with known ra and dec
imgSetList of image positions with known x and y
wcsA Wcs object to convert from xy to radec
distHow close to objects need to be in order to be considered the same

Definition at line 45 of file MatchSrcToCatalogue.cc.

49 {
50  setImgSrcSet(imgSet);
51  setCatSrcSet(catSet);
52  setDist(dist);
53  setWcs(wcs);
54 }
tbl::Key< int > wcs
void setWcs(boost::shared_ptr< afw::image::Wcs const > wcs)
Set a different Wcs solution.
void setDist(afw::geom::Angle dist)
Set a new value for the maximum allowed distance between two matching objects (in ra/dec space) ...
void setImgSrcSet(afw::table::SourceCatalog const &srcSet)
sourceSet is a vector of pointers to Sources.
void setCatSrcSet(afw::table::SimpleCatalog const &catSet)

Member Function Documentation

void lsst::meas.astrom.sip::MatchSrcToCatalogue::_removeManyToOne ( )
private

This function is identical to _removeOneToMany() except first is replaced with second for the match structures

Definition at line 125 of file MatchSrcToCatalogue.cc.

125  {
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 }
afw::table::ReferenceMatchVector _match
void lsst::meas.astrom.sip::MatchSrcToCatalogue::_removeOneToMany ( )
private

We require that out matches be one to one, i.e any element matches no more than once for either the catalogue or the image. However, our implementation of findMatches uses afw::table::matchRaDec() which does not garauntee that. This function does the (slow) search and removal.

Definition at line 100 of file MatchSrcToCatalogue.cc.

100  {
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 }
afw::table::ReferenceMatchVector _match
void lsst::meas.astrom.sip::MatchSrcToCatalogue::findMatches ( )

Definition at line 78 of file MatchSrcToCatalogue.cc.

78  {
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 }
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
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > matchRaDec(Cat1 const &cat1, Cat2 const &cat2, Angle radius, bool closest=true)
boost::shared_ptr< lsst::afw::image::Wcs const > _wcs
List of tuples of matching indices.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Base::const_iterator const_iterator
Definition: SortedCatalog.h:49
boost::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:111
afw::table::SourceCatalog _imgSet
Copy of input catalog.
afw::table::ReferenceMatchVector lsst::meas.astrom.sip::MatchSrcToCatalogue::getMatches ( )

Definition at line 148 of file MatchSrcToCatalogue.cc.

148  {
149  findMatches();
150  return _match;
151 }
afw::table::ReferenceMatchVector _match
void lsst::meas.astrom.sip::MatchSrcToCatalogue::setCatSrcSet ( afw::table::SimpleCatalog const &  catSet)

Definition at line 74 of file MatchSrcToCatalogue.cc.

74  {
75  _catSet = srcSet;
76 }
afw::table::SimpleCatalog _catSet
Copy of input catalog.
void lsst::meas.astrom.sip::MatchSrcToCatalogue::setDist ( afw::geom::Angle  dist)

Set a new value for the maximum allowed distance between two matching objects (in ra/dec space)

Definition at line 57 of file MatchSrcToCatalogue.cc.

57  {
58  if (dist <= 0) {
59  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Distance must be > 0");
60  }
61  _dist = dist;
62 }
lsst::afw::geom::Angle _dist
How close must two objects be to match.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::meas.astrom.sip::MatchSrcToCatalogue::setImgSrcSet ( afw::table::SourceCatalog const &  srcSet)

sourceSet is a vector of pointers to Sources.

Definition at line 70 of file MatchSrcToCatalogue.cc.

70  {
71  _imgSet = srcSet;
72 }
afw::table::SourceCatalog _imgSet
Copy of input catalog.
void lsst::meas.astrom.sip::MatchSrcToCatalogue::setWcs ( boost::shared_ptr< afw::image::Wcs const >  wcs)

Set a different Wcs solution.

Definition at line 65 of file MatchSrcToCatalogue.cc.

65  {
66  _wcs = wcs;
67 }
tbl::Key< int > wcs
boost::shared_ptr< lsst::afw::image::Wcs const > _wcs
List of tuples of matching indices.

Member Data Documentation

afw::table::SimpleCatalog lsst::meas.astrom.sip::MatchSrcToCatalogue::_catSet
private

Copy of input catalog.

Definition at line 83 of file MatchSrcToCatalogue.h.

lsst::afw::geom::Angle lsst::meas.astrom.sip::MatchSrcToCatalogue::_dist
private

How close must two objects be to match.

Definition at line 87 of file MatchSrcToCatalogue.h.

afw::table::SourceCatalog lsst::meas.astrom.sip::MatchSrcToCatalogue::_imgSet
private

Copy of input catalog.

Definition at line 84 of file MatchSrcToCatalogue.h.

afw::table::ReferenceMatchVector lsst::meas.astrom.sip::MatchSrcToCatalogue::_match
private

Definition at line 85 of file MatchSrcToCatalogue.h.

boost::shared_ptr< lsst::afw::image::Wcs const> lsst::meas.astrom.sip::MatchSrcToCatalogue::_wcs
private

List of tuples of matching indices.

Definition at line 86 of file MatchSrcToCatalogue.h.


The documentation for this class was generated from the following files: