LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
matchOptimisticB.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #if !defined(LSST_MEAS_ASTROM_MATCHOPTIMISTICB_H)
3 #define LSST_MEAS_ASTROM_MATCHOPTIMISTICB_H
4 
5 #include <cmath>
6 #include <string>
7 #include <vector>
8 
9 #include "lsst/pex/config.h"
10 #include "lsst/afw/table/Source.h"
11 #include "lsst/afw/table/Match.h"
12 
13 namespace lsst {
14 namespace meas {
15 namespace astrom {
16 
21  struct RecordProxy {
23  lsst::afw::geom::Point2D position;
24  mutable bool used; // set true if this star object has already been used for a match
25  // mutable to allow freezing the fundamental object data using const
26  // while keeping track of which objects have been used in each search
27 
28  double getX() const { return position.getX(); }
29  double getY() const { return position.getY(); }
30 
34  operator PTR(lsst::afw::table::SimpleRecord)() const { return record; }
35 
36  bool operator==(RecordProxy const & other) const { return record == other.record; }
37  bool operator!=(RecordProxy const & other) const { return record != other.record; }
38 
48  ) : record(record), position(position) {}
49 
50  explicit RecordProxy() {} // default constructor needed so we can call ProxyVector::resize()
51  };
52 
53  typedef std::vector<RecordProxy> ProxyVector;
54 
56  afw::image::Wcs const& distortedWcs,
57  afw::image::Wcs const& tanWcs
58  );
59 
61  afw::image::Wcs const& tanWcs
62  );
63 
64  struct ProxyPair {
67  double distance;
68  double pa;
69 
70  ProxyPair(RecordProxy const & s1, RecordProxy const & s2) : first(s1), second(s2) {
71  double x1 = first.position.getX();
72  double y1 = first.position.getY();
73  double x2 = second.position.getX();
74  double y2 = second.position.getY();
75  distance = std::hypot(x2-x1, y2-y1);
76  pa = std::atan2(y2-y1, x2-x1);
77  }
78  };
79 
81  LSST_CONTROL_FIELD(refFluxField, std::string, "name of flux field in reference catalog");
82  LSST_CONTROL_FIELD(sourceFluxField, std::string, "name of flux field in source catalog");
83  LSST_CONTROL_FIELD(numBrightStars, int, "maximum number of bright reference stars to use");
84  LSST_CONTROL_FIELD(minMatchedPairs, int, "minimum number of matches");
86  "maximum allowed distance between reference objects and sources (pixels)");
87  LSST_CONTROL_FIELD(maxOffsetPix, double, "maximum allowed frame translation (pixels)");
88  LSST_CONTROL_FIELD(maxRotationDeg, double, "maximum allowed frame rotation (deg)");
89  LSST_CONTROL_FIELD(allowedNonperpDeg, double, "allowed non-perpendicularity of x and y axes (deg)");
90  LSST_CONTROL_FIELD(numPointsForShape, int, "number of points in a matching shape");
92 
94  refFluxField("r_flux"),
95  sourceFluxField("slot_ApFlux_flux"),
96  numBrightStars(100),
97  minMatchedPairs(50),
99  maxOffsetPix(300),
100  maxRotationDeg(1.0),
101  allowedNonperpDeg(3.0),
103  maxDeterminant(0.02)
104  {
105  validate();
106  }
107 
108  void validate() const;
109 
111  };
112 
133  lsst::afw::table::SimpleCatalog const &posRefCat,
134  lsst::afw::table::SourceCatalog const &sourceCat,
135  MatchOptimisticBControl const &control,
136  afw::image::Wcs const& wcs,
137  int posRefBegInd=0,
138  bool verbose = false
139  );
140 
141 }}}
142 
143 #endif
double allowedNonperpDeg
&quot;allowed non-perpendicularity of x and y axes (deg)&quot; ;
bool operator!=(RecordProxy const &other) const
ProxyPair(RecordProxy const &s1, RecordProxy const &s2)
std::string sourceFluxField
&quot;name of flux field in source catalog&quot; ;
bool operator==(RecordProxy const &other) const
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
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ &quot;control object&quot; structs.
Definition: config.h:36
boost::shared_ptr< lsst::afw::table::SimpleRecord > record
double maxRotationDeg
&quot;maximum allowed frame rotation (deg)&quot; ;
lsst::afw::table::ReferenceMatchVector matchOptimisticB(lsst::afw::table::SimpleCatalog const &posRefCat, lsst::afw::table::SourceCatalog const &sourceCat, MatchOptimisticBControl const &control, afw::image::Wcs const &wcs, int posRefBegInd=0, bool verbose=false)
Match sources to stars in a position reference catalog using optimistic pattern matching B...
int numBrightStars
&quot;maximum number of bright reference stars to use&quot; ;
double maxOffsetPix
&quot;maximum allowed frame translation (pixels)&quot; ;
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
double matchingAllowancePix
&quot;maximum allowed distance between reference objects and sources (pixels)&quot; ;
int minMatchedPairs
&quot;minimum number of matches&quot; ;
std::string refFluxField
&quot;name of flux field in reference catalog&quot; ;
lsst::afw::geom::Point2D position
std::vector< RecordProxy > ProxyVector
A wrapper around a SimpleRecord or SourceRecord that allows us to record a pixel position in a way th...
#define PTR(...)
Definition: base.h:41
Point< double, 2 > Point2D
Definition: Point.h:288
ProxyVector makeProxies(lsst::afw::table::SourceCatalog const &sourceCat, afw::image::Wcs const &distortedWcs, afw::image::Wcs const &tanWcs)
Record class that must contain a unique ID field and a celestial coordinate field.
Definition: Simple.h:46
int numPointsForShape
&quot;number of points in a matching shape&quot; ;
RecordProxy(boost::shared_ptr< lsst::afw::table::SimpleRecord > record, lsst::afw::geom::Point2D const &position)
Construct a RecordProxy.