LSSTApplications  20.0.0
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::meas::base::SdssShapeResultKey Class Referenceabstract

A FunctorKey that maps SdssShapeResult to afw::table Records. More...

#include <SdssShape.h>

Inheritance diagram for lsst::meas::base::SdssShapeResultKey:
lsst::afw::table::FunctorKey< SdssShapeResult > lsst::afw::table::OutputFunctorKey< SdssShapeResult > lsst::afw::table::InputFunctorKey< SdssShapeResult >

Public Types

using Value = SdssShapeResult
 The data type for get and set. More...
 

Public Member Functions

 SdssShapeResultKey ()
 Default constructor; instance will not be usuable unless subsequently assigned to. More...
 
 SdssShapeResultKey (afw::table::SubSchema const &s)
 Construct from a subschema, assuming _xx, _yy, etc. More...
 
virtual SdssShapeResult get (afw::table::BaseRecord const &record) const
 Get an SdssShapeResult from the given record. More...
 
virtual void set (afw::table::BaseRecord &record, SdssShapeResult const &value) const
 Set an SdssShapeResult in the given record. More...
 
virtual afw::geom::ellipses::Quadrupole getPsfShape (afw::table::BaseRecord const &record) const
 Get a Quadrupole for the Psf from the given record. More...
 
virtual void setPsfShape (afw::table::BaseRecord &record, afw::geom::ellipses::Quadrupole const &value) const
 Set a Quadrupole for the Psf at the position of the given record. More...
 
bool operator== (SdssShapeResultKey const &other) const
 Compare the FunctorKey for equality with another, using the underlying Keys. More...
 
bool operator!= (SdssShapeResultKey const &other) const
 
bool isValid () const
 Return True if the key is valid. More...
 
FlagHandler const & getFlagHandler () const
 
virtual void set (BaseRecord &record, SdssShapeResult const &value) const=0
 

Static Public Member Functions

static SdssShapeResultKey addFields (afw::table::Schema &schema, std::string const &name, bool doMeasurePsf)
 Add the appropriate fields to a Schema, and return a SdssShapeResultKey that manages them. More...
 

Detailed Description

A FunctorKey that maps SdssShapeResult to afw::table Records.

This is used internally by SdssShapeAlgorithm to transfer results from SdssShapeResult to SourceRecord, but it can also be used in the other direction by codes that need to extra an SdssShapeResult from a record.

Definition at line 73 of file SdssShape.h.

Member Typedef Documentation

◆ Value

The data type for get and set.

Definition at line 77 of file FunctorKey.h.

Constructor & Destructor Documentation

◆ SdssShapeResultKey() [1/2]

lsst::meas::base::SdssShapeResultKey::SdssShapeResultKey ( )
inline

Default constructor; instance will not be usuable unless subsequently assigned to.

Definition at line 90 of file SdssShape.h.

90 {}

◆ SdssShapeResultKey() [2/2]

lsst::meas::base::SdssShapeResultKey::SdssShapeResultKey ( afw::table::SubSchema const &  s)

Construct from a subschema, assuming _xx, _yy, etc.

subfields

If a schema has "a_xx", "a_yy", etc. fields, this constructor allows you to construct a SdssShapeResultKey via:

Definition at line 693 of file SdssShape.cc.

694  : _shapeResult(s),
695  _centroidResult(s),
696  _instFluxResult(s),
697  _instFlux_xx_Cov(s["instFlux"]["xx"]["Cov"]),
698  _instFlux_yy_Cov(s["instFlux"]["yy"]["Cov"]),
699  _instFlux_xy_Cov(s["instFlux"]["xy"]["Cov"]) {
700  // The input SubSchema may optionally provide for a PSF.
701  try {
702  _psfShapeResult = afw::table::QuadrupoleKey(s["psf"]);
703  _flagHandler = FlagHandler(s, SdssShapeAlgorithm::getFlagDefinitions());
704  _includePsf = true;
705  } catch (pex::exceptions::NotFoundError &e) {
706  _flagHandler =
708  _includePsf = false;
709  }
710 }

Member Function Documentation

◆ addFields()

SdssShapeResultKey lsst::meas::base::SdssShapeResultKey::addFields ( afw::table::Schema schema,
std::string const &  name,
bool  doMeasurePsf 
)
static

Add the appropriate fields to a Schema, and return a SdssShapeResultKey that manages them.

Parameters
[in,out]schemaSchema to add fields to.
[in]nameName prefix for all fields; "_xx", "_yy", etc. will be appended to this to form the full field names.
[in]numFlagsInteger to accommodate not setting the Psf shape fields when doMeasurePsf is false.
[in]doMeasurePsfBoolean indicating whether or not the Psf is being measured (as set in the SdssShapeControl class).

