LSST Applications g042eb84c57+730a74494b,g04e9c324dd+8c5ae1fdc5,g134cb467dc+1f1e3e7524,g199a45376c+0ba108daf9,g1fd858c14a+fa7d31856b,g210f2d0738+f66ac109ec,g262e1987ae+83a3acc0e5,g29ae962dfc+d856a2cb1f,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+a1e0c9f713,g47891489e3+0d594cb711,g4d44eb3520+c57ec8f3ed,g4d7b6aa1c5+f66ac109ec,g53246c7159+8c5ae1fdc5,g56a1a4eaf3+fd7ad03fde,g64539dfbff+f66ac109ec,g67b6fd64d1+0d594cb711,g67fd3c3899+f66ac109ec,g6985122a63+0d594cb711,g74acd417e5+3098891321,g786e29fd12+668abc6043,g81db2e9a8d+98e2ab9f28,g87389fa792+8856018cbb,g89139ef638+0d594cb711,g8d7436a09f+80fda9ce03,g8ea07a8fe4+760ca7c3fc,g90f42f885a+033b1d468d,g97be763408+a8a29bda4b,g99822b682c+e3ec3c61f9,g9d5c6a246b+0d5dac0c3d,ga41d0fce20+9243b26dd2,gbf99507273+8c5ae1fdc5,gd7ef33dd92+0d594cb711,gdab6d2f7ff+3098891321,ge410e46f29+0d594cb711,geaed405ab2+c4bbc419c6,gf9a733ac38+8c5ae1fdc5,w.2025.38
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst::meas::base::CentroidTransform Class Reference

Base for centroid measurement transformations. More...

#include <CentroidUtilities.h>

Inheritance diagram for lsst::meas::base::CentroidTransform:
lsst::meas::base::BaseTransform lsst::meas::base::SdssCentroidTransform

Public Member Functions

 CentroidTransform (std::string const &name, afw::table::SchemaMapper &mapper)
 
virtual void operator() (afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::geom::SkyWcs const &wcs, afw::image::PhotoCalib const &photoCalib) const
 

Protected Member Functions

void checkCatalogSize (afw::table::BaseCatalog const &cat1, afw::table::BaseCatalog const &cat2) const
 Ensure that catalogs have the same size.
 

Protected Attributes

std::string _name
 

Detailed Description

Base for centroid measurement transformations.

Provides a basic transform from centroid plus associated uncertainty to celestial position with uncertainty. The basic "flag" attribute for the measurement algorithm is propagated to the output.

Subclasses should define a constructor which take a Control argument corresponding to the measurement algorithm being transformed and ensure that any other necessary flags are propagated.

Definition at line 170 of file CentroidUtilities.h.

Constructor & Destructor Documentation

◆ CentroidTransform()

lsst::meas::base::CentroidTransform::CentroidTransform ( std::string const & name,
afw::table::SchemaMapper & mapper )

Definition at line 126 of file CentroidUtilities.cc.

128 // Map the flag through to the output
129 mapper.addMapping(mapper.getInputSchema().find<afw::table::Flag>(name + "_flag").key);
130
131 // Add keys for the coordinates
132 auto &s = mapper.editOutputSchema();
133 _coordKey = afw::table::CoordKey::addFields(s, name, "ICRS coordinates");
134
135 // If the centroid has an error key we also include one on the celestial
136 // coordinates; otherwise, it isn't necessary. Note that if we provide for
137 // errors in celestial coordinates, we always need the full covariance.
138 if (CentroidResultKey(mapper.getInputSchema()[name]).getCentroidErr().isValid()) {
139 std::vector<afw::table::Key<ErrElement> > sigma(2);
140 std::vector<afw::table::Key<ErrElement> > cov(1);
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",
144 "rad^2");
145 _coordErrKey = afw::table::CovarianceMatrixKey<ErrElement, 2>(sigma, cov);
146 }
147}
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.
BaseTransform(std::string const &name)
Definition Transform.h:88

Member Function Documentation

◆ checkCatalogSize()

void lsst::meas::base::BaseTransform::checkCatalogSize ( afw::table::BaseCatalog const & cat1,
afw::table::BaseCatalog const & cat2 ) const
inlineprotectedinherited

Ensure that catalogs have the same size.

Parameters
[in]cat1Catalog for comparison
[in]cat2Catalog for comparison
Exceptions
LengthErrorCatalog sizes do not match

Definition at line 102 of file Transform.h.

102 {
103 if (cat1.size() != cat2.size()) {
104 throw LSST_EXCEPT(pex::exceptions::LengthError, "Catalog size mismatch");
105 }
106 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48

◆ operator()()

void lsst::meas::base::CentroidTransform::operator() ( afw::table::SourceCatalog const & inputCatalog,
afw::table::BaseCatalog & outputCatalog,
afw::geom::SkyWcs const & wcs,
afw::image::PhotoCalib const & photoCalib ) const
virtual

Implements lsst::meas::base::BaseTransform.

Definition at line 149 of file CentroidUtilities.cc.

151 {
152 checkCatalogSize(inputCatalog, outputCatalog);
153 CentroidResultKey centroidResultKey(inputCatalog.getSchema()[_name]);
154
155 afw::table::SourceCatalog::const_iterator inSrc = inputCatalog.begin();
156 afw::table::BaseCatalog::iterator outSrc = outputCatalog.begin();
157
158 for (; inSrc != inputCatalog.end() && outSrc != outputCatalog.end(); ++inSrc, ++outSrc) {
159 CentroidResult centroidResult = centroidResultKey.get(*inSrc);
160
161 _coordKey.set(*outSrc, wcs.pixelToSky(centroidResult.getCentroid()));
162
163 if (centroidResultKey.getCentroidErr().isValid()) {
164 CentroidCov centroidCov = centroidResult.getCentroidErr();
165 if (!(std::isnan(centroidCov(0, 0)) || std::isnan(centroidCov(1, 1)))) {
166 auto transform = wcs.linearizePixelToSky(centroidResult.getCentroid(), geom::radians)
167 .getLinear()
168 .getMatrix();
169 _coordErrKey.set(*outSrc, (transform * centroidResult.getCentroidErr().cast<double>() *
170 transform.transpose())
171 .cast<ErrElement>());
172 }
173 }
174 }
175}
CatalogIterator< typename Internal::iterator > iterator
Definition Catalog.h:110
typename Base::const_iterator const_iterator
void checkCatalogSize(afw::table::BaseCatalog const &cat1, afw::table::BaseCatalog const &cat2) const
Ensure that catalogs have the same size.
Definition Transform.h:102
T isnan(T... args)
AngleUnit constexpr radians
constant with units of radians
Definition Angle.h:109
Eigen::Matrix< ErrElement, 2, 2, Eigen::DontAlign > CentroidCov
Definition constants.h:59
T transform(T... args)

Member Data Documentation

◆ _name

std::string lsst::meas::base::BaseTransform::_name
protectedinherited

Definition at line 107 of file Transform.h.


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