LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
ChebyshevBoundedField.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2014 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_AFW_MATH_ChebyshevBoundedField_h_INCLUDED
25 #define LSST_AFW_MATH_ChebyshevBoundedField_h_INCLUDED
26 
27 #include "ndarray.h"
28 
29 #include "lsst/pex/config.h"
32 
33 namespace lsst {
34 namespace afw {
35 namespace math {
36 
39 public:
41 
42  LSST_CONTROL_FIELD(orderX, int, "maximum Chebyshev function order in x");
43 
44  LSST_CONTROL_FIELD(orderY, int, "maximum Chebyshev function order in y");
45 
47  "if true, only include terms where the sum of the x and y order "
48  "is less than or equal to max(orderX, orderY)");
49 
51  int computeSize() const;
52 };
53 
76 class ChebyshevBoundedField : public table::io::PersistableFacade<ChebyshevBoundedField>,
77  public BoundedField {
78 public:
80 
116  ndarray::Array<double const, 2, 2> const& coefficients);
117 
120  ChebyshevBoundedField& operator=(ChebyshevBoundedField const&) = delete;
121  ChebyshevBoundedField& operator=(ChebyshevBoundedField&&) = delete;
122  ~ChebyshevBoundedField() override;
123 
135  ndarray::Array<double const, 1> const& x,
136  ndarray::Array<double const, 1> const& y,
137  ndarray::Array<double const, 1> const& z,
138  Control const& ctrl);
139 
153  ndarray::Array<double const, 1> const& x,
154  ndarray::Array<double const, 1> const& y,
155  ndarray::Array<double const, 1> const& z,
156  ndarray::Array<double const, 1> const& w,
157  Control const& ctrl);
158 
172  template <typename T>
173  static std::shared_ptr<ChebyshevBoundedField> fit(image::Image<T> const& image, Control const& ctrl);
174 
180  ndarray::Array<double const, 2, 2> getCoefficients() const { return _coefficients; }
181 
183  std::shared_ptr<ChebyshevBoundedField> truncate(Control const& ctrl) const;
184 
192 
194  double evaluate(lsst::geom::Point2D const& position) const override;
195 
197 
199  double integrate() const override;
200 
202  double mean() const override;
203 
205  bool isPersistable() const noexcept override { return true; }
206 
208  std::shared_ptr<BoundedField> operator*(double const scale) const override;
209 
211  bool operator==(BoundedField const& rhs) const override;
212 
213 protected:
214  std::string getPersistenceName() const override;
215 
216  std::string getPythonModule() const override;
217 
218  void write(OutputArchiveHandle& handle) const override;
219 
220 private:
221  // Internal constructor for fit() routines: just initializes the transform,
222  // leaves coefficients empty.
223  explicit ChebyshevBoundedField(lsst::geom::Box2I const& bbox);
224 
225  lsst::geom::AffineTransform _toChebyshevRange; // maps points from the bbox to [-1,1]x[-1,1]
226  ndarray::Array<double const, 2, 2> _coefficients; // shape=(orderY+1, orderX+1)
227 
228  std::string toString() const override;
229 };
230 } // namespace math
231 } // namespace afw
232 } // namespace lsst
233 
234 #endif // !LSST_AFW_MATH_ChebyshevBoundedField_h_INCLUDED
An object passed to Persistable::write to allow it to persist itself.
An affine coordinate transformation consisting of a linear transformation and an offset.
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109
A control object used when fitting ChebyshevBoundedField to data (see ChebyshevBoundedField::fit) ...
int y
Definition: SpanSet.cc:49
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition: config.h:36
STL class.
int computeSize() const
Return the number of nonzero coefficients in the Chebyshev function defined by this object...
int orderY
"maximum Chebyshev function order in y" ;
A base class for image defects.
Extent< int, N > truncate(Extent< double, N > const &input) noexcept
Return the component-wise truncation (round towards zero).
Definition: Extent.cc:100
table::Box2IKey bbox
Definition: Detector.cc:169
double x
bool triangular
"if true, only include terms where the sum of the x and y order " "is less than or equal to max(order...
double w
Definition: CoaddPsf.cc:69
bool isPersistable() const noexcept override
ChebyshevBoundedField is always persistable.
ndarray::Array< double const, 2, 2 > getCoefficients() const
Return the coefficient matrix.
A BoundedField based on 2-d Chebyshev polynomials of the first kind.
std::shared_ptr< BoundedField > operator*(double const scale, std::shared_ptr< BoundedField const > bf)
An abstract base class for 2-d functions defined on an integer bounding boxes.
Definition: BoundedField.h:55
virtual double evaluate(lsst::geom::Point2D const &position) const =0
Evaluate the field at the given point.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
An integer coordinate rectangle.
Definition: Box.h:54
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:59
UnaryFunctionT::result_type integrate(UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
The 1D integrator.
Definition: Integrate.h:886
ndarray::Array< double const, 2, 2 > coefficients
double z
Definition: Match.cc:44
int orderX
"maximum Chebyshev function order in x" ;