LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
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"
31 #include "lsst/afw/image/Calib.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 
110  virtual afw::geom::ellipses::Quadrupole getPsfShape(afw::table::BaseRecord const& record) const;
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 
171  SdssShapeAlgorithm(Control const& ctrl, std::string const& name, afw::table::Schema& schema);
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 
254  SdssShapeTransform(Control const& ctrl, std::string const& name, afw::table::SchemaMapper& mapper);
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] calib 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::Calib const& calib) 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
Transformation for SdssShape measurements.
Definition: SdssShape.h:250
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
Defines the fields and offsets for a table.
Definition: Schema.h:50
bool doMeasurePsf
"Whether to also compute the shape of the PSF model" ;
Definition: SdssShape.h:59
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
Definition: SkyWcs.h:115
A proxy type for name lookups in a Schema.
Definition: Schema.h:360
ErrElement instFlux_yy_Cov
instFlux, yy term in the uncertainty covariance matrix
Definition: SdssShape.h:227
float tol2
"Convergence tolerance for FWHM" ;
Definition: SdssShape.h:58
static FlagDefinition const SHIFT
Definition: SdssShape.h:158
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
Simple class used to define and document flags The name and doc constitute the identity of the FlagDe...
Definition: FlagHandler.h:40
A reusable struct for centroid measurements.
bool operator!=(SdssShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: SdssShape.h:119
double background
"Additional value to add to background" ;
Definition: SdssShape.h:54
int maxIter
"Maximum number of iterations" ;
Definition: SdssShape.h:55
Utility class for measurement algorithms that extracts a position from the Centroid slot and handles ...
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
static FlagDefinition const UNWEIGHTED
Definition: SdssShape.h:157
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition: config.h:36
Base for instFlux measurement transformations.
float tol1
"Convergence tolerance for e1,e2" ;
Definition: SdssShape.h:57
Describe an exposure&#39;s calibration.
Definition: Calib.h:95
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
static FlagDefinition const UNWEIGHTED_BAD
Definition: SdssShape.h:156
double maxShift
"Maximum centroid shift, limited to 2-10" ;
Definition: SdssShape.h:56
float ErrElement
Definition: constants.h:55
A FunctorKey for ShapeResult.
bool getFlag(std::string const &name) const
Definition: SdssShape.h:236
STL class.
Utility class for handling flag fields that indicate the failure modes of an algorithm.
Definition: FlagHandler.h:148
A reusable struct for moments-based shape measurements.
A base class for image defects.
Result object SdssShapeAlgorithm.
Definition: SdssShape.h:224
static FlagDefinitionList const & getFlagDefinitions()
Definition: SdssShape.cc:58
bool isValid
Definition: fits.cc:378
FlagDefinition getDefinition(std::size_t index) const
get a reference to the FlagDefinition with specified index.
Definition: FlagHandler.h:83
table::Schema schema
Definition: Camera.cc:161
A C++ control class to handle SdssShapeAlgorithm&#39;s configuration.
Definition: SdssShape.h:52
solver_t * s
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:59
std::bitset< SdssShapeAlgorithm::N_FLAGS > flags
Status flags (see SdssShapeAlgorithm).
Definition: SdssShape.h:230
Base class for all records.
Definition: BaseRecord.h:31
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition: Algorithm.h:170
static FlagDefinition const MAXITER
Definition: SdssShape.h:159
static FlagDefinition const PSF_SHAPE_BAD
Definition: SdssShape.h:160
A FunctorKey that maps SdssShapeResult to afw::table Records.
Definition: SdssShape.h:73
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:85
static FlagDefinition const FAILURE
Definition: SdssShape.h:155
A FunctorKey for CentroidResult.
def measure(mi, x, y, size, statistic, stats)
Definition: fringe.py:357
ItemVariant const * other
Definition: Schema.cc:56
Record class that contains measurements made on a single exposure.
Definition: Source.h:82
ErrElement instFlux_xx_Cov
instFlux, xx term in the uncertainty covariance matrix
Definition: SdssShape.h:226
Measure the image moments of source using adaptive Gaussian weights.
Definition: SdssShape.h:150
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:90
FlagHandler const & getFlagHandler() const
Definition: SdssShape.h:125
ErrElement instFlux_xy_Cov
instFlux, xy term in the uncertainty covariance matrix
Definition: SdssShape.h:228
vector-type utility class to build a collection of FlagDefinitions
Definition: FlagHandler.h:60
bool getFlag(unsigned int index) const
Flag getter for Swig, which doesn&#39;t understand std::bitset.
Definition: SdssShape.h:234
Convenience base class that combines the OutputFunctorKey and InputFunctorKey.
Definition: FunctorKey.h:74
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys...
Definition: aggregates.h:282
Base for centroid measurement transformations.
A reusable result struct for instFlux measurements.
Definition: FluxUtilities.h:41
SchemaMapper * mapper
Definition: SchemaMapper.cc:78