LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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< T > lsst::afw::table::InputFunctorKey< T >

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, T 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:

table::Schema schema
Definition: python.h:134
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:90

Definition at line 673 of file SdssShape.cc.

674  : _shapeResult(s),
675  _centroidResult(s),
676  _instFluxResult(s),
677  _instFlux_xx_Cov(s["instFlux"]["xx"]["Cov"]),
678  _instFlux_yy_Cov(s["instFlux"]["yy"]["Cov"]),
679  _instFlux_xy_Cov(s["instFlux"]["xy"]["Cov"]) {
680  // The input SubSchema may optionally provide for a PSF.
681  try {
682  _psfShapeResult = afw::table::QuadrupoleKey(s["psf"]);
683  _flagHandler = FlagHandler(s, SdssShapeAlgorithm::getFlagDefinitions());
684  _includePsf = true;
685  } catch (pex::exceptions::NotFoundError &e) {
686  _flagHandler =
688  _includePsf = false;
689  }
690 }
static FlagDefinitionList const & getFlagDefinitions()
Definition: SdssShape.cc:58
static FlagDefinition const PSF_SHAPE_BAD
Definition: SdssShape.h:160

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 626 of file SdssShape.cc.

627  {
629  r._shapeResult =
630  ShapeResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments", SIGMA_ONLY);
631  r._centroidResult = CentroidResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments",
633  r._instFluxResult = FluxResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments");
634 
635  // Only include PSF shape fields if doMeasurePsf = True
636  if (doMeasurePsf) {
637  r._includePsf = true;
638  r._psfShapeResult = afw::table::QuadrupoleKey::addFields(
639  schema, schema.join(name, "psf"), "adaptive moments of the PSF model at the object position");
640  } else {
641  r._includePsf = false;
642  }
643 
644  r._instFlux_xx_Cov =
645  schema.addField<ErrElement>(schema.join(name, "instFlux", "xx", "Cov"),
646  (boost::format("uncertainty covariance between %s and %s") %
647  schema.join(name, "instFlux") % schema.join(name, "xx"))
648  .str(),
649  "count*pixel^2");
650  r._instFlux_yy_Cov =
651  schema.addField<ErrElement>(schema.join(name, "instFlux", "yy", "Cov"),
652  (boost::format("uncertainty covariance between %s and %s") %
653  schema.join(name, "instFlux") % schema.join(name, "yy"))
654  .str(),
655  "count*pixel^2");
656  r._instFlux_xy_Cov =
657  schema.addField<ErrElement>(schema.join(name, "instFlux", "xy", "Cov"),
658  (boost::format("uncertainty covariance between %s and %s") %
659  schema.join(name, "instFlux") % schema.join(name, "xy"))
660  .str(),
661  "count*pixel^2");
662 
663  // Skip the psf flag if not recording the PSF shape.
664  if (r._includePsf) {
666  } else {
669  }
670  return r;
671 }
table::Key< std::string > name
Definition: Amplifier.cc:116
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
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.
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
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...
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.
@ SIGMA_ONLY
Only the diagonal elements of the covariance matrix are provided.
Definition: constants.h:45
@ NO_UNCERTAINTY
Algorithm provides no uncertainy information at all.
Definition: constants.h:44
float ErrElement
Definition: constants.h:55
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ 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< T >.

Definition at line 692 of file SdssShape.cc.

692  {
693  SdssShapeResult result;
694  static_cast<ShapeResult &>(result) = record.get(_shapeResult);
695  static_cast<CentroidResult &>(result) = record.get(_centroidResult);
696  static_cast<FluxResult &>(result) = record.get(_instFluxResult);
697  result.instFlux_xx_Cov = record.get(_instFlux_xx_Cov);
698  result.instFlux_yy_Cov = record.get(_instFlux_yy_Cov);
699  result.instFlux_xy_Cov = record.get(_instFlux_xy_Cov);
700  for (size_t n = 0; n < SdssShapeAlgorithm::N_FLAGS; ++n) {
701  if (n == SdssShapeAlgorithm::PSF_SHAPE_BAD.number && !_includePsf) continue;
702  result.flags[n] = _flagHandler.getValue(record, n);
703  }
704  return result;
705 }
py::object result
Definition: _schema.cc:429
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
static unsigned int const N_FLAGS
Definition: SdssShape.h:154

◆ 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 707 of file SdssShape.cc.

707  {
708  return record.get(_psfShapeResult);
709 }

◆ isValid()

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

Return True if the key is valid.

Definition at line 737 of file SdssShape.cc.

737  {
738  return _shapeResult.isValid() && _centroidResult.isValid() && _instFluxResult.isValid() &&
739  _psfShapeResult.isValid() && _instFlux_xx_Cov.isValid() && _instFlux_yy_Cov.isValid() &&
740  _instFlux_xy_Cov.isValid();
741  // don't bother with flags - if we've gotten this far, it's basically impossible the flags are invalid
742 }
bool isValid() const noexcept
Return true if the key was initialized to valid offset.
Definition: Key.h:97
bool isValid() const noexcept
Return True if all the constituent Keys are valid.
Definition: aggregates.h:342
bool isValid() const
Return True if the centroid key is valid.
bool isValid() const
Return True if both the instFlux and instFluxErr Keys are valid.
bool isValid() const
Return True if the shape key is valid.

◆ 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 729 of file SdssShape.cc.

729  {
730  return _shapeResult == other._shapeResult && _centroidResult == other._centroidResult &&
731  _instFluxResult == other._instFluxResult && _psfShapeResult == other._psfShapeResult &&
732  _instFlux_xx_Cov == other._instFlux_xx_Cov && _instFlux_yy_Cov == other._instFlux_yy_Cov &&
733  _instFlux_xy_Cov == other._instFlux_xy_Cov;
734  // don't bother with flags - if we've gotten this far, it's basically impossible the flags don't match
735 }

◆ 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 711 of file SdssShape.cc.

711  {
712  record.set(_shapeResult, value);
713  record.set(_centroidResult, value);
714  record.set(_instFluxResult, value);
715  record.set(_instFlux_xx_Cov, value.instFlux_xx_Cov);
716  record.set(_instFlux_yy_Cov, value.instFlux_yy_Cov);
717  record.set(_instFlux_xy_Cov, value.instFlux_xy_Cov);
718  for (size_t n = 0; n < SdssShapeAlgorithm::N_FLAGS; ++n) {
719  if (n == SdssShapeAlgorithm::PSF_SHAPE_BAD.number && !_includePsf) continue;
720  _flagHandler.setValue(record, n, value.flags[n]);
721  }
722 }
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

◆ set() [2/2]

template<typename T >
virtual void lsst::afw::table::InputFunctorKey< T >::set ( BaseRecord record,
T 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 724 of file SdssShape.cc.

725  {
726  record.set(_psfShapeResult, value);
727 }

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