LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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"
38 
39 namespace lsst {
40 namespace meas {
41 namespace base {
42 
43 class SdssShapeResult;
44 
51 public:
52  LSST_CONTROL_FIELD(background, double, "Additional value to add to background");
53  LSST_CONTROL_FIELD(maxIter, int, "Maximum number of iterations");
54  LSST_CONTROL_FIELD(maxShift, double, "Maximum centroid shift, limited to 2-10");
55  LSST_CONTROL_FIELD(tol1, float, "Convergence tolerance for e1,e2");
56  LSST_CONTROL_FIELD(tol2, float, "Convergence tolerance for FWHM");
57  LSST_CONTROL_FIELD(doMeasurePsf, bool, "Whether to also compute the shape of the PSF model");
58 
60  SdssShapeControl() : background(0.0), maxIter(100), maxShift(), tol1(1E-5), tol2(1E-4),
61  doMeasurePsf(true) {}
62 };
63 
71 class SdssShapeResultKey : public afw::table::FunctorKey<SdssShapeResult> {
72 public:
73 
87  std::string const & name,
88  bool doMeasurePsf
89  );
90 
93 
104 
106  virtual SdssShapeResult get(afw::table::BaseRecord const & record) const;
107 
109  virtual void set(afw::table::BaseRecord & record, SdssShapeResult const & value) const;
110 
113 
115  virtual void setPsfShape(afw::table::BaseRecord & record,
116  afw::geom::ellipses::Quadrupole const & value) const;
117 
119  bool operator==(SdssShapeResultKey const & other) const;
121  bool operator!=(SdssShapeResultKey const & other) const { return !(*this == other); }
123 
125  bool isValid() const;
126 
127  FlagHandler const & getFlagHandler() const { return _flagHandler; }
128 
129 private:
139 };
140 
153 public:
154 
158 
159  // NOTE: In order to accommodate the optional setting of additional fields when running with
160  // doMeasurePsf = true (do set extra fields) or false (do NOT set extra fields), all of
161  // the code in SdssShape assumes that PSF_SHAPE_BAD is the last entry in the enum list.
162  // If new flags are added, be sure to add them above the PSF_SHAPE_BAD entry.
163  enum {
169  PSF_SHAPE_BAD, // NOTE: PSF_SHAPE_BAD must be the last entry in the enum list
171  };
172 
173  SdssShapeAlgorithm(Control const & ctrl, std::string const & name, afw::table::Schema & schema);
174 
185  template <typename ImageT>
187  ImageT const & image,
188  afw::geom::Point2D const & position,
189  bool negative=false,
190  Control const & ctrl=Control()
191  );
192 
202  template <typename ImageT>
204  ImageT const & image,
205  afw::geom::ellipses::Quadrupole const & shape,
206  afw::geom::Point2D const & position
207  );
208 
209  virtual void measure(
210  afw::table::SourceRecord & measRecord,
211  afw::image::Exposure<float> const & exposure
212  ) const;
213 
214  virtual void fail(
215  afw::table::SourceRecord & measRecord,
216  MeasurementError * error=NULL
217  ) const;
218 
219 private:
223 };
224 
237 class SdssShapeResult : public ShapeResult, public CentroidResult, public FluxResult {
238 public:
242 
243 #ifndef SWIG
244  std::bitset<SdssShapeAlgorithm::N_FLAGS> flags;
245 #endif
246 
248  bool getFlag(int index) const { return flags[index]; }
249 
250  SdssShapeResult();
251 
252 };
253 
262 public:
264 
265  SdssShapeTransform(Control const & ctrl, std::string const & name, afw::table::SchemaMapper & mapper);
266 
267  /*
268  * @brief Perform transformation from inputCatalog to outputCatalog.
269  *
270  * @param[in] inputCatalog Source of data to be transformed
271  * @param[in,out] outputCatalog Container for transformed results
272  * @param[in] wcs World coordinate system under which transformation will take place
273  * @param[in] calib Photometric calibration under which transformation will take place
274  * @throws LengthError Catalog sizes do not match
275  */
276  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
277  afw::table::BaseCatalog & outputCatalog,
278  afw::image::Wcs const & wcs,
279  afw::image::Calib const & calib) const;
280 private:
286 };
287 
288 }}} // namespace lsst::meas::base
289 
290 #endif // !LSST_MEAS_BASE_SdssShape_h_INCLUDED
Transformation for SdssShape measurements.
Definition: SdssShape.h:261
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:45
Defines the fields and offsets for a table.
Definition: Schema.h:44
bool doMeasurePsf
&quot;Whether to also compute the shape of the PSF model&quot; ;
Definition: SdssShape.h:57
A proxy type for name lookups in a Schema.
Definition: Schema.h:340
static Result computeAdaptiveMoments(ImageT const &image, afw::geom::Point2D const &position, bool negative=false, Control const &ctrl=Control())
Compute the adaptive Gaussian-weighted moments of an image.
afw::table::Key< ErrElement > _flux_yy_Cov
Definition: SdssShape.h:136
SafeCentroidExtractor _centroidExtractor
Definition: SdssShape.h:222
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:759
table::Key< std::string > name
Definition: ApCorrMap.cc:71
static FluxResult computeFixedMomentsFlux(ImageT const &image, afw::geom::ellipses::Quadrupole const &shape, afw::geom::Point2D const &position)
Compute the flux within a fixed Gaussian aperture.
Definition: SdssShape.cc:863
float tol2
&quot;Convergence tolerance for FWHM&quot; ;
Definition: SdssShape.h:56
CentroidTransform _centroidTransform
Definition: SdssShape.h:282
FlagHandler const & getFlagHandler() const
Definition: SdssShape.h:127
A custom container class for records, based on std::vector.
Definition: Catalog.h:95
afw::table::Schema schema
Definition: GaussianPsf.cc:41
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
bool operator!=(SdssShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: SdssShape.h:121
A reusable struct for centroid measurements.
double background
&quot;Additional value to add to background&quot; ;
Definition: SdssShape.h:52
tbl::Key< int > wcs
int maxIter
&quot;Maximum number of iterations&quot; ;
Definition: SdssShape.h:53
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
afw::table::QuadrupoleKey _outPsfShapeKey
Definition: SdssShape.h:284
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
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ &quot;control object&quot; structs.
Definition: config.h:36
Base for flux measurement transformations.
float tol1
&quot;Convergence tolerance for e1,e2&quot; ;
Definition: SdssShape.h:55
Describe an exposure&#39;s calibration.
Definition: Calib.h:82
double maxShift
&quot;Maximum centroid shift, limited to 2-10&quot; ;
Definition: SdssShape.h:54
bool isValid() const
Return True if the key is valid.
Definition: SdssShape.cc:775
float ErrElement
Definition: constants.h:53
ErrElement flux_yy_Cov
flux, yy term in the uncertainty covariance matrix
Definition: SdssShape.h:240
A coordinate class intended to represent absolute positions.
bool operator==(SdssShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: SdssShape.cc:764
Definitions and inlines for Quadrupole.
A FunctorKey for ShapeResult.
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
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:915
def error
Definition: log.py:103
Utility class for handling flag fields that indicate the failure modes of an algorithm.
Definition: FlagHandler.h:73
A reusable struct for moments-based shape measurements.
Result object SdssShapeAlgorithm.
Definition: SdssShape.h:237
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55
SdssShapeResult()
Constructor; initializes everything to NaN.
Definition: SdssShape.cc:647
SdssShapeAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Definition: SdssShape.cc:786
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:743
A C++ control class to handle SdssShapeAlgorithm&#39;s configuration.
Definition: SdssShape.h:50
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
virtual void set(afw::table::BaseRecord &record, SdssShapeResult const &value) const
Set an SdssShapeResult in the given record.
Definition: SdssShape.cc:747
virtual void operator()(afw::table::SourceCatalog const &inputCatalog, afw::table::BaseCatalog &outputCatalog, afw::image::Wcs const &wcs, afw::image::Calib const &calib) const
Definition: SdssShape.cc:1010
std::bitset< SdssShapeAlgorithm::N_FLAGS > flags
Status flags (see SdssShapeAlgorithm).
Definition: SdssShape.h:244
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record...
Definition: SdssShape.cc:955
Base class for all records.
Definition: BaseRecord.h:27
An abstract base classes for which the same implementation can be used for both SingleFrameAlgorithm ...
Definition: Algorithm.h:177
A FunctorKey that maps SdssShapeResult to afw::table Records.
Definition: SdssShape.h:71
Abstract base class for all C++ measurement transformations.
Definition: Transform.h:82
A FunctorKey for CentroidResult.
afw::table::QuadrupoleKey _psfShapeResult
Definition: SdssShape.h:134
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
Measure the image moments of source using adaptive Gaussian weights.
Definition: SdssShape.h:152
afw::table::Key< ErrElement > _flux_xy_Cov
Definition: SdssShape.h:137
bool getFlag(int index) const
Flag getter for Swig, which doesn&#39;t understand std::bitset.
Definition: SdssShape.h:248
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:92
afw::table::Key< ErrElement > _flux_xx_Cov
Definition: SdssShape.h:135
ErrElement flux_xx_Cov
flux, xx term in the uncertainty covariance matrix
Definition: SdssShape.h:239
Convenience base class that combines the OutputFunctorKey and InputFunctorKey.
Definition: FunctorKey.h:70
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:662
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys...
Definition: aggregates.h:188
SdssShapeTransform(Control const &ctrl, std::string const &name, afw::table::SchemaMapper &mapper)
Definition: SdssShape.cc:983
Base for centroid measurement transformations.
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37
ErrElement flux_xy_Cov
flux, xy term in the uncertainty covariance matrix
Definition: SdssShape.h:241