Definition at line 646 of file SdssShape.cc.

647  {
649  r._shapeResult =
650  ShapeResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments", SIGMA_ONLY);
651  r._centroidResult = CentroidResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments",
653  r._instFluxResult = FluxResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments");
654 
655  // Only include PSF shape fields if doMeasurePsf = True
656  if (doMeasurePsf) {
657  r._includePsf = true;
658  r._psfShapeResult = afw::table::QuadrupoleKey::addFields(
659  schema, schema.join(name, "psf"), "adaptive moments of the PSF model at the object position");
660  } else {
661  r._includePsf = false;
662  }
663 
664  r._instFlux_xx_Cov =
665  schema.addField<ErrElement>(schema.join(name, "instFlux", "xx", "Cov"),
666  (boost::format("uncertainty covariance between %s and %s") %
667  schema.join(name, "instFlux") % schema.join(name, "xx"))
668  .str(),
669  "count*pixel^2");
670  r._instFlux_yy_Cov =
671  schema.addField<ErrElement>(schema.join(name, "instFlux", "yy", "Cov"),
672  (boost::format("uncertainty covariance between %s and %s") %
673  schema.join(name, "instFlux") % schema.join(name, "yy"))
674  .str(),
675  "count*pixel^2");
676  r._instFlux_xy_Cov =
677  schema.addField<ErrElement>(schema.join(name, "instFlux", "xy", "Cov"),
678  (boost::format("uncertainty covariance between %s and %s") %
679  schema.join(name, "instFlux") % schema.join(name, "xy"))
680  .str(),
681  "count*pixel^2");
682 
683  // Skip the psf flag if not recording the PSF shape.
684  if (r._includePsf) {
686  } else {
689  }
690  return r;
691 }

◆ get()

SdssShapeResult lsst::meas::base::SdssShapeResultKey::get ( afw::table::BaseRecord const &  record) const
virtual

Get an SdssShapeResult from the given record.

Implements lsst::afw::table::OutputFunctorKey< SdssShapeResult >.

Definition at line 712 of file SdssShape.cc.

712  {
713  SdssShapeResult result;
714  static_cast<ShapeResult &>(result) = record.get(_shapeResult);
715  static_cast<CentroidResult &>(result) = record.get(_centroidResult);
716  static_cast<FluxResult &>(result) = record.get(_instFluxResult);
717  result.instFlux_xx_Cov = record.get(_instFlux_xx_Cov);
718  result.instFlux_yy_Cov = record.get(_instFlux_yy_Cov);
719  result.instFlux_xy_Cov = record.get(_instFlux_xy_Cov);
720  for (size_t n = 0; n < SdssShapeAlgorithm::N_FLAGS; ++n) {
721  if (n == SdssShapeAlgorithm::PSF_SHAPE_BAD.number && !_includePsf) continue;
722  result.flags[n] = _flagHandler.getValue(record, n);
723  }
724  return result;
725 }

◆ getFlagHandler()

FlagHandler const& lsst::meas::base::SdssShapeResultKey::getFlagHandler ( ) const
inline

Definition at line 125 of file SdssShape.h.

125 { return _flagHandler; }

◆ getPsfShape()

afw::geom::ellipses::Quadrupole lsst::meas::base::SdssShapeResultKey::getPsfShape ( afw::table::BaseRecord const &  record) const
virtual

Get a Quadrupole for the Psf from the given record.

Definition at line 727 of file SdssShape.cc.

727  {
728  return record.get(_psfShapeResult);
729 }

◆ isValid()

bool lsst::meas::base::SdssShapeResultKey::isValid ( ) const

Return True if the key is valid.

Definition at line 757 of file SdssShape.cc.

757  {
758  return _shapeResult.isValid() && _centroidResult.isValid() && _instFluxResult.isValid() &&
759  _psfShapeResult.isValid() && _instFlux_xx_Cov.isValid() && _instFlux_yy_Cov.isValid() &&
760  _instFlux_xy_Cov.isValid();
761  // don't bother with flags - if we've gotten this far, it's basically impossible the flags are invalid
762 }

◆ operator!=()

bool lsst::meas::base::SdssShapeResultKey::operator!= ( SdssShapeResultKey const &  other) const
inline

Definition at line 119 of file SdssShape.h.

119 { return !(*this == other); }

◆ operator==()

bool lsst::meas::base::SdssShapeResultKey::operator== ( SdssShapeResultKey const &  other) const

Compare the FunctorKey for equality with another, using the underlying Keys.

Definition at line 749 of file SdssShape.cc.

