LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
SdssShape.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2016 AURA/LSST.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <https://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #ifndef LSST_MEAS_BASE_SdssShape_h_INCLUDED
25 #define LSST_MEAS_BASE_SdssShape_h_INCLUDED
26 
27 #include <bitset>
28 
29 #include "lsst/pex/config.h"
30 #include "lsst/afw/geom/SkyWcs.h"
40 
41 namespace lsst {
42 namespace meas {
43 namespace base {
44 
45 class SdssShapeResult;
46 
53 public:
54  LSST_CONTROL_FIELD(background, double, "Additional value to add to background");
55  LSST_CONTROL_FIELD(maxIter, int, "Maximum number of iterations");
56  LSST_CONTROL_FIELD(maxShift, double, "Maximum centroid shift, limited to 2-10");
57  LSST_CONTROL_FIELD(tol1, float, "Convergence tolerance for e1,e2");
58  LSST_CONTROL_FIELD(tol2, float, "Convergence tolerance for FWHM");
59  LSST_CONTROL_FIELD(doMeasurePsf, bool, "Whether to also compute the shape of the PSF model");
60 
63  : background(0.0), maxIter(100), maxShift(), tol1(1E-5), tol2(1E-4), doMeasurePsf(true) {}
64 };
65 
73 class SdssShapeResultKey : public afw::table::FunctorKey<SdssShapeResult> {
74 public:
87  bool doMeasurePsf);
88 
91 
102 
104  virtual SdssShapeResult get(afw::table::BaseRecord const& record) const;
105 
107  virtual void set(afw::table::BaseRecord& record, SdssShapeResult const& value) const;
108 
111 
113  virtual void setPsfShape(afw::table::BaseRecord& record,
114  afw::geom::ellipses::Quadrupole const& value) const;
115 
117  bool operator==(SdssShapeResultKey const& other) const;
119  bool operator!=(SdssShapeResultKey const& other) const { return !(*this == other); }
121 
123  bool isValid() const;
124 
125  FlagHandler const& getFlagHandler() const { return _flagHandler; }
126 
127 private:
128  bool _includePsf;
129  ShapeResultKey _shapeResult;
130  CentroidResultKey _centroidResult;
131  FluxResultKey _instFluxResult;
132  afw::table::QuadrupoleKey _psfShapeResult;
133  afw::table::Key<ErrElement> _instFlux_xx_Cov;
134  afw::table::Key<ErrElement> _instFlux_yy_Cov;
135  afw::table::Key<ErrElement> _instFlux_xy_Cov;
136  FlagHandler _flagHandler;
137 };
138 
151 public:
152  // Structures and routines to manage flaghandler
153  static FlagDefinitionList const& getFlagDefinitions();
154  static unsigned int const N_FLAGS = 6;
155  static FlagDefinition const FAILURE;
158  static FlagDefinition const SHIFT;
159  static FlagDefinition const MAXITER;
161 
165 
166  // NOTE: In order to accommodate the optional setting of additional fields when running with
167  // doMeasurePsf = true (do set extra fields) or false (do NOT set extra fields), all of
168  // the code in SdssShape assumes that PSF_SHAPE_BAD is the last entry in the enum list.
169  // If new flags are added, be sure to add them above the PSF_SHAPE_BAD entry.
170 
172 
183  template <typename ImageT>
184  static Result computeAdaptiveMoments(ImageT const& image, geom::Point2D const& position,
185  bool negative = false, Control const& ctrl = Control());
186 
196  template <typename ImageT>
197  static FluxResult computeFixedMomentsFlux(ImageT const& image,
198  afw::geom::ellipses::Quadrupole const& shape,
199  geom::Point2D const& position);
200 
201  virtual void measure(afw::table::SourceRecord& measRecord,
202  afw::image::Exposure<float> const& exposure) const;
203 
204  virtual void fail(afw::table::SourceRecord& measRecord, MeasurementError* error = nullptr) const;
205 
206 private:
207  Control _ctrl;
208  ResultKey _resultKey;
209  SafeCentroidExtractor _centroidExtractor;
210 };
211 
224 class SdssShapeResult : public ShapeResult, public CentroidResult, public FluxResult {
225 public:
229 
231 
233  // TODO is this workaround still needed?
234  bool getFlag(unsigned int index) const { return flags[index]; }
235 
236  bool getFlag(std::string const& name) const {
238  }
239 
240  SdssShapeResult();
241 };
242 
251 public:
253 
255 
256  /*
257  * @brief Perform transformation from inputCatalog to outputCatalog.
258  *
259  * @param[in] inputCatalog Source of data to be transformed
260  * @param[in,out] outputCatalog Container for transformed results
261  * @param[in] wcs World coordinate system under which transformation will take place
262  * @param[in] photoCalib Photometric calibration under which transformation will take place
263  * @throws LengthError Catalog sizes do not match
264  */
265  virtual void operator()(afw::table::SourceCatalog const& inputCatalog,
266  afw::table::BaseCatalog& outputCatalog, afw::geom::SkyWcs const& wcs,
267  afw::image::PhotoCalib const& photoCalib) const;
268 
269 private:
270  FluxTransform _instFluxTransform;
271  CentroidTransform _centroidTransform;
272  ShapeResultKey _outShapeKey;
273  afw::table::QuadrupoleKey _outPsfShapeKey;
274  bool _transformPsf;
275 };
276 
277 } // namespace base
278 } // namespace meas
279 } // namespace lsst
280 
281 #endif // !LSST_MEAS_BASE_SdssShape_h_INCLUDED
lsst::meas::base::SdssShapeResult::getFlag
bool getFlag(std::string const &name) const
Definition: SdssShape.h:236
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::meas::base::SdssShapeResult
Result object SdssShapeAlgorithm.
Definition: SdssShape.h:224
lsst::meas::base::SdssShapeResult::getFlag
bool getFlag(unsigned int index) const
Flag getter for Swig, which doesn't understand std::bitset.
Definition: SdssShape.h:234
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::meas::base::SimpleAlgorithm
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition: Algorithm.h:170
std::bitset< SdssShapeAlgorithm::N_FLAGS >
lsst::meas::base::FlagDefinition::number
std::size_t number
Definition: FlagHandler.h:54
std::string
STL class.
CentroidUtilities.h
lsst::meas::base::SdssShapeControl::tol2
float tol2
"Convergence tolerance for FWHM" ;
Definition: SdssShape.h:58
lsst::meas::base::FluxResult
A reusable result struct for instFlux measurements.
Definition: FluxUtilities.h:41
lsst::log.log.logContinued.error
def error(fmt, *args)
Definition: logContinued.py:213
lsst::meas::base::SdssShapeTransform::Control
SdssShapeControl Control
Definition: SdssShape.h:252
lsst::afw::table::SourceRecord
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
lsst::afw::image::Exposure< float >
wcs
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
lsst::afw::table::FunctorKey
Convenience base class that combines the OutputFunctorKey and InputFunctorKey.
Definition: FunctorKey.h:74
lsst::meas::base::SdssShapeResult::flags
std::bitset< SdssShapeAlgorithm::N_FLAGS > flags
Status flags (see SdssShapeAlgorithm).
Definition: SdssShape.h:230
lsst::meas::base::SdssShapeAlgorithm::Control
SdssShapeControl Control
Definition: SdssShape.h:162
lsst::meas::base::SdssShapeControl::maxIter
int maxIter
"Maximum number of iterations" ;
Definition: SdssShape.h:55
lsst::meas::base::SdssShapeAlgorithm
Measure the image moments of source using adaptive Gaussian weights.
Definition: SdssShape.h:150
FluxUtilities.h
Quadrupole.h
lsst::meas::base::SdssShapeResultKey::isValid
bool isValid() const
Return True if the key is valid.
Definition: SdssShape.cc:737
lsst::meas::base::SdssShapeTransform
Transformation for SdssShape measurements.
Definition: SdssShape.h:250
lsst::meas::base::MeasurementError
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
SkyWcs.h
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::meas::base::ShapeResultKey
A FunctorKey for ShapeResult.
Definition: ShapeUtilities.h:113
InputUtilities.h
lsst::meas::base::SafeCentroidExtractor
Utility class for measurement algorithms that extracts a position from the Centroid slot and handles ...
Definition: InputUtilities.h:39
lsst::afw::geom::SkyWcs
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:117
lsst::meas::base::CentroidResultKey
A FunctorKey for CentroidResult.
Definition: CentroidUtilities.h:88
lsst::meas::base::SdssShapeResultKey::operator==
bool operator==(SdssShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: SdssShape.cc:729
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
aggregates.h
lsst::meas::base::CentroidTransform
Base for centroid measurement transformations.
Definition: CentroidUtilities.h:168
lsst::meas::base::FluxResultKey
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:59
lsst::meas::base::SdssShapeResultKey::setPsfShape
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.
Definition: SdssShape.cc:724
lsst::meas::base::CentroidResult
A reusable struct for centroid measurements.
Definition: CentroidUtilities.h:41
lsst::meas::base::SdssShapeResult::instFlux_xx_Cov
ErrElement instFlux_xx_Cov
instFlux, xx term in the uncertainty covariance matrix
Definition: SdssShape.h:226
lsst::meas::base::SdssShapeResultKey::operator!=
bool operator!=(SdssShapeResultKey const &other) const
Definition: SdssShape.h:119
lsst::meas::base::FlagDefinitionList
vector-type utility class to build a collection of FlagDefinitions
Definition: FlagHandler.h:60
lsst::meas::base::SdssShapeAlgorithm::computeAdaptiveMoments
static Result computeAdaptiveMoments(ImageT const &image, geom::Point2D const &position, bool negative=false, Control const &ctrl=Control())
Compute the adaptive Gaussian-weighted moments of an image.
lsst::meas::base::SdssShapeAlgorithm::measure
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Called to measure a single child source in an image.
Definition: SdssShape.cc:869
lsst::meas::base::SdssShapeControl
A C++ control class to handle SdssShapeAlgorithm's configuration.
Definition: SdssShape.h:52
lsst::meas::base::SdssShapeAlgorithm::SHIFT
static FlagDefinition const SHIFT
Definition: SdssShape.h:158
lsst::meas::base::SdssShapeControl::tol1
float tol1
"Convergence tolerance for e1,e2" ;
Definition: SdssShape.h:57
lsst::meas::base::SdssShapeTransform::operator()
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::geom::SkyWcs const &wcs, afw::image::PhotoCalib const &photoCalib) const
Definition: SdssShape.cc:948
lsst::meas::base::SdssShapeAlgorithm::UNWEIGHTED_BAD
static FlagDefinition const UNWEIGHTED_BAD
Definition: SdssShape.h:156
lsst::meas::base::SdssShapeAlgorithm::N_FLAGS
static unsigned int const N_FLAGS
Definition: SdssShape.h:154
lsst::afw::table::QuadrupoleKey
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys.
Definition: aggregates.h:282
lsst::meas::base::FlagHandler
Utility class for handling flag fields that indicate the failure modes of an algorithm.
Definition: FlagHandler.h:148
lsst::afw::table._source.SourceCatalog
Definition: _source.py:32
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::BaseRecord
Base class for all records.
Definition: BaseRecord.h:31
lsst::afw::table::SchemaMapper
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
lsst::meas::base::SdssShapeResultKey::SdssShapeResultKey
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:90
lsst::meas::base::SdssShapeResultKey::set
virtual void set(afw::table::BaseRecord &record, SdssShapeResult const &value) const
Set an SdssShapeResult in the given record.
Definition: SdssShape.cc:711
lsst::afw::table::Key< ErrElement >
lsst::meas::base::FluxTransform
Base for instFlux measurement transformations.
Definition: FluxUtilities.h:187
lsst::meas::base::SdssShapeControl::doMeasurePsf
bool doMeasurePsf
"Whether to also compute the shape of the PSF model" ;
Definition: SdssShape.h:59
lsst::afw::image::PhotoCalib
The photometric calibration of an exposure.
Definition: PhotoCalib.h:114
LSST_CONTROL_FIELD
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition: config.h:43
Algorithm.h
lsst::meas::base::SdssShapeAlgorithm::UNWEIGHTED
static FlagDefinition const UNWEIGHTED
Definition: SdssShape.h:157
lsst::meas::base::SdssShapeAlgorithm::ResultKey
SdssShapeResultKey ResultKey
Definition: SdssShape.h:164
lsst::meas::base::SdssShapeAlgorithm::getFlagDefinitions
static FlagDefinitionList const & getFlagDefinitions()
Definition: SdssShape.cc:58
lsst::meas::base::SdssShapeResultKey::get
virtual SdssShapeResult get(afw::table::BaseRecord const &record) const
Get an SdssShapeResult from the given record.
Definition: SdssShape.cc:692
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::meas::base::SdssShapeResult::instFlux_xy_Cov
ErrElement instFlux_xy_Cov
instFlux, xy term in the uncertainty covariance matrix
Definition: SdssShape.h:228
lsst::afw::geom::ellipses::Quadrupole
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
photoCalib
Key< int > photoCalib
Definition: Exposure.cc:67
lsst::meas::base::SdssShapeResultKey::getPsfShape
virtual afw::geom::ellipses::Quadrupole getPsfShape(afw::table::BaseRecord const &record) const
Get a Quadrupole for the Psf from the given record.
Definition: SdssShape.cc:707
ShapeUtilities.h
lsst::meas::base::FlagDefinition
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
Definition: FlagHandler.h:40
lsst::meas::base::SdssShapeResultKey::addFields
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.
Definition: SdssShape.cc:626
lsst::meas::base::SdssShapeAlgorithm::computeFixedMomentsFlux
static FluxResult computeFixedMomentsFlux(ImageT const &image, afw::geom::ellipses::Quadrupole const &shape, geom::Point2D const &position)
Compute the instFlux within a fixed Gaussian aperture.
Definition: SdssShape.cc:819
PhotoCalib.h
Implementation of the Photometric Calibration class.
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::afw::table::SubSchema
A proxy type for name lookups in a Schema.
Definition: Schema.h:357
lsst::geom::Point< double, 2 >
lsst::meas::base::SdssShapeAlgorithm::FAILURE
static FlagDefinition const FAILURE
Definition: SdssShape.h:155
mapper
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
lsst::meas::base::SdssShapeTransform::SdssShapeTransform
SdssShapeTransform(Control const &ctrl, std::string const &name, afw::table::SchemaMapper &mapper)
Definition: SdssShape.cc:922
config.h
lsst::meas::base::SdssShapeResultKey::getFlagHandler
FlagHandler const & getFlagHandler() const
Definition: SdssShape.h:125
lsst::meas::base::SdssShapeResult::SdssShapeResult
SdssShapeResult()
Constructor; initializes everything to NaN.
Definition: SdssShape.cc:621
lsst::meas::base::SdssShapeControl::SdssShapeControl
SdssShapeControl()
Definition: SdssShape.h:62
lsst::meas::base::ShapeResult
A reusable struct for moments-based shape measurements.
Definition: ShapeUtilities.h:43
lsst::meas::base::SdssShapeAlgorithm::MAXITER
static FlagDefinition const MAXITER
Definition: SdssShape.h:159
lsst::meas::base::SdssShapeAlgorithm::fail
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=nullptr) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
Definition: SdssShape.cc:904
lsst::meas::base::FlagDefinitionList::getDefinition
FlagDefinition getDefinition(std::size_t index) const
get a reference to the FlagDefinition with specified index.
Definition: FlagHandler.h:83
lsst::meas::base::SdssShapeControl::maxShift
double maxShift
"Maximum centroid shift, limited to 2-10" ;
Definition: SdssShape.h:56
lsst::meas::base::SdssShapeResult::instFlux_yy_Cov
ErrElement instFlux_yy_Cov
instFlux, yy term in the uncertainty covariance matrix
Definition: SdssShape.h:227
lsst::meas::base::BaseTransform
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:86
lsst::meas::base::SdssShapeResultKey
A FunctorKey that maps SdssShapeResult to afw::table Records.
Definition: SdssShape.h:73
Exposure.h
lsst::meas::base::SdssShapeAlgorithm::SdssShapeAlgorithm
SdssShapeAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Definition: SdssShape.cc:744
lsst::afw::table::CatalogT< BaseRecord >
lsst::meas::base::SdssShapeControl::background
double background
"Additional value to add to background" ;
Definition: SdssShape.h:54
lsst::meas::base::SdssShapeAlgorithm::Result
SdssShapeResult Result
Definition: SdssShape.h:163