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
simpleShape.cc
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 <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #include <array>
25 
28 #include "lsst/afw/math.h"
29 
30 namespace lsst { namespace meas { namespace extensions { namespace simpleShape {
31 namespace {
32 base::FlagDefinitionList flagDefinitions;
33 } // end anonymous
34 
35 base::FlagDefinition const SimpleShape::FAILURE = flagDefinitions.addFailureFlag();
36 
38  return flagDefinitions;
39 }
40 
41 
42 /* ---- Machinery for iterating over elliptical regions ----------------------------------------------------
43  *
44  * In contrast to FootprintFunctor (which is what's used by most other measurement algorithms), this
45  * machinery doesn't require a virtual function call at each pixel, and hence allows the functor to
46  * be inlined.
47  * Eventually, something like this will replace FootprintFunctor (see #1836)
48  */
49 
50 namespace {
51 
52 using afw::geom::Span;
53 
54 Span clipSpan(Span const & span, geom::Box2I const & box) {
55  if (span.getY() < box.getMinY() || span.getY() > box.getMaxY()) return Span();
56  return Span(span.getY(),
57  std::min(std::max(span.getMinX(), box.getMinX()), box.getMaxX()),
58  std::max(std::min(span.getMaxX(), box.getMaxX()), box.getMinX())
59  );
60 }
61 
62 template <typename Function, typename Iterator>
63 void iterateSpan(Function & function, Iterator pixIter, Span const & span) {
64  for (
65  Span::Iterator pointIter = span.begin(), pointEnd = span.end();
66  pointIter != pointEnd;
67  ++pointIter, ++pixIter
68  ) {
69  function(*pointIter, *pixIter);
70  }
71 }
72 
73 template <typename Function, typename Image, typename Region>
74 void iterateRegion(Function & function, Image const & image, Region const & region) {
76  if (bbox.contains(region.getBBox())) {
77  // if the box contains the region, there's no need to check each span to make sure it's entirely
78  // within the image
79  for (
80  typename Region::Iterator spanIter = region.begin(), spanEnd = region.end();
81  spanIter != spanEnd;
82  ++spanIter
83  ) {
84  iterateSpan(
85  function,
86  image.x_at(spanIter->getMinX() - image.getX0(), spanIter->getY() - image.getY0()),
87  *spanIter
88  );
89  }
90  } else {
91  for (
92  typename Region::Iterator spanIter = region.begin(), spanEnd = region.end();
93  spanIter != spanEnd;
94  ++spanIter
95  ) {
96  Span span = clipSpan(*spanIter, bbox);
97  iterateSpan(
98  function,
99  image.x_at(span.getMinX() - image.getX0(), span.getY() - image.getY0()),
100  span
101  );
102  }
103  }
104 }
105 
106 } // anonymous
107 
108 /* ---- Implementation for SimpleShape algorithm ------------------------------------------------------------
109  *
110  * All of the pixel-based work is done by an accumulating functor that we invoke using the above machinery.
111  * The rest is in the static member function measure(), which provides a way to call the algorithm
112  * outside the context of the pluggable source measurement algorithm framework.
113  */
114 
115 namespace {
116 
117 // Enums used to index arrays for code clarity
118 enum { Q0=0, QXX, QYY, QXY, QX, QY, N_Q };
119 enum { MXX=0, MYY, MXY, MX, MY, N_M };
120 
121 typedef Eigen::Matrix<double,N_Q,1> VectorQ;
122 typedef Eigen::Matrix<double,N_Q,N_Q> MatrixQ;
123 typedef Eigen::Matrix<double,N_M,1> VectorM;
124 typedef Eigen::Matrix<double,N_M,N_M> MatrixM;
125 typedef Eigen::Matrix<double,N_M,N_Q> MatrixMQ;
126 
127 struct RawMomentAccumulator {
128 
129  template <typename PixelT>
130  void operator()(geom::Point2I const & pos, PixelT const & pixel) {
131  geom::Extent2D d = geom::Point2D(pos) - _center;
132  geom::Extent2D gtd = _gt(d);
133  double w = std::exp(-0.5 * (gtd.getX()*gtd.getX() + gtd.getY()*gtd.getY()));
134  VectorQ q = VectorQ::Constant(w);
135  q[QXX] *= d.getX() * d.getX();
136  q[QYY] *= d.getY() * d.getY();
137  q[QXY] *= d.getX() * d.getY();
138  q[QX] *= d.getX();
139  q[QY] *= d.getY();
140  moments += q * pixel.image();
141  covariance.selfadjointView<Eigen::Lower>().rankUpdate(q, pixel.variance());
142  }
143 
144  explicit RawMomentAccumulator(afw::geom::ellipses::Ellipse const & weightEllipse) :
145  moments(VectorQ::Zero()),
146  covariance(MatrixQ::Zero()),
147  _center(weightEllipse.getCenter()),
148  _gt(weightEllipse.getCore().getGridTransform())
149  {}
150 
151  VectorQ moments;
152  MatrixQ covariance;
153 private:
154  geom::Point2D _center;
156 };
157 
158 } // anonymous
159 
160 template <typename T>
164  double nSigmaRegion
165 ) {
166  // Define the pixel region we want to accumulate over.
167  afw::geom::ellipses::Ellipse regionEllipse(weight);
168  regionEllipse.getCore().scale(nSigmaRegion);
169  afw::geom::ellipses::PixelRegion region(regionEllipse);
171 
172  // We work in the coordinate system where the origin is the center of the weight function.
173  // This will make things easier in the various transformations we'll have to apply to the raw
174  // moments.
175 
176  // All the pixel operations take place in the next two lines, when we use the above machinery
177  // to accumulate the raw moments in a single pass.
178  RawMomentAccumulator functor(weight);
179  iterateRegion(functor, image, region);
180 
181  // Then we convert the raw moments to an ellipse and centroid, and propagate the uncertainty
182  // through the covariance matrix.
183  MatrixMQ dm_dq = convertRawMoments(functor.moments, result.ellipse, result.center);
184  MatrixM mCov = dm_dq * functor.covariance.selfadjointView<Eigen::Lower>() * dm_dq.adjoint();
185 
186  // Next, we correct the measured moments for the fact that what we just measured was the
187  // moments of the product of the weight function and the data, and we want just the moments
188  // of the data.
189  MatrixM dc_dm = correctWeightedMoments(
190  weight.getCore().as<afw::geom::ellipses::Quadrupole>(),
191  result.ellipse,
192  result.center
193  );
194  result.covariance = dc_dm * mCov.selfadjointView<Eigen::Lower>() * dc_dm.adjoint();
195 
196  // Finally, we switch back to the native image coordinate system.
197  result.center += geom::Extent2D(weight.getCenter());
198 
199  return result;
200 }
201 
202 
204  VectorQ const & q,
206  geom::Point2D & center
207 ) {
208  VectorM m = q.segment<N_M>(1) / q[Q0];
209  MatrixMQ dm_dq = MatrixMQ::Zero();;
210  dm_dq.block<N_M,N_M>(0,1) = MatrixM::Identity() / q[Q0];
211  dm_dq.col(Q0) = -m / q[Q0];
212  // now we account for the centroid^2 terms in the second moments
213  m[MXX] -= m[MX] * m[MX];
214  m[MYY] -= m[MY] * m[MY];
215  m[MXY] -= m[MX] * m[MY];
216  dm_dq(MXX, QX) = -2.0 * m[MX] / q[Q0];
217  dm_dq(MYY, QY) = -2.0 * m[MY] / q[Q0];
218  dm_dq(MXY, QX) = m[MY] / q[Q0];
219  dm_dq(MXY, QY) = m[MX] / q[Q0];
220  double tmp = 2.0 / (q[Q0] * q[Q0] * q[Q0]); // == d(-Q_0^{-2})/d(Q_0)
221  dm_dq(MXX, Q0) += tmp * q[QX] * q[QX];
222  dm_dq(MYY, Q0) += tmp * q[QY] * q[QY];
223  dm_dq(MXY, Q0) += tmp * q[QX] * q[QY];
224 
225  ellipse.setIxx(m[MXX]);
226  ellipse.setIyy(m[MYY]);
227  ellipse.setIxy(m[MXY]);
228  center.setX(m[MX]);
229  center.setY(m[MY]);
230 
231  return dm_dq;
232 }
233 
237  geom::Point2D & center
238 ) {
239  Eigen::Matrix2d wMat = weight.getMatrix();
240  Eigen::Vector2d mVec = center.asEigen();
241  Eigen::Matrix2d mMat = ellipse.getMatrix();
242  if (wMat.determinant() <= 0.0) {
243  throw LSST_EXCEPT(
245  "Weight moments matrix is singular",
247  );
248  }
249  if (mMat.determinant() <= 0.0) {
250  throw LSST_EXCEPT(
252  "Measured moments matrix is singular",
254  );
255  }
256  Eigen::Matrix2d mInv = mMat.inverse();
257  Eigen::Matrix2d cInv = mInv - wMat.inverse();
258  if (cInv.determinant() <= 0.0) {
259  throw LSST_EXCEPT(
261  "Corrected moments matrix is singular",
263  );
264  }
265  Eigen::Matrix2d cMat = cInv.inverse();
266  ellipse.setIxx(cMat(0, 0));
267  ellipse.setIyy(cMat(1, 1));
268  ellipse.setIxy(cMat(0, 1));
269  Eigen::Matrix2d cMat_mInv = cMat * mInv;
270  Eigen::Vector2d mInv_mVec = mInv * mVec;
271  Eigen::Vector2d cVec = cMat_mInv * mVec;
272  center.setX(cVec[0]);
273  center.setY(cVec[1]);
274  Eigen::Matrix2d dcMat_dmxx = cMat_mInv.col(0) * cMat_mInv.col(0).adjoint();
275  Eigen::Matrix2d dcMat_dmyy = cMat_mInv.col(1) * cMat_mInv.col(1).adjoint();
276  Eigen::Matrix2d dcMat_dmxy = cMat_mInv.col(0) * cMat_mInv.col(1).adjoint()
277  + cMat_mInv.col(1) * cMat_mInv.col(0).adjoint();
278  Eigen::Vector2d dcVec_dmxx = cMat_mInv.col(0) * mInv_mVec[0];
279  Eigen::Vector2d dcVec_dmyy = cMat_mInv.col(1) * mInv_mVec[1];
280  Eigen::Vector2d dcVec_dmxy = cMat_mInv.col(0) * mInv_mVec[1] + cMat_mInv.col(1) * mInv_mVec[0];
281  Eigen::Matrix2d const & dcVec_dmVec = cMat_mInv;
282 
283  // calculations done - now we just need to put these elements back into a 5x5 matrix to return
284 
285  MatrixM dc_dm = MatrixM::Zero();
286  dc_dm(MXX, MXX) = dcMat_dmxx(0, 0);
287  dc_dm(MYY, MXX) = dcMat_dmxx(1, 1);
288  dc_dm(MXY, MXX) = dcMat_dmxx(0, 1);
289  dc_dm(MXX, MYY) = dcMat_dmyy(0, 0);
290  dc_dm(MYY, MYY) = dcMat_dmyy(1, 1);
291  dc_dm(MXY, MYY) = dcMat_dmyy(0, 1);
292  dc_dm(MXX, MXY) = dcMat_dmxy(0, 0);
293  dc_dm(MYY, MXY) = dcMat_dmxy(1, 1);
294  dc_dm(MXY, MXY) = dcMat_dmxy(0, 1);
295  dc_dm(MX, MXX) = dcVec_dmxx[0];
296  dc_dm(MY, MXX) = dcVec_dmxx[1];
297  dc_dm(MX, MYY) = dcVec_dmyy[0];
298  dc_dm(MY, MYY) = dcVec_dmyy[1];
299  dc_dm(MX, MXY) = dcVec_dmxy[0];
300  dc_dm(MY, MXY) = dcVec_dmxy[1];
301  dc_dm(MX, MX) = dcVec_dmVec(0, 0);
302  dc_dm(MX, MY) = dcVec_dmVec(0, 1);
303  dc_dm(MY, MX) = dcVec_dmVec(1, 0);
304  dc_dm(MY, MY) = dcVec_dmVec(1, 1);
305 
306  return dc_dm;
307 }
308 
309 
310 SimpleShapeResult::SimpleShapeResult() : ellipse(std::numeric_limits<lsst::meas::base::ErrElement>::quiet_NaN(),
311  std::numeric_limits<lsst::meas::base::ErrElement>::quiet_NaN(),
312  std::numeric_limits<lsst::meas::base::ErrElement>::quiet_NaN()),
313  center(std::numeric_limits<lsst::meas::base::ErrElement>::quiet_NaN(),
314  std::numeric_limits<lsst::meas::base::ErrElement>::quiet_NaN()),
315  covariance(Eigen::Matrix<double,5,5>::Constant(std::numeric_limits<lsst::meas::base::ErrElement>::quiet_NaN()))
316 {}
317 
318 
321  std::string const & name
322 ) {
325  name, "elliptical Gaussian moments");
327  name, "elliptical Gaussian moments", "pixel");
329  std::vector<std::string> ({"Ixx", "Iyy", "Ixy",
330  "Ix", "Iy"}), "pixel");
333  return r;
334 }
335 
337  _shapeResult(s),
338  _centroidResult(s),
339  _uncertantyResult(s, std::vector<std::string> ({"Ixx", "Iyy", "Ixy", "Ix", "Iy"})),
340  _flagHandler(s, SimpleShape::getFlagDefinitions())
341 {}
342 
345  result.ellipse = record.get(_shapeResult);
346  result.center = record.get(_centroidResult);
347  result.covariance = record.get(_uncertantyResult);
348  for (std::size_t n = 0; n < SimpleShape::N_FLAGS; ++n) {
349  result.flags[n] = _flagHandler.getValue(record, n);
350  }
351  return result;
352 }
353 
355  record.set(_shapeResult, value.ellipse);
356  record.set(_centroidResult, value.center);
357  record.set(_uncertantyResult, value.covariance);
358  for (std::size_t n = 0; n < SimpleShape::N_FLAGS; ++n) {
359  _flagHandler.setValue(record, n, value.flags[n]);
360  }
361 }
362 
364  return _shapeResult == other._shapeResult &&
365  _centroidResult == other._centroidResult &&
366  _uncertantyResult == other._uncertantyResult;
367  //don't bother with flags - if we've gotten this far, it's basically impossible the flags don't match
368 }
369 
371  return _shapeResult.isValid() &&
372  _centroidResult.isValid() &&
373  _uncertantyResult.isValid();
374  //don't bother with flags - if we've gotten this far, it's basically impossible the flags don't match
375 }
376 
377 
379  Control const & ctrl,
380  std::string const & name,
382  )
383  : _ctrl(ctrl),
384  _resultKey(SimpleShapeResultKey::addFields(schema, name)),
385  _centroidExtractor(schema, name)
386  {}
387 
390  afw::image::Exposure<float> const & exposure
391 ) const {
392  geom::Point2D center = _centroidExtractor(source, _resultKey.getFlagHandler());
394  // set flags so an exception throw produces a flagged source
396  source.set(_resultKey, result);
397 }
398 
400  afw::table::SourceRecord & measRecord,
402 ) const {
403  _resultKey.getFlagHandler().handleFailure(measRecord, error);
404 }
405 
406 #define INSTANTIATE_IMAGE(IMAGE) \
407  template SimpleShapeResult SimpleShape::computeMoments(\
408  afw::geom::ellipses::Ellipse const &, \
409  IMAGE const &, \
410  double \
411  )
412 
416 
417 }}}} // namespace lsst::meas::extensions::simpleShape
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::afw::geom::ellipses::Quadrupole::setIxx
void setIxx(double ixx)
Definition: Quadrupole.h:55
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::geom::ellipses::Quadrupole::setIyy
void setIyy(double iyy)
Definition: Quadrupole.h:58
moments
VectorQ moments
Definition: simpleShape.cc:151
lsst::afw::geom::Span
A range of pixels within one row of an Image.
Definition: Span.h:47
lsst::meas::extensions::simpleShape::SimpleShape::FAILURE
static base::FlagDefinition const FAILURE
Definition: simpleShape.h:101
lsst::meas::base::FlagDefinition::number
std::size_t number
Definition: FlagHandler.h:54
std::string
STL class.
lsst::log.log.logContinued.error
def error(fmt, *args)
Definition: logContinued.py:213
lsst::meas::extensions::simpleShape::SimpleShape::convertRawMoments
static Eigen::Matrix< double, 5, 6 > convertRawMoments(Eigen::Matrix< double, 6, 1 > const &q, afw::geom::ellipses::Quadrupole &quadrupole, geom::Point2D &center)
Convert linear raw moments into an ellipse and centroid, and return the derivative of the conversion.
Definition: simpleShape.cc:203
lsst::meas::base::FlagHandler::handleFailure
void handleFailure(afw::table::BaseRecord &record, MeasurementError const *error=nullptr) const
Handle an expected or unexpected Exception thrown by a measurement algorithm.
Definition: FlagHandler.cc:76
lsst::afw::table::SourceRecord
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
lsst::afw::table::BaseRecord::get
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
Definition: BaseRecord.h:151
lsst::afw::image::Exposure< float >
lsst::meas::extensions::simpleShape::SimpleShapeControl::nSigmaRegion
double nSigmaRegion
"Maximum radius for pixels to include, in units of sigma" ;
Definition: simpleShape.h:47
lsst::afw::table::PointKey< double >::addFields
static PointKey addFields(Schema &schema, std::string const &name, std::string const &doc, std::string const &unit)
Add a pair of _x, _y fields to a Schema, and return a PointKey that points to them.
Definition: aggregates.cc:36
std::vector< std::string >
lsst::geom::LinearTransform
A 2D linear coordinate transformation.
Definition: LinearTransform.h:69
lsst::meas::base::FlagHandler::getValue
bool getValue(afw::table::BaseRecord const &record, std::size_t i) const
Return the value of the flag field corresponding to the given flag index.
Definition: FlagHandler.h:242
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::get
virtual SimpleShapeResult get(afw::table::BaseRecord const &record) const
Definition: simpleShape.cc:343
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::isValid
bool isValid() const
Return True if the key is valid.
Definition: simpleShape.cc:370
lsst::meas::extensions::simpleShape::SimpleShapeControl
A C++ control class to handle SdssShapeAlgorithm's configuration.
Definition: simpleShape.h:44
lsst::ip::diffim::detail::PixelT
float PixelT
Definition: AssessSpatialKernelVisitor.cc:208
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::SimpleShapeResultKey
SimpleShapeResultKey()
Definition: simpleShape.h:60
lsst::meas::extensions::simpleShape::SimpleShapeResult
Struct to hold the results of SimpleShape when we don't run it as a plugin.
Definition: simpleShape.h:204
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::getFlagHandler
lsst::meas::base::FlagHandler const & getFlagHandler() const
Definition: simpleShape.h:85
lsst::meas::base::MeasurementError
Exception to be thrown when a measurement algorithm experiences a known failure mode.
Definition: exceptions.h:48
lsst::meas::extensions::simpleShape::SimpleShapeResult::flags
std::bitset< SimpleShape::N_FLAGS > flags
Definition: simpleShape.h:211
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::afw::geom::ellipses::Axes
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
Definition: Axes.h:47
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
lsst::meas::extensions::simpleShape::SimpleShapeResult::covariance
Eigen::Matrix< double, 5, 5 > covariance
Matrix of uncertainties; ordered Ixx, Iyy, Ixy, Ix, Iy.
Definition: simpleShape.h:208
lsst::afw::image::Exposure::getMaskedImage
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:228
lsst::afw::geom::ellipses::Quadrupole::getMatrix
Matrix const & getMatrix() const
Return a 2x2 symmetric matrix of the parameters.
Definition: Quadrupole.h:80
lsst::meas::base::FlagDefinitionList
vector-type utility class to build a collection of FlagDefinitions
Definition: FlagHandler.h:60
lsst::meas::extensions::simpleShape::SimpleShapeResult::ellipse
afw::geom::ellipses::Quadrupole ellipse
Measured second moments.
Definition: simpleShape.h:206
math.h
lsst::afw::table::CovarianceMatrixKey::isValid
bool isValid() const noexcept
Return True if all the constituent error Keys are valid.
Definition: aggregates.cc:294
lsst::afw::table::PointKey::isValid
bool isValid() const noexcept
Return True if both the x and y Keys are valid.
Definition: aggregates.h:104
lsst::meas::extensions::simpleShape::SimpleShape::correctWeightedMoments
static Eigen::Matrix< double, 5, 5 > correctWeightedMoments(afw::geom::ellipses::Quadrupole const &weight, afw::geom::ellipses::Quadrupole &ellipse, geom::Point2D &center)
Correct moments measured with a Gaussian weight function by assuming the data was also an elliptical ...
Definition: simpleShape.cc:234
lsst::meas::base::FlagHandler::setValue
void setValue(afw::table::BaseRecord &record, std::size_t i, bool value) const
Set the flag field corresponding to the given flag index.
Definition: FlagHandler.h:262
lsst::meas::extensions::simpleShape::SimpleShape::N_FLAGS
static unsigned int const N_FLAGS
Definition: simpleShape.h:100
lsst::afw::image::MaskedImage
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
ast::detail::source
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
lsst::meas::extensions::simpleShape::SimpleShapeResultKey
Definition: simpleShape.h:52
lsst::afw::table::QuadrupoleKey::addFields
static QuadrupoleKey addFields(Schema &schema, std::string const &name, std::string const &doc, CoordinateType coordType=CoordinateType::PIXEL)
Add a set of quadrupole subfields to a schema and return a QuadrupoleKey that points to them.
Definition: aggregates.cc:100
lsst::afw::geom::ellipses::Quadrupole::setIxy
void setIxy(double ixy)
Definition: Quadrupole.h:61
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::BaseRecord
Base class for all records.
Definition: BaseRecord.h:31
lsst::meas::extensions::simpleShape::SimpleShapeResult::center
geom::Point2D center
Measured first moments, or the input center if !recentroid.
Definition: simpleShape.h:207
lsst::jointcal::Iterator
FastFinder::Iterator Iterator
Definition: FastFinder.cc:178
lsst::meas::extensions::simpleShape::SimpleShape::SimpleShape
SimpleShape(Control const &ctrl, std::string const &name, afw::table::Schema &schema)
Definition: simpleShape.cc:378
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::set
virtual void set(afw::table::BaseRecord &record, SimpleShapeResult const &value) const
Definition: simpleShape.cc:354
pixel
table::PointKey< int > pixel
Definition: DeltaFunctionKernel.cc:101
result
py::object result
Definition: _schema.cc:429
weight
afw::table::Key< double > weight
Definition: CoaddBoundedField.cc:166
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::geom::ellipses::Ellipse
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:51
lsst::afw::geom::ellipses::PixelRegion
A pixelized region containing all pixels whose centers are within an Ellipse.
Definition: PixelRegion.h:46
std::min
T min(T... args)
lsst::meas::modelfit::Matrix
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: common.h:45
PixelRegion.h
lsst::afw::geom::ellipses::Quadrupole
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
lsst::afw::table::CovarianceMatrixKey::addFields
static CovarianceMatrixKey addFields(Schema &schema, std::string const &prefix, NameArray const &names, std::string const &unit, bool diagonalOnly=false)
Add covariance matrix fields to a Schema, and return a CovarianceMatrixKey to manage them.
Definition: aggregates.cc:141
lsst::geom::Box2I::getMaxY
int getMaxY() const noexcept
Definition: Box.h:162
lsst::meas::extensions::simpleShape.name
name
Definition: __init__.py:8
std::exp
T exp(T... args)
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::Box2I::getMaxX
int getMaxX() const noexcept
Definition: Box.h:161
std
STL namespace.
lsst::geom::Point< int, 2 >
covariance
MatrixQ covariance
Definition: simpleShape.cc:152
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::meas::extensions::simpleShape::SimpleShape::computeMoments
static SimpleShapeResult computeMoments(afw::geom::ellipses::Ellipse const &weight, afw::image::MaskedImage< T > const &image, double nSigmaRegion=3.0)
Compute the Gaussian-weighted moments of an image.
Definition: simpleShape.cc:161
lsst::geom::Box2I::getMinX
int getMinX() const noexcept
Definition: Box.h:157
lsst::afw::image::PARENT
@ PARENT
Definition: ImageBase.h:94
lsst::geom::Extent2D
Extent< double, 2 > Extent2D
Definition: Extent.h:400
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::operator==
bool operator==(SimpleShapeResultKey const &other) const
Compare the FunctorKey for equality with another, using the underlying Keys.
Definition: simpleShape.cc:363
lsst::meas::extensions::simpleShape::SimpleShape::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: simpleShape.cc:388
w
double w
Definition: CoaddPsf.cc:69
std::size_t
lsst::meas::extensions::simpleShape::SimpleShape::fail
virtual void fail(afw::table::SourceRecord &measRecord, lsst::meas::base::MeasurementError *error=NULL) const
Handle an exception thrown by the current algorithm by setting flags in the given record.
Definition: simpleShape.cc:399
lsst::afw::geom::ellipses::Ellipse::getCore
BaseCore const & getCore() const
Return the ellipse core.
Definition: Ellipse.h:71
lsst::afw::table::BaseRecord::set
void set(Key< T > const &key, U const &value)
Set value of a field for the given key.
Definition: BaseRecord.h:164
std::max
T max(T... args)
lsst::meas::extensions::simpleShape::SimpleShapeResult::SimpleShapeResult
SimpleShapeResult()
Constructor; initializes everything to Nan.
Definition: simpleShape.cc:310
lsst::geom::Extent< double, 2 >
lsst::meas::extensions::simpleShape::SimpleShape::getFlagDefinitions
static base::FlagDefinitionList const & getFlagDefinitions()
Definition: simpleShape.cc:37
lsst::afw::geom::ellipses::BaseCore::scale
void scale(double factor)
Scale the size of the ellipse core by the given factor.
Definition: BaseCore.cc:104
lsst::meas::base::FlagHandler::addFields
static FlagHandler addFields(afw::table::Schema &schema, std::string const &prefix, FlagDefinitionList const &flagDefs, FlagDefinitionList const &exclDefs=FlagDefinitionList::getEmptyList())
Add Flag fields to a schema, creating a FlagHandler object to manage them.
Definition: FlagHandler.cc:37
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
simpleShape.h
lsst::meas::extensions::simpleShape::SimpleShapeControl::sigma
double sigma
"Sigma of circular Gaussian used as weight function, in pixels" ;
Definition: simpleShape.h:46
lsst::geom::Box2I::getMinY
int getMinY() const noexcept
Definition: Box.h:158
m
int m
Definition: SpanSet.cc:49
lsst::meas::extensions::simpleShape::SimpleShapeResultKey::addFields
static SimpleShapeResultKey addFields(afw::table::Schema &schema, std::string const &name)
Definition: simpleShape.cc:319
lsst::afw::table::QuadrupoleKey::isValid
bool isValid() const noexcept
Return True if all the constituent Keys are valid.
Definition: aggregates.h:342
INSTANTIATE_IMAGE
#define INSTANTIATE_IMAGE(IMAGE)
Definition: simpleShape.cc:406