LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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 { namespace afw { namespace math {
34 
37 public:
38 
40 
41  LSST_CONTROL_FIELD(orderX, int, "maximum Chebyshev function order in x");
42 
43  LSST_CONTROL_FIELD(orderY, int, "maximum Chebyshev function order in y");
44 
46  triangular, bool,
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  );
50 
52  int computeSize() const;
53 
54 };
55 
70  public table::io::PersistableFacade<ChebyshevBoundedField>,
71  public BoundedField
72 {
73 public:
74 
76 
95  afw::geom::Box2I const & bbox,
97  );
98 
109  static PTR(ChebyshevBoundedField) fit(
110  afw::geom::Box2I const & bbox,
111  ndarray::Array<double const,1> const & x,
112  ndarray::Array<double const,1> const & y,
113  ndarray::Array<double const,1> const & z,
114  Control const & ctrl
115  );
116 
129  static PTR(ChebyshevBoundedField) fit(
130  afw::geom::Box2I const & bbox,
131  ndarray::Array<double const,1> const & x,
132  ndarray::Array<double const,1> const & y,
133  ndarray::Array<double const,1> const & z,
134  ndarray::Array<double const,1> const & w,
135  Control const & ctrl
136  );
137 
151  template <typename T>
152  static PTR(ChebyshevBoundedField) fit(
153  image::Image<T> const & image,
154  Control const & ctrl
155  );
156 
162  ndarray::Array<double const,2,2> getCoefficients() const { return _coefficients; }
163 
165  PTR(ChebyshevBoundedField) truncate(Control const & ctrl) const;
166 
173  PTR(ChebyshevBoundedField) relocate(geom::Box2I const & bbox) const;
174 
176  virtual double evaluate(geom::Point2D const & position) const;
177 
178  using BoundedField::evaluate;
179 
181  virtual bool isPersistable() const { return true; }
182 
184  virtual PTR(BoundedField) operator*(double const scale) const;
185 
186 protected:
187 
188  virtual std::string getPersistenceName() const;
189 
190  virtual std::string getPythonModule() const;
191 
192  virtual void write(OutputArchiveHandle & handle) const;
193 
194 private:
195 
196  // Internal constructor for fit() routines: just initializes the transform,
197  // leaves coefficients empty.
198  explicit ChebyshevBoundedField(afw::geom::Box2I const & bbox);
199 
200  geom::AffineTransform _toChebyshevRange; // maps points from the bbox to [-1,1]x[-1,1]
201  ndarray::Array<double const,2,2> _coefficients; // shape=(orderY+1, orderX+1)
202 };
203 
204 
205 }}} // namespace lsst::afw::math
206 
207 #endif // !LSST_AFW_MATH_ChebyshevBoundedField_h_INCLUDED
int y
int computeSize() const
Return the number of nonzero coefficients in the Chebyshev function defined by this object...
#define PTR(...)
Definition: base.h:41
virtual bool isPersistable() const
ChebyshevBoundedField is always persistable.
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
ChebyshevBoundedField(afw::geom::Box2I const &bbox, ndarray::Array< double const, 2, 2 > const &coefficients)
Initialize the field from its bounding box an coefficients.
A control object used when fitting ChebyshevBoundedField to data (see ChebyshevBoundedField::fit) ...
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:114
boost::shared_ptr< ChebyshevBoundedField > relocate(geom::Box2I const &bbox) const
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
Definition: config.h:36
An integer coordinate rectangle.
Definition: Box.h:53
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
double w
Definition: CoaddPsf.cc:57
boost::shared_ptr< ChebyshevBoundedField > truncate(Control const &ctrl) const
Return a new ChebyshevBoudedField with maximum orders set by the given control object.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
virtual double evaluate(geom::Point2D const &position) const
int x
ChebyshevBoundedFieldControl Control
A BoundedField based on 2-d Chebyshev polynomials of the first kind.
int orderX
&quot;maximum Chebyshev function order in x&quot; ;
int orderY
&quot;maximum Chebyshev function order in y&quot; ;
An abstract base class for 2-d functions defined on an integer bounding boxes.
Definition: BoundedField.h:49
ndarray::Array< double const, 2, 2 > _coefficients
Point< double, 2 > Point2D
Definition: Point.h:286
static boost::shared_ptr< ChebyshevBoundedField > fit(afw::geom::Box2I const &bbox, ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y, ndarray::Array< double const, 1 > const &z, Control const &ctrl)
Fit a Chebyshev approximation to non-gridded data with equal weights.
bool triangular
&quot;if true, only include terms where the sum of the x and y order &quot; &quot;is less than or equal to max(order...
ndarray::Array< double const, 2, 2 > coefficients
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:182
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
ndarray::Array< double const, 2, 2 > getCoefficients() const
Return the coefficient matrix.