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
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
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
def write(self, patchRef, catalog)
Write the output.
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
double z
Definition: Match.cc:44
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
Definition: config.h:43
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
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:55
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
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
int orderX
"maximum Chebyshev function order in x" ;