LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::meas::base::SdssShapeTransform Class Reference

Transformation for SdssShape measurements. More...

#include <SdssShape.h>

Inheritance diagram for lsst::meas::base::SdssShapeTransform:
lsst::meas::base::BaseTransform

Public Types

typedef SdssShapeControl Control
 

Public Member Functions

 SdssShapeTransform (Control const &ctrl, 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. More...
 

Protected Attributes

std::string _name
 

Detailed Description

Transformation for SdssShape measurements.

SdssShape measures not just shape but also instFlux and centroid. This transform operates on the first directly, and delegates to the Flux and Centroid transforms for the other two.

Definition at line 250 of file SdssShape.h.

Member Typedef Documentation

◆ Control

Definition at line 252 of file SdssShape.h.

Constructor & Destructor Documentation

◆ SdssShapeTransform()

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

Definition at line 934 of file SdssShape.cc.

936  : BaseTransform{name}, _instFluxTransform{name, mapper}, _centroidTransform{name, mapper} {
937  // If the input schema has a PSF flag -- it's optional -- assume we are also transforming the PSF.
938  _transformPsf = mapper.getInputSchema().getNames().count("sdssShape_flag_psf") ? true : false;
939 
940  // Skip the last flag if not transforming the PSF shape.
941  for (std::size_t i = 0; i < SdssShapeAlgorithm::getFlagDefinitions().size(); i++) {
942  FlagDefinition const &flag = SdssShapeAlgorithm::getFlagDefinitions()[i];
943  if (flag == SdssShapeAlgorithm::FAILURE) continue;
944  if (mapper.getInputSchema().getNames().count(mapper.getInputSchema().join(name, flag.name)) == 0)
945  continue;
946  afw::table::Key<afw::table::Flag> key =
947  mapper.getInputSchema().find<afw::table::Flag>(name + "_" + flag.name).key;
948  mapper.addMapping(key);
949  }
950 
951  _outShapeKey = ShapeResultKey::addFields(mapper.editOutputSchema(), name, "Shape in celestial moments",
953  if (_transformPsf) {
954  _outPsfShapeKey = afw::table::QuadrupoleKey::addFields(mapper.editOutputSchema(), name + "_psf",
955  "PSF shape in celestial moments",
957  }
958 }

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  }

◆ operator()()

void lsst::meas::base::SdssShapeTransform::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 960 of file SdssShape.cc.

962  {
963  // The instFlux and cetroid transforms will check that the catalog lengths
964  // match and throw if not, so we don't repeat the test here.
965  _instFluxTransform(inputCatalog, outputCatalog, wcs, photoCalib);
966  _centroidTransform(inputCatalog, outputCatalog, wcs, photoCalib);
967 
968  CentroidResultKey centroidKey(inputCatalog.getSchema()[_name]);
969  ShapeResultKey inShapeKey(inputCatalog.getSchema()[_name]);
970  afw::table::QuadrupoleKey inPsfShapeKey;
971  if (_transformPsf) {
972  inPsfShapeKey = afw::table::QuadrupoleKey(
973  inputCatalog.getSchema()[inputCatalog.getSchema().join(_name, "psf")]);
974  }
975 
976  afw::table::SourceCatalog::const_iterator inSrc = inputCatalog.begin();
977  afw::table::BaseCatalog::iterator outSrc = outputCatalog.begin();
978  for (; inSrc != inputCatalog.end(); ++inSrc, ++outSrc) {
979  ShapeResult inShape = inShapeKey.get(*inSrc);
980  ShapeResult outShape;
981 
982  // The transformation from the (x, y) to the (Ra, Dec) basis.
983  geom::AffineTransform crdTr =
984  wcs.linearizePixelToSky(centroidKey.get(*inSrc).getCentroid(), geom::radians);
985  outShape.setShape(inShape.getShape().transform(crdTr.getLinear()));
986 
987  // Transformation matrix from pixel to celestial basis.
989  outShape.setShapeErr((m * inShape.getShapeErr().cast<double>() * m.transpose()).cast<ErrElement>());
990 
991  _outShapeKey.set(*outSrc, outShape);
992 
993  if (_transformPsf) {
994  _outPsfShapeKey.set(*outSrc, inPsfShapeKey.get(*inSrc).transform(crdTr.getLinear()));
995  }
996  }
997 }

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:
lsst::meas::base::FULL_COVARIANCE
@ FULL_COVARIANCE
The full covariance matrix is provided.
Definition: constants.h:46
lsst::afw::table::CoordinateType::CELESTIAL
@ CELESTIAL
lsst::afw::table::QuadrupoleKey::set
void set(BaseRecord &record, geom::ellipses::Quadrupole const &value) const override
Set a Quadrupole in the given record.
Definition: aggregates.cc:114
wcs
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::meas::base::ShapeTrMatrix
Eigen::Matrix< ShapeElement, 3, 3, Eigen::DontAlign > ShapeTrMatrix
Definition: constants.h:62
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
lsst::meas::base::BaseTransform::_name
std::string _name
Definition: Transform.h:107
lsst::afw::table::QuadrupoleKey::addFields
static QuadrupoleKey addFields(Schema &schema, std::string const &name, std::string const &doc, CoordinateType coordType=CoordinateType::PIXEL)
Add a set of quadrupole subfields to a schema and return a QuadrupoleKey that points to them.
Definition: aggregates.cc:100
lsst::meas::base::ShapeResultKey::addFields
static ShapeResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc, UncertaintyEnum uncertainty, afw::table::CoordinateType coordType=afw::table::CoordinateType::PIXEL)
Add the appropriate fields to a Schema, and return a ShapeResultKey that manages them.
Definition: ShapeUtilities.cc:74
lsst::geom::AffineTransform::getLinear
LinearTransform const & getLinear() const noexcept
Definition: AffineTransform.h:155
lsst::afw::table::CatalogT< BaseRecord >::iterator
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110
lsst::meas::base::SdssShapeAlgorithm::getFlagDefinitions
static FlagDefinitionList const & getFlagDefinitions()
Definition: SdssShape.cc:58
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::meas::base::FlagDefinitionList::size
std::size_t size() const
return the current size (number of defined elements) of the collection
Definition: FlagHandler.h:125
photoCalib
Key< int > photoCalib
Definition: Exposure.cc:67
lsst::meas::base::makeShapeTransformMatrix
ShapeTrMatrix makeShapeTransformMatrix(geom::LinearTransform const &xform)
Construct a matrix suitable for transforming second moments.
Definition: ShapeUtilities.cc:143
lsst::meas::base::ErrElement
float ErrElement
Definition: constants.h:55
key
Key< U > key
Definition: Schema.cc:281
lsst::meas::base::SdssShapeAlgorithm::FAILURE
static FlagDefinition const FAILURE
Definition: SdssShape.h:155
mapper
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
lsst::geom::radians
constexpr AngleUnit radians
constant with units of radians
Definition: Angle.h:108
std::size_t
lsst::meas::base::BaseTransform::BaseTransform
BaseTransform(std::string const &name)
Definition: Transform.h:88
lsst::meas::base::ShapeResultKey::set
virtual void set(afw::table::BaseRecord &record, ShapeResult const &value) const
Set a ShapeResult in the given record.
Definition: ShapeUtilities.cc:136
m
int m
Definition: SpanSet.cc:49