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 Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::meas::base::BaseTransform Class Referenceabstract

#include <Transform.h>

Inheritance diagram for lsst::meas::base::BaseTransform:
lsst::meas::base::ApertureFluxTransform lsst::meas::base::CentroidTransform lsst::meas::base::FluxTransform lsst::meas::base::SdssShapeTransform lsst::meas::base::GaussianCentroidTransform lsst::meas::base::NaiveCentroidTransform lsst::meas::base::SdssCentroidTransform lsst::meas::base::GaussianFluxTransform lsst::meas::base::PeakLikelihoodFluxTransform lsst::meas::base::PsfFluxTransform

Public Member Functions

 BaseTransform (std::string const &name)
 
virtual ~BaseTransform ()
 
virtual void operator() (afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const =0
 

Protected Member Functions

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

Protected Attributes

std::string _name
 

Detailed Description

Abstract base class for all C++ measurement transformations

Measurement plugins return results in raw, uncalibrated units (eg fluxes or positions in pixels). The transformation system provides a mechanism for post-processing those results into a calibrated form (magnitudes, celestial coordinates, etc).

A measurement transformation should derive from BaseTransform. It should implement a constructor which takes three arguments:

The constructor should use the SchemaMapper to map fields from the input to output schemas and add additional keys to the output as required. For example:

class SillyTransform :
{
public:
typedef SillyCentroidControl Control;
SillyTransform(Control const & ctrl, std::string const & name, lsst::afw::table::SchemaMapper & mapper)
: BaseTransform(name), _ctrl(ctrl) {
// Map these fields from the input to the output
lsst::afw::table::Key<double> xkey = mapper.getInputSchema()[name + "_x"];
lsst::afw::table::Key<double> ykey = mapper.getInputSchema()[name + "_y"];
mapper.addMapping(xkey);
mapper.addMapping(ykey);
// Add these fields to the output schema to fill in later; the keys
// are stored as members of this class
_key_revX = mapper.editOutputSchema().addField<double>(name + "_reverse_x", "reversed X");
_key_revY = mapper.editOutputSchema().addField<double>(name + "_reverse_y", "reversed Y");
}

Derived classes should also implement operator() following the interface below. This will be called with a catalog containing the results of the measurement plugin and a catalog to be populated with transformed quantities, as well as WCS and calibration information. For example:

virtual void operator()(lsst::afw::table::SourceCatalog const & inputCatalog,
lsst::afw::image::Calib const & calib) const {
checkCatalogSize(inputCatalog, outputCatalog);
lsst::afw::table::Key<double> xkey = inputCatalog.getSchema()[_name + "_x"];
lsst::afw::table::Key<double> ykey = inputCatalog.getSchema()[_name + "_y"];
for (; inSrc < inputCatalog.end() && outSrc < outputCatalog.end(); ++inSrc, ++outSrc) {
// Store the "reversed" versions of the x and y positions in the
// output catalog.
outSrc->set(_key_revX, -1.0 * inSrc->get(xkey));
outSrc->set(_key_revY, -1.0 * inSrc->get(ykey));
}
} // operator()

Note that it is safe to assume that both catalogs passed to operator() are contiguous in memory. It is good practice to ensure that they are equal in size: this may be conveniently achieved by calling BaseTransform::checkCatalogSize().

operator() may throw LengthError if the transformation is impossible to complete. In this case, the contents of outputCatalog is not guaranteed.

Definition at line 82 of file Transform.h.

Constructor & Destructor Documentation

lsst::meas::base::BaseTransform::BaseTransform ( std::string const &  name)
inlineexplicit

Definition at line 85 of file Transform.h.

85 : _name(name) {}
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual lsst::meas::base::BaseTransform::~BaseTransform ( )
inlinevirtual

Definition at line 86 of file Transform.h.

86 {}

Member Function Documentation

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

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 101 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,...)
Definition: Exception.h:46
virtual void lsst::meas::base::BaseTransform::operator() ( afw::table::SourceCatalog const &  inputCatalog,
afw::table::BaseCatalog outputCatalog,
afw::image::Wcs const &  wcs,
afw::image::Calib const &  calib 
) const
pure virtual

Member Data Documentation

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

Definition at line 107 of file Transform.h.


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