LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.45
LSSTDataManagementBasePackage
ShapeletFunction.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010, 2011 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 #ifndef LSST_AFW_MATH_SHAPELETS_SHAPELETFUNCTION_H
26 #define LSST_AFW_MATH_SHAPELETS_SHAPELETFUNCTION_H
27 
28 #include "ndarray.h"
32 #include "lsst/geom.h"
33 #include "lsst/afw/geom/ellipses.h"
34 #include "lsst/afw/image/Image.h"
35 
36 #include <list>
37 
38 namespace lsst { namespace shapelet {
39 
40 class ShapeletFunctionEvaluator;
41 
66 public:
67 
70 
72 
73  static double const FLUX_FACTOR;
74 
76  int getOrder() const { return _order; }
77 
79  afw::geom::ellipses::Ellipse const & getEllipse() const { return _ellipse; }
80 
82  afw::geom::ellipses::Ellipse & getEllipse() { return _ellipse; }
83 
85  void setEllipse(afw::geom::ellipses::Ellipse const & ellipse) { _ellipse = ellipse; }
86 
88  BasisTypeEnum getBasisType() const { return _basisType; }
89 
91  void changeBasisType(BasisTypeEnum basisType) {
92  ConversionMatrix::convertCoefficientVector(_coefficients, _basisType, basisType, _order);
93  _basisType = basisType;
94  }
95 
97  void normalize(double value=1.0);
98 
100  ndarray::Array<double,1,1> const getCoefficients() { return _coefficients; }
101 
103  ndarray::Array<double const,1,1> const getCoefficients() const { return _coefficients; }
104 
107 
109  Evaluator evaluate() const;
110 
112  void shiftInPlace(geom::Extent2D const & offset) {
113  _ellipse.getCenter() += offset;
114  }
115 
118  _ellipse.transform(transform).inPlace();
119  }
120 
122  ShapeletFunction(int order, BasisTypeEnum basisType);
123 
126  int order, BasisTypeEnum basisType,
127  ndarray::Array<double,1,1> const & coefficients
128  );
129 
131  ShapeletFunction(int order, BasisTypeEnum basisType, double radius,
132  geom::Point2D const & center=geom::Point2D());
133 
136  int order, BasisTypeEnum basisType, double radius, geom::Point2D const & center,
137  ndarray::Array<double,1,1> const & coefficients
138  );
139 
141  ShapeletFunction(int order, BasisTypeEnum basisType,
143 
146  int order, BasisTypeEnum basisType,
147  afw::geom::ellipses::Ellipse const & ellipse,
148  ndarray::Array<double const,1,1> const & coefficients
149  );
150 
152  ShapeletFunction(ShapeletFunction const & other);
153 
156 
159 
160 private:
161 
162  int _order;
163  BasisTypeEnum _basisType;
165  ndarray::Array<double,1,1> _coefficients;
166 };
167 
178 public:
179 
182 
184  double operator()(double x, double y) const {
185  return this->operator()(geom::Point2D(x, y));
186  }
187 
189  double operator()(geom::Point2D const & point) const {
190  return _normalization * _h.sumEvaluation(_coefficients, _transform(point));
191  }
192 
194  double operator()(geom::Extent2D const & point) const {
195  return _normalization * _h.sumEvaluation(_coefficients, _transform(point));
196  }
197 
199  ndarray::Array<double,1,1> operator()(
200  ndarray::Array<double const,1> const & x,
201  ndarray::Array<double const,1> const & y
202  ) const;
203 
205  void addToImage(
206  ndarray::Array<double,2,1> const & array,
207  geom::Point2I const & xy0 = geom::Point2I()
208  ) const;
209 
212  addToImage(image.getArray(), image.getXY0());
213  }
214 
216  double integrate() const {
217  return _h.sumIntegration(_coefficients);
218  }
219 
221  afw::geom::ellipses::Ellipse computeMoments() const;
222 
224  void update(ShapeletFunction const & function);
225 
227  explicit ShapeletFunctionEvaluator(ShapeletFunction const & function);
228 
229 private:
230 
232 
233  void _computeRawMoments(double & q0, Eigen::Vector2d & q1, Eigen::Matrix2d & q2) const;
234 
235  double _normalization;
236  ndarray::Array<double const,1,1> _coefficients;
237  geom::AffineTransform _transform;
239 };
240 
242  return ShapeletFunctionEvaluator(*this);
243 }
244 
245 }} // namespace lsst::shapelet
246 
247 #endif // !defined(LSST_AFW_MATH_SHAPELETS_SHAPELETFUNCTION_H)
void setEllipse(afw::geom::ellipses::Ellipse const &ellipse)
Set the ellipse.
lsst::geom::Point2D const & getCenter() const
Return the center point.
Definition: Ellipse.h:62
void shiftInPlace(geom::Extent2D const &offset)
Shift the shapelet function by shifting the basis ellipse.
An affine coordinate transformation consisting of a linear transformation and an offset.
std::shared_ptr< ShapeletFunctionEvaluator > Ptr
void changeBasisType(BasisTypeEnum basisType)
Change the basis type and convert coefficients in-place correspondingly.
A class to evaluate HERMITE shapelet-related quantities.
int y
Definition: SpanSet.cc:49
ndarray::Array< double, 1, 1 > const getCoefficients()
Return the coefficient vector.
ItemVariant const * other
Definition: Schema.cc:56
int getOrder() const
Return the maximum order (inclusive), either or .
afw::geom::ellipses::Ellipse const & getEllipse() const
Get the ellipse (const).
double integrate() const
Compute the definite integral or integral moments.
A base class for image defects.
std::shared_ptr< ShapeletFunctionEvaluator const > ConstPtr
Evaluates a ShapeletFunction.
BasisTypeEnum getBasisType() const
Return the basis type (HERMITE or LAGUERRE).
afw::geom::ellipses::Ellipse & getEllipse()
Get the ellipse (non-const).
ndarray::Array< double const, 1, 1 > const getCoefficients() const
Return the coefficient vector (const).
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:51
void inPlace()
Transform the ellipse in-place.
Definition: Transformer.cc:103
void normalize(double value=1.0)
Normalize the integral of the shapelet function to the given value.
double operator()(geom::Extent2D const &point) const
Evaluate at the given point.
std::shared_ptr< ShapeletFunction const > ConstPtr
double x
Evaluator evaluate() const
Construct a helper object that can efficiently evaluate the function.
std::shared_ptr< ShapeletFunction > Ptr
lsst::geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: ImageBase.h:340
static void convertCoefficientVector(ndarray::Array< double, 1 > const &array, BasisTypeEnum input, BasisTypeEnum output, int order)
Convert a coefficient vector between basis types in-place.
ShapeletFunctionEvaluator Evaluator
double operator()(geom::Point2D const &point) const
Evaluate at the given point.
void addToImage(boost::shared_ptr< afw::image::Image< double > > image, std::vector< boost::shared_ptr< afw::image::Image< double > >> const &imgVector, std::vector< double > const &weightVector)
Definition: CoaddPsf.cc:192
Constants, typedefs, and general-purpose functions for shapelets library.
void addToImage(afw::image::Image< double > &image) const
Evaluate the function on the given image.
ShapeletFunction()
Default constructor to appease SWIG (used by std::list). Not for use by users.
ShapeletFunction convolve(ShapeletFunction const &other) const
Convolve the shapelet function.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
double operator()(double x, double y) const
Evaluate at the given point.
void transformInPlace(geom::AffineTransform const &transform)
Transform the shapelet function by transforming the basis ellipse.
A 2-d function defined by an expansion onto a Gauss-Laguerre or Gauss-Hermite basis.
Transformer transform(lsst::geom::AffineTransform const &transform)
Definition: Transformer.h:124
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
ndarray::Array< double const, 2, 2 > coefficients
ShapeletFunction & operator=(ShapeletFunction const &other)
Assignment (deep).