67 os <<
"x=" << result.x <<
", y=" << result.y <<
", xErr=" << result.xErr <<
", yErr=" << result.yErr;
78 sigma[0] = schema.addField<
ErrElement>(schema.join(name,
"xErr"),
"1-sigma uncertainty on x position",
80 sigma[1] = schema.addField<
ErrElement>(schema.join(name,
"yErr"),
"1-sigma uncertainty on y position",
84 "uncertainty covariance in x and y",
"pixel^2"));
112 r.setCentroid(record.
get(_centroid));
113 if (_centroidErr.isValid()) {
114 r.setCentroidErr(record.
get(_centroidErr));
120 record.
set(_centroid, value.getCentroid());
121 if (_centroidErr.isValid()) {
122 record.
set(_centroidErr, value.getCentroidErr());
141 sigma[0] = s.addField<
ErrElement>(s.join(name,
"raErr"),
"1-sigma uncertainty on RA",
"rad");
142 sigma[1] = s.addField<
ErrElement>(s.join(name,
"decErr"),
"1-sigma uncertainty on dec",
"rad");
143 cov[0] = s.addField<
ErrElement>(s.join(name,
"ra_dec_Cov"),
"Uncertainty covariance in RA and dec",
158 for (; inSrc != inputCatalog.end() && outSrc != outputCatalog.
end(); ++inSrc, ++outSrc) {
161 _coordKey.set(*outSrc, wcs.pixelToSky(centroidResult.
getCentroid()));
169 _coordErrKey.set(*outSrc, (transform * centroidResult.
getCentroidErr().cast<
double>() *
170 transform.transpose())
180 double maxDistFromPeak)
181 : _doFootprintCheck(doFootprintCheck), _maxDistFromPeak(maxDistFromPeak) {
182 _resetKey = schema.addField<afw::table::Flag>(schema.join(name,
"flag_resetToPeak"),
183 "set if CentroidChecker reset the centroid");
184 _failureKey = schema.find<afw::table::Flag>(schema.join(name,
"flag")).key;
191 _xErrKey = schema.find<
ErrElement>(schema.join(name,
"xErr")).key;
195 _yErrKey = schema.find<
ErrElement>(schema.join(name,
"yErr")).key;
198 if (_xErrKey.isValid() || _yErrKey.isValid()) {
199 _badErrorKey = schema.addField<afw::table::Flag>(schema.join(name,
"flag_badError"),
200 "Error on x and/or y position is NaN");
209 if ((_xErrKey.isValid() &&
std::isnan(record.
get(_xErrKey))) ||
211 record.
set(_badErrorKey,
true);
212 record.
set(_failureKey,
true);
216 if (!_doFootprintCheck && _maxDistFromPeak < 0.0) {
225 if (footprint->getPeaks().empty()) {
233 double distsq = (x - footX) * (x - footX) + (y - footY) * (y - footY);
235 ((_maxDistFromPeak > 0) && (distsq > _maxDistFromPeak * _maxDistFromPeak))) {
236 record.
set(_xKey, footX);
237 record.
set(_yKey, footY);
238 record.
set(_failureKey,
true);
239 record.
set(_resetKey,
true);
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
The photometric calibration of an exposure.
Base class for all records.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
CatalogIterator< typename Internal::iterator > iterator
iterator begin()
Iterator access.
static CoordKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
Add a pair of _ra, _dec fields to a Schema, and return a CoordKey that points to them.
bool isValid() const noexcept
Return True if all the constituent error Keys are valid.
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a pair of _x, _y fields to a Schema, and return a PointKey that points to them.
Defines the fields and offsets for a table.
SchemaItem< T > find(std::string const &name) const
Find a SchemaItem in the Schema by name.
A mapping between the keys of two Schemas, used to copy data between them.
Key< T > addMapping(Key< T > const &inputKey, bool doReplace=false)
Add a new field to the output Schema that is a copy of a field in the input Schema.
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
Schema const getInputSchema() const
Return the input schema (copy-on-write).
typename Base::const_iterator const_iterator
Record class that contains measurements made on a single exposure.
std::shared_ptr< Footprint > getFootprint() const
A proxy type for name lookups in a Schema.
CentroidChecker(afw::table::Schema &schema, std::string const &name, bool inside=true, double maxDistFromPeak=-1.0)
Check source record produced by a centroid algorithm called "name".
bool operator()(afw::table::SourceRecord &record) const
Set the centroid to the first footprint if the centroid is either more than _dist pixels from the foo...
A FunctorKey for CentroidResult.
virtual void set(afw::table::BaseRecord &record, CentroidResult const &value) const
Set a CentroidResult in the given record.
afw::table::CovarianceMatrixKey< ErrElement, 2 > getCentroidErr() const
Return a FunctorKey to just the uncertainty matrix.
CentroidResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
virtual CentroidResult get(afw::table::BaseRecord const &record) const
Get a CentroidResult from the given record.
static CentroidResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty)
Add the appropriate fields to a Schema, and return a CentroidResultKey that manages them.
Reports attempts to access elements using an invalid key.
Reports errors that are due to events beyond the control of the program.
CatalogT< BaseRecord > BaseCatalog
AngleUnit constexpr radians
constant with units of radians
Point< double, 2 > Point2D
UncertaintyEnum
An enum used to specify how much uncertainty information measurement algorithms provide.
@ FULL_COVARIANCE
The full covariance matrix is provided.
@ NO_UNCERTAINTY
Algorithm provides no uncertainy information at all.
std::ostream & operator<<(std::ostream &os, CentroidResult const &result)
Eigen::Matrix< ErrElement, 2, 2, Eigen::DontAlign > CentroidCov
geom::Point< CentroidElement, 2 > Centroid
A reusable struct for centroid measurements.
CentroidElement y
y (row) coordinate of the measured position
Centroid const getCentroid() const
Return a Point object containing the measured x and y.
CentroidElement x
x (column) coordinate of the measured position
void setCentroidErr(CentroidCov const &matrix)
Set the struct uncertainty fields from the given matrix, with rows and columns ordered (x,...
CentroidCov const getCentroidErr() const
Return the 2x2 symmetric covariance matrix, with rows and columns ordered (x, y)
void setCentroid(Centroid const ¢roid)
Set the struct fields from the given Point object.
ErrElement yErr
standard deviation of y
CentroidResult()
Constructor; initializes everything to NaN.
ErrElement x_y_Cov
x,y term in the uncertainty convariance matrix
ErrElement xErr
standard deviation of x