LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
SdssShape.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
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 <http://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"
36 
37 namespace lsst { namespace meas { namespace base {
38 
39 class SdssShapeResult;
40 
47 public:
48  LSST_CONTROL_FIELD(background, double, "Additional value to add to background");
49  LSST_CONTROL_FIELD(maxIter, int, "Maximum number of iterations");
50  LSST_CONTROL_FIELD(maxShift, double, "Maximum centroid shift, limited to 2-10");
51  LSST_CONTROL_FIELD(tol1, float, "Convergence tolerance for e1,e2");
52  LSST_CONTROL_FIELD(tol2, float, "Convergence tolerance for FWHM");
53 
55  SdssShapeControl() : background(0.0), maxIter(100), maxShift(), tol1(1E-5), tol2(1E-4) {}
56 
57 };
58 
66 class SdssShapeResultKey : public afw::table::FunctorKey<SdssShapeResult> {
67 public:
68 
78  std::string const & name
79  );
80 
83 
94 
96  virtual SdssShapeResult get(afw::table::BaseRecord const & record) const;
97 
99  virtual void set(afw::table::BaseRecord & record, SdssShapeResult const & value) const;
100 
102  bool operator==(SdssShapeResultKey const & other) const;
104  bool operator!=(SdssShapeResultKey const & other) const { return !(*this == other); }
106 
108  bool isValid() const;
109 
110  FlagHandler const & getFlagHandler() const { return _flagHandler; }
111 
112 private:
120 };
121 
134 public:
135 
139 
140  enum {
147  };
148 
149  SdssShapeAlgorithm(Control const & ctrl, std::string const & name, afw::table::Schema & schema);
150 
160  template <typename ImageT>
162  ImageT const & image,
163  afw::geom::Point2D const & position,
164  Control const & ctrl=Control()
165  );
166 
176  template <typename ImageT>
178  ImageT const & image,
179  afw::geom::ellipses::Quadrupole const & shape,
180  afw::geom::Point2D const & position
181  );
182 
183  virtual void measure(
184  afw::table::SourceRecord & measRecord,
185  afw::image::Exposure<float> const & exposure
186  ) const;
187 
188  virtual void fail(
189  afw::table::SourceRecord & measRecord,
190  MeasurementError * error=NULL
191  ) const;
192 
193 private:
197 };
198 
211 class SdssShapeResult : public ShapeResult, public CentroidResult, public FluxResult {
212 public:
216 
217 #ifndef SWIG
218  std::bitset<SdssShapeAlgorithm::N_FLAGS> flags;
219 #endif
220 
222  bool getFlag(int index) const { return flags[index]; }
223 
224  SdssShapeResult();
225 
226 };
227 
236 public:
238 
239  SdssShapeTransform(Control const & ctrl, std::string const & name, afw::table::SchemaMapper & mapper);
240 
241  /*
242  * @brief Perform transformation from inputCatalog to outputCatalog.
243  *
244  * @param[in] inputCatalog Source of data to be transformed
245  * @param[in,out] outputCatalog Container for transformed results
246  * @param[in] wcs World coordinate system under which transformation will take place
247  * @param[in] calib Photometric calibration under which transformation will take place
248  * @throws LengthError Catalog sizes do not match
249  */
250  virtual void operator()(afw::table::SourceCatalog const & inputCatalog,
251  afw::table::BaseCatalog & outputCatalog,
252  afw::image::Wcs const & wcs,
253  afw::image::Calib const & calib) const;
254 private:
258 };
259 
260 }}} // namespace lsst::meas::base
261 
262 #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:46
static SdssShapeResultKey addFields(afw::table::Schema &schema, std::string const &name)
Add the appropriate fields to a Schema, and return a SdssShapeResultKey that manages them...
Definition: SdssShape.cc:654
A proxy type for name lookups in a Schema.
Definition: Schema.h:330
afw::table::Key< ErrElement > _flux_yy_Cov
Definition: SdssShape.h:117
SafeCentroidExtractor _centroidExtractor
Definition: SdssShape.h:196
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)
Definition: SdssShape.cc:813
float tol2
&quot;Convergence tolerance for FWHM&quot; ;
Definition: SdssShape.h:52
CentroidTransform _centroidTransform
Definition: SdssShape.h:256
FlagHandler const & getFlagHandler() const
Definition: SdssShape.h:110
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
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:104
A reusable struct for centroid measurements.
double background
&quot;Additional value to add to background&quot; ;
Definition: SdssShape.h:48
tbl::Key< int > wcs
SdssShapeControl()
Default constructor.
Definition: SdssShape.h:55
int maxIter
&quot;Maximum number of iterations&quot; ;
Definition: SdssShape.h:49
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
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
float tol1
&quot;Convergence tolerance for e1,e2&quot; ;
Definition: SdssShape.h:51
double maxShift
&quot;Maximum centroid shift, limited to 2-10&quot; ;
Definition: SdssShape.h:50
bool isValid() const
Return True if the key is valid.
Definition: SdssShape.cc:732
float ErrElement
Definition: constants.h:53
ErrElement flux_yy_Cov
flux, yy term in the uncertainty covariance matrix
Definition: SdssShape.h:214
bool operator==(SdssShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: SdssShape.cc:722
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
Definition: SdssShape.cc:865
def error
Definition: log.py:108
A reusable struct for moments-based shape measurements.
Result object SdssShapeAlgorithm.
Definition: SdssShape.h:211
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
static Result computeAdaptiveMoments(ImageT const &image, afw::geom::Point2D const &position, Control const &ctrl=Control())
SdssShapeResult()
Constructor; initializes everything to NaN.
Definition: SdssShape.cc:640
SdssShapeAlgorithm(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Definition: SdssShape.cc:742
A C++ control class to handle SdssShapeAlgorithm&#39;s configuration.
Definition: SdssShape.h:46
A FunctorKey for FluxResult.
Definition: FluxUtilities.h:56
virtual void set(afw::table::BaseRecord &record, SdssShapeResult const &value) const
Set a CentroidResult in the given record.
Definition: SdssShape.cc:710
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:922
std::bitset< SdssShapeAlgorithm::N_FLAGS > flags
Status flags (see SdssShapeAlgorithm).
Definition: SdssShape.h:218
virtual void fail(afw::table::SourceRecord &measRecord, MeasurementError *error=NULL) const
Definition: SdssShape.cc:877
Base class for all records.
Definition: BaseRecord.h:27
A FunctorKey that maps SdssShapeResult to afw::table Records.
Definition: SdssShape.h:66
A FunctorKey for CentroidResult.
Record class that contains measurements made on a single exposure.
Definition: Source.h:81
Measure the image moments of source using adaptive Gaussian weights.
Definition: SdssShape.h:133
afw::table::Key< ErrElement > _flux_xy_Cov
Definition: SdssShape.h:118
bool getFlag(int index) const
Flag getter for Swig, which doesn&#39;t understand std::bitset.
Definition: SdssShape.h:222
SdssShapeResultKey()
Default constructor; instance will not be usuable unless subsequently assigned to.
Definition: SdssShape.h:82
afw::table::Key< ErrElement > _flux_xx_Cov
Definition: SdssShape.h:116
ErrElement flux_xx_Cov
flux, xx term in the uncertainty covariance matrix
Definition: SdssShape.h:213
SdssShapeTransform(Control const &ctrl, std::string const &name, afw::table::SchemaMapper &mapper)
Definition: SdssShape.cc:904
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:215