LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:45
Defines the fields and offsets for a table.
Definition: Schema.h:44
afw::table::QuadrupoleKey _psfShapeResult
Definition: SdssShape.h:134
A proxy type for name lookups in a Schema.
Definition: Schema.h:326
table::Key< std::string > name
Definition: ApCorrMap.cc:71
afw::table::QuadrupoleKey _outPsfShapeKey
Definition: SdssShape.h:284
CentroidResultKey _centroidResult
Definition: SdssShape.h:132
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Definition: SdssShape.cc:955
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.cc:764
A reusable struct for centroid measurements.
float tol2
&quot;Convergence tolerance for FWHM&quot; ;
Definition: SdssShape.h:56
SafeCentroidExtractor _centroidExtractor
Definition: SdssShape.h:222
tbl::Key< int > wcs
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
ErrElement flux_xy_Cov
flux, xy term in the uncertainty covariance matrix
Definition: SdssShape.h:241
static FluxResult computeFixedMomentsFlux(ImageT const &image, afw::geom::ellipses::Quadrupole const &shape, afw::geom::Point2D const &position)
Definition: SdssShape.cc:863
virtual void set(afw::table::BaseRecord &record, SdssShapeResult const &value) const
Set an SdssShapeResult in the given record.
Definition: SdssShape.cc:747
static Result computeAdaptiveMoments(ImageT const &image, afw::geom::Point2D const &position, bool negative=false, Control const &ctrl=Control())
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
Definition: config.h:36
A coordinate class intended to represent absolute positions.
Definition: PSF.h:39
Definitions and inlines for Quadrupole.
A FunctorKey for ShapeResult.
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
double background
&quot;Additional value to add to background&quot; ;
Definition: SdssShape.h:52
afw::table::Key< ErrElement > _flux_yy_Cov
Definition: SdssShape.h:136
def error
Definition: log.py:103
A reusable struct for moments-based shape measurements.
float ErrElement
Definition: constants.h:53
FlagHandler const & getFlagHandler() const
Definition: SdssShape.h:127
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
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
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:92
double maxShift
&quot;Maximum centroid shift, limited to 2-10&quot; ;
Definition: SdssShape.h:54
afw::table::Key< ErrElement > _flux_xy_Cov
Definition: SdssShape.h:137
A C++ control class to handle SdssShapeAlgorithm&#39;s configuration.
Definition: SdssShape.h:50
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
CentroidTransform _centroidTransform
Definition: SdssShape.h:282
bool doMeasurePsf
&quot;Whether to also compute the shape of the PSF model&quot; ;
Definition: SdssShape.h:57
bool operator!=(SdssShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: SdssShape.h:121
Base class for all records.
Definition: BaseRecord.h:27
SdssShapeAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Definition: SdssShape.cc:786
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
A FunctorKey that maps SdssShapeResult to afw::table Records.
Definition: SdssShape.h:71
A FunctorKey for CentroidResult.
std::bitset< SdssShapeAlgorithm::N_FLAGS > flags
Status flags (see SdssShapeAlgorithm).
Definition: SdssShape.h:244
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
SdssShapeTransform(Control const &ctrl, std::string const &name, afw::table::SchemaMapper &mapper)
Definition: SdssShape.cc:983
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
ErrElement flux_xx_Cov
flux, xx term in the uncertainty covariance matrix
Definition: SdssShape.h:239
float tol1
&quot;Convergence tolerance for e1,e2&quot; ;
Definition: SdssShape.h:55
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
bool getFlag(int index) const
Flag getter for Swig, which doesn&#39;t understand std::bitset.
Definition: SdssShape.h:248
A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys...
Definition: aggregates.h:188
bool isValid() const
Return True if the key is valid.
Definition: SdssShape.cc:775
A reusable result struct for flux measurements.
Definition: FluxUtilities.h:37
virtual void measure(afw::table::SourceRecord &measRecord, afw::image::Exposure< float > const &exposure) const
Definition: SdssShape.cc:915
SdssShapeResult()
Constructor; initializes everything to NaN.
Definition: SdssShape.cc:647
int maxIter
&quot;Maximum number of iterations&quot; ;
Definition: SdssShape.h:53
afw::table::Key< ErrElement > _flux_xx_Cov
Definition: SdssShape.h:135
ErrElement flux_yy_Cov
flux, yy term in the uncertainty covariance matrix
Definition: SdssShape.h:240