749  {
750  return _shapeResult == other._shapeResult && _centroidResult == other._centroidResult &&
751  _instFluxResult == other._instFluxResult && _psfShapeResult == other._psfShapeResult &&
752  _instFlux_xx_Cov == other._instFlux_xx_Cov && _instFlux_yy_Cov == other._instFlux_yy_Cov &&
753  _instFlux_xy_Cov == other._instFlux_xy_Cov;
754  // don't bother with flags - if we've gotten this far, it's basically impossible the flags don't match
755 }

◆ set() [1/2]

void lsst::meas::base::SdssShapeResultKey::set ( afw::table::BaseRecord record,
SdssShapeResult const &  value 
) const
virtual

Set an SdssShapeResult in the given record.

Definition at line 731 of file SdssShape.cc.

731  {
732  record.set(_shapeResult, value);
733  record.set(_centroidResult, value);
734  record.set(_instFluxResult, value);
735  record.set(_instFlux_xx_Cov, value.instFlux_xx_Cov);
736  record.set(_instFlux_yy_Cov, value.instFlux_yy_Cov);
737  record.set(_instFlux_xy_Cov, value.instFlux_xy_Cov);
738  for (size_t n = 0; n < SdssShapeAlgorithm::N_FLAGS; ++n) {
739  if (n == SdssShapeAlgorithm::PSF_SHAPE_BAD.number && !_includePsf) continue;
740  _flagHandler.setValue(record, n, value.flags[n]);
741  }
742 }

◆ set() [2/2]

virtual void lsst::afw::table::InputFunctorKey< SdssShapeResult >::set ( BaseRecord record,
SdssShapeResult const &  value 
) const
pure virtualinherited

◆ setPsfShape()

void lsst::meas::base::SdssShapeResultKey::setPsfShape ( afw::table::BaseRecord record,
afw::geom::ellipses::Quadrupole const &  value 
) const
virtual

Set a Quadrupole for the Psf at the position of the given record.

Definition at line 744 of file SdssShape.cc.

745  {
746  record.set(_psfShapeResult, value);
747 }

The documentation for this class was generated from the following files:
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::meas::base::NO_UNCERTAINTY
@ NO_UNCERTAINTY
Algorithm provides no uncertainy information at all.
Definition: constants.h:44
lsst::meas::base::SIGMA_ONLY
@ SIGMA_ONLY
Only the diagonal elements of the covariance matrix are provided.
Definition: constants.h:45
lsst::meas::base::FlagHandler::getValue
bool getValue(afw::table::BaseRecord const &record, std::size_t i) const
Return the value of the flag field corresponding to the given flag index.
Definition: FlagHandler.h:242
pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::meas::base::FluxResultKey::isValid
bool isValid() const
Return True if both the instFlux and instFluxErr Keys are valid.
Definition: FluxUtilities.h:111
lsst::meas::base::CentroidResultKey::addFields
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.
Definition: CentroidUtilities.cc:66
lsst::meas::base::FlagHandler::setValue
void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const
Set the flag field corresponding to the given flag index.
Definition: FlagHandler.h:262
lsst::meas::base::SdssShapeAlgorithm::N_FLAGS
static unsigned int const N_FLAGS
Definition: SdssShape.h:154
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
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::meas::base::SdssShapeResultKey::SdssShapeResultKey
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:90
lsst::afw::table::Key::isValid
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Definition: Key.h:97
lsst::meas::base::CentroidResultKey::isValid
bool isValid() const
Return True if the centroid key is valid.
Definition: CentroidUtilities.h:138
result
py::object result
Definition: _schema.cc:429
lsst::meas::base::SdssShapeAlgorithm::getFlagDefinitions
static FlagDefinitionList const & getFlagDefinitions()
Definition: SdssShape.cc:58
lsst::meas::base::SdssShapeAlgorithm::PSF_SHAPE_BAD
static FlagDefinition const PSF_SHAPE_BAD
Definition: SdssShape.h:160
lsst::meas::base::ErrElement
float ErrElement
Definition: constants.h:55
lsst::meas::base::FluxResultKey::addFields
static FluxResultKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
Add a pair of _instFlux, _instFluxErr fields to a Schema, and return a FluxResultKey that points to t...
Definition: FluxUtilities.cc:36
lsst::meas::base::ShapeResultKey::isValid
bool isValid() const
Return True if the shape key is valid.
Definition: ShapeUtilities.h:164
lsst::meas::base::FlagHandler::addFields
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList())
Add Flag fields to a schema, creating a FlagHandler object to manage them.
Definition: FlagHandler.cc:37
lsst::afw::table::QuadrupoleKey::isValid
bool isValid() const noexcept
Return True if all the constituent Keys are valid.
Definition: aggregates.h:342