LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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 675 of file SdssShape.cc.

676  : _shapeResult(s),
677  _centroidResult(s),
678  _instFluxResult(s),
679  _instFlux_xx_Cov(s["instFlux"]["xx"]["Cov"]),
680  _instFlux_yy_Cov(s["instFlux"]["yy"]["Cov"]),
681  _instFlux_xy_Cov(s["instFlux"]["xy"]["Cov"]) {
682  // The input SubSchema may optionally provide for a PSF.
683  try {
684  _psfShapeResult = afw::table::QuadrupoleKey(s["psf"]);
685  _flagHandler = FlagHandler(s, SdssShapeAlgorithm::getFlagDefinitions());
686  _includePsf = true;
687  } catch (pex::exceptions::NotFoundError &e) {
688  _flagHandler =
690  _includePsf = false;
691  }
692 }
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 628 of file SdssShape.cc.

629  {
631  r._shapeResult =
632  ShapeResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments", SIGMA_ONLY);
633  r._centroidResult = CentroidResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments",
635  r._instFluxResult = FluxResultKey::addFields(schema, name, "elliptical Gaussian adaptive moments");
636 
637  // Only include PSF shape fields if doMeasurePsf = True
638  if (doMeasurePsf) {
639  r._includePsf = true;
640  r._psfShapeResult = afw::table::QuadrupoleKey::addFields(
641  schema, schema.join(name, "psf"), "adaptive moments of the PSF model at the object position");
642  } else {
643  r._includePsf = false;
644  }
645 
646  r._instFlux_xx_Cov =
647  schema.addField<ErrElement>(schema.join(name, "instFlux", "xx", "Cov"),
648  (boost::format("uncertainty covariance between %s and %s") %
649  schema.join(name, "instFlux") % schema.join(name, "xx"))
650  .str(),
651  "count*pixel^2");
652  r._instFlux_yy_Cov =
653  schema.addField<ErrElement>(schema.join(name, "instFlux", "yy", "Cov"),
654  (boost::format("uncertainty covariance between %s and %s") %
655  schema.join(name, "instFlux") % schema.join(name, "yy"))
656  .str(),
657  "count*pixel^2");
658  r._instFlux_xy_Cov =
659  schema.addField<ErrElement>(schema.join(name, "instFlux", "xy", "Cov"),
660  (boost::format("uncertainty covariance between %s and %s") %
661  schema.join(name, "instFlux") % schema.join(name, "xy"))
662  .str(),
663  "count*pixel^2");
664 
665  // Skip the psf flag if not recording the PSF shape.
666  if (r._includePsf) {
668  } else {
671  }
672  return r;
673 }
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 694 of file SdssShape.cc.

694  {
695  SdssShapeResult result;
696  static_cast<ShapeResult &>(result) = record.get(_shapeResult);
697  static_cast<CentroidResult &>(result) = record.get(_centroidResult);
698  static_cast<FluxResult &>(result) = record.get(_instFluxResult);
699  result.instFlux_xx_Cov = record.get(_instFlux_xx_Cov);
700  result.instFlux_yy_Cov = record.get(_instFlux_yy_Cov);
701  result.instFlux_xy_Cov = record.get(_instFlux_xy_Cov);
702  for (size_t n = 0; n < SdssShapeAlgorithm::N_FLAGS; ++n) {
703  if (n == SdssShapeAlgorithm::PSF_SHAPE_BAD.number && !_includePsf) continue;
704  result.flags[n] = _flagHandler.getValue(record, n);
705  }
706  return result;
707 }
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 709 of file SdssShape.cc.

709  {
710  return record.get(_psfShapeResult);
711 }

◆ isValid()

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

Return True if the key is valid.

Definition at line 739 of file SdssShape.cc.

739  {
740  return _shapeResult.isValid() && _centroidResult.isValid() && _instFluxResult.isValid() &&
741  _psfShapeResult.isValid() && _instFlux_xx_Cov.isValid() && _instFlux_yy_Cov.isValid() &&
742  _instFlux_xy_Cov.isValid();
743  // don't bother with flags - if we've gotten this far, it's basically impossible the flags are invalid
744 }
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 731 of file SdssShape.cc.

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

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

713  {
714  record.set(_shapeResult, value);
715  record.set(_centroidResult, value);
716  record.set(_instFluxResult, value);
717  record.set(_instFlux_xx_Cov, value.instFlux_xx_Cov);
718  record.set(_instFlux_yy_Cov, value.instFlux_yy_Cov);
719  record.set(_instFlux_xy_Cov, value.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  _flagHandler.setValue(record, n, value.flags[n]);
723  }
724 }
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 726 of file SdssShape.cc.

727  {
728  record.set(_psfShapeResult, value);
729 }

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