LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
|
A BoundedField based on 2-d Chebyshev polynomials of the first kind. More...
#include <ChebyshevBoundedField.h>
Public Types | |
using | Control = ChebyshevBoundedFieldControl |
Public Member Functions | |
ChebyshevBoundedField (lsst::geom::Box2I const &bbox, ndarray::Array< double const, 2, 2 > const &coefficients) | |
Initialize the field from its bounding box an coefficients. | |
ChebyshevBoundedField (ChebyshevBoundedField const &) | |
ChebyshevBoundedField (ChebyshevBoundedField &&) | |
ChebyshevBoundedField & | operator= (ChebyshevBoundedField const &)=delete |
ChebyshevBoundedField & | operator= (ChebyshevBoundedField &&)=delete |
~ChebyshevBoundedField () override | |
ndarray::Array< double const, 2, 2 > | getCoefficients () const |
Return the coefficient matrix. | |
std::shared_ptr< ChebyshevBoundedField > | truncate (Control const &ctrl) const |
Return a new ChebyshevBoudedField with maximum orders set by the given control object. | |
std::shared_ptr< ChebyshevBoundedField > | relocate (lsst::geom::Box2I const &bbox) const |
Return a new ChebyshevBoundedField with domain set to the given bounding box. | |
double | evaluate (lsst::geom::Point2D const &position) const override |
Evaluate the field at the given point. | |
double | integrate () const override |
Compute the integral of this function over its bounding-box. | |
double | mean () const override |
Compute the mean of this function over its bounding-box. | |
bool | isPersistable () const noexcept override |
ChebyshevBoundedField is always persistable. | |
std::shared_ptr< BoundedField > | operator* (double const scale) const override |
Return a scaled BoundedField. | |
bool | operator== (BoundedField const &rhs) const override |
BoundedFields (of the same sublcass) are equal if their bounding boxes and parameters are equal. | |
virtual double | evaluate (lsst::geom::Point2D const &position) const=0 |
Evaluate the field at the given point. | |
double | evaluate (double x, double y) const |
Evaluate the field at the given point. | |
virtual ndarray::Array< double, 1, 1 > | evaluate (ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y) const |
Evaluate the field at multiple arbitrary points. | |
lsst::geom::Box2I | getBBox () const |
Return the bounding box that defines the region where the field is valid. | |
template<typename T > | |
void | fillImage (image::Image< T > &image, bool overlapOnly=false, int xStep=1, int yStep=1) const |
Assign the field to an image, overwriting values already present. | |
template<typename T > | |
void | addToImage (image::Image< T > &image, double scaleBy=1.0, bool overlapOnly=false, int xStep=1, int yStep=1) const |
Add the field or a constant multiple of it to an image in-place. | |
template<typename T > | |
void | multiplyImage (image::Image< T > &image, bool overlapOnly=false, int xStep=1, int yStep=1) const |
Multiply an image by the field in-place. | |
template<typename T > | |
void | divideImage (image::Image< T > &image, bool overlapOnly=false, int xStep=1, int yStep=1) const |
Divide an image by the field in-place. | |
std::shared_ptr< BoundedField > | operator/ (double scale) const |
bool | operator!= (BoundedField const &rhs) const |
BoundedFields (of the same sublcass) are equal if their bounding boxes and parameters are equal. | |
void | writeFits (std::string const &fileName, std::string const &mode="w") const |
Write the object to a regular FITS file. | |
void | writeFits (fits::MemFileManager &manager, std::string const &mode="w") const |
Write the object to a FITS image in memory. | |
void | writeFits (fits::Fits &fitsfile) const |
Write the object to an already-open FITS object. | |
Static Public Member Functions | |
static std::shared_ptr< ChebyshevBoundedField > | fit (lsst::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. | |
static std::shared_ptr< ChebyshevBoundedField > | fit (lsst::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, ndarray::Array< double const, 1 > const &w, Control const &ctrl) |
Fit a Chebyshev approximation to non-gridded data with unequal weights. | |
template<typename T > | |
static std::shared_ptr< ChebyshevBoundedField > | fit (image::Image< T > const &image, Control const &ctrl) |
Fit a Chebyshev approximation to gridded data with equal weights. | |
static std::shared_ptr< ChebyshevBoundedField > | readFits (fits::Fits &fitsfile) |
Read an object from an already open FITS object. | |
static std::shared_ptr< ChebyshevBoundedField > | readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU) |
Read an object from a regular FITS file. | |
static std::shared_ptr< ChebyshevBoundedField > | readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU) |
Read an object from a FITS file in memory. | |
static std::shared_ptr< ChebyshevBoundedField > | dynamicCast (std::shared_ptr< Persistable > const &ptr) |
Dynamically cast a shared_ptr. | |
static std::shared_ptr< BoundedField > | readFits (fits::Fits &fitsfile) |
Read an object from an already open FITS object. | |
static std::shared_ptr< BoundedField > | readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU) |
Read an object from a regular FITS file. | |
static std::shared_ptr< BoundedField > | readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU) |
Read an object from a FITS file in memory. | |
static std::shared_ptr< BoundedField > | dynamicCast (std::shared_ptr< Persistable > const &ptr) |
Dynamically cast a shared_ptr. | |
Protected Types | |
using | OutputArchiveHandle = io::OutputArchiveHandle |
Protected Member Functions | |
std::string | getPersistenceName () const override |
Return the unique name used to persist this object and look up its factory. | |
std::string | getPythonModule () const override |
Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. | |
void | write (OutputArchiveHandle &handle) const override |
Write the object to one or more catalogs. | |
Private Member Functions | |
std::string | toString () const override |
A BoundedField based on 2-d Chebyshev polynomials of the first kind.
The 2-d Chebyshev polynomial used here is defined as:
\[ f(x,y) = \sum_i \sum_j a_{i,j} T_i(x) T_j(y) \]
where \(T_n(x)\) is the n-th order Chebyshev polynomial of \(x\) and \(a_{i,j}\) is the corresponding coefficient of the (i,j) polynomial term.
ChebyshevBoundedField supports fitting to gridded and non-gridded data, as well coefficient matrices with different x- and y-order.
There is currently quite a bit of duplication of functionality between ChebyshevBoundedField, ApproximateChebyshev, and Chebyshev1Function2; the intent is that ChebyshevBoundedField will ultimately replace ApproximateChebyshev and should be preferred over Chebyshev1Function2 when the parametrization interface that is part of the Function2 class is not needed.
Definition at line 76 of file ChebyshevBoundedField.h.
Definition at line 79 of file ChebyshevBoundedField.h.
|
protectedinherited |
Definition at line 108 of file Persistable.h.
lsst::afw::math::ChebyshevBoundedField::ChebyshevBoundedField | ( | lsst::geom::Box2I const & | bbox, |
ndarray::Array< double const, 2, 2 > const & | coefficients ) |
Initialize the field from its bounding box an coefficients.
This constructor is mostly intended for testing purposes and persistence, but it also provides a way to initialize the object from Chebyshev coefficients derived from some external source.
Note that because the bounding box provided is always an integer bounding box, and LSST convention puts the center of each pixel at an integer, the actual floating-point domain of the Chebyshev functions is lsst::geom::Box2D(bbox), that is, the box that contains the entirety of all the pixels included in the integer bounding box.
The coefficients are ordered [y,x], so the shape is (orderY+1, orderX+1), and the arguments to the Chebyshev functions are transformed such that the region lsst::geom::Box2D(bbox) is mapped to [-1, 1]x[-1, 1].
Example:
bbox = lsst::geom::Box2I(lsst::geom::Point2I(10, 20), lsst::geom::Point2I(30, 40)); ndarray::Array<double, 2, 2> coeffs = ndarray::allocate(ndarray::makeVector(2, 2)); coeffs[0][0] = 1; coeffs[1][0] = 2; coeffs[0][1] = 3; coeffs[1][1] = 4; ndarray::Array<double, 2, 2> coeffs = ndarray::external(data); poly = ChebyshevBoundedField(bbox, coeffs);
will result in the following polynomial:
\[ f(x,y) = 1 T_0(x) T_0(y) + 2 T_0(x) T_1(y) + 3 T_1(x) T_0(y) + 4 T_1(x) T_1(y) \]
Definition at line 59 of file ChebyshevBoundedField.cc.
|
default |
|
default |
|
overridedefault |
|
inherited |
Add the field or a constant multiple of it to an image in-place.
[out] | image | Image to add to. |
[in] | scaleBy | Multiply the field by this before adding it to the image. |
[in] | overlapOnly | If true, only modify the region in the intersection of image.getBBox(image::PARENT) and this->getBBox(). |
[in] | xStep | Distance between grid points in X to evaluate; values between grid points will be linearly interpolated. |
[in] | yStep | Distance between grid points in Y to evaluate; values between grid points will be linearly interpolated. |
pex::exceptions::RuntimeError | if the bounding boxes do not overlap and overlapOnly=false. |
Definition at line 264 of file BoundedField.cc.
|
inherited |
Divide an image by the field in-place.
[out] | image | Image to fill. |
[in] | overlapOnly | If true, only modify the region in the intersection of image.getBBox(image::PARENT) and this->getBBox(). |
[in] | xStep | Distance between grid points in X to evaluate; values between grid points will be linearly interpolated. |
[in] | yStep | Distance between grid points in Y to evaluate; values between grid points will be linearly interpolated. |
pex::exceptions::RuntimeError | if the bounding boxes do not overlap and overlapOnly=false. |
Definition at line 275 of file BoundedField.cc.
|
staticinherited |
Dynamically cast a shared_ptr.
Dynamically cast a shared pointer and raise on failure.
You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;
lsst::pex::exceptions::LogicError | if the cast fails |
param[in] ptr The pointer to be cast.
lsst::pex::exceptions::TypeError | If the dynamic cast fails. |
Definition at line 218 of file Persistable.cc.
|
staticinherited |
Dynamically cast a shared_ptr.
Dynamically cast a shared pointer and raise on failure.
You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;
lsst::pex::exceptions::LogicError | if the cast fails |
param[in] ptr The pointer to be cast.
lsst::pex::exceptions::TypeError | If the dynamic cast fails. |
Definition at line 218 of file Persistable.cc.
|
inline |
Evaluate the field at the given point.
This delegates to the evaluate() method that takes lsst::geom::Point2D.
There is no bounds-checking on the given position; this is the responsibility of the user, who can almost always do it more efficiently.
Definition at line 75 of file BoundedField.h.
|
overridevirtual |
Evaluate the field at the given point.
This is the only abstract method to be implemented by subclasses.
Subclasses should not provide bounds checking on the given position; this is the responsibility of the user, who can almost always do it more efficiently.
Implements lsst::afw::math::BoundedField.
Definition at line 281 of file ChebyshevBoundedField.cc.
|
virtual |
Evaluate the field at the given point.
This is the only abstract method to be implemented by subclasses.
Subclasses should not provide bounds checking on the given position; this is the responsibility of the user, who can almost always do it more efficiently.
Implements lsst::afw::math::BoundedField.
|
virtual |
Evaluate the field at multiple arbitrary points.
[in] | x | array of x coordinates, same shape as y |
[in] | y | array of y coordinates, same shape as x |
There is no bounds-checking on the given positions; this is the responsibility of the user, who can almost always do it more efficiently.
Reimplemented from lsst::afw::math::BoundedField.
Definition at line 87 of file BoundedField.cc.
|
inherited |
Assign the field to an image, overwriting values already present.
[out] | image | Image to fill. |
[in] | overlapOnly | If true, only modify the region in the intersection of image.getBBox(image::PARENT) and this->getBBox(). |
[in] | xStep | Distance between grid points in X to evaluate; values between grid points will be linearly interpolated. |
[in] | yStep | Distance between grid points in Y to evaluate; values between grid points will be linearly interpolated. |
pex::exceptions::RuntimeError | if the bounding boxes do not overlap and overlapOnly=false. |
Definition at line 259 of file BoundedField.cc.
|
static |
Fit a Chebyshev approximation to gridded data with equal weights.
[in] | image | The Image containing the data to fit. image.getBBox(PARENT) is used as the bounding box of the BoundedField. |
[in] | ctrl | Specifies the orders and triangularity of the coefficient matrix. |
Instantiated for float and double.
Definition at line 193 of file ChebyshevBoundedField.cc.
|
static |
Fit a Chebyshev approximation to non-gridded data with equal weights.
[in] | bbox | Integer bounding box of the resulting approximation. All given points must lie within lsst::geom::Box2D(bbox). |
[in] | x | Array of x coordinate values. |
[in] | y | Array of y coordinate values. |
[in] | z | Array of field values to be fit at each (x,y) point. |
[in] | ctrl | Specifies the orders and triangularity of the coefficient matrix. |
Definition at line 148 of file ChebyshevBoundedField.cc.
|
static |
Fit a Chebyshev approximation to non-gridded data with unequal weights.
[in] | bbox | Integer bounding box of the resulting approximation. All given points must lie within lsst::geom::Box2D(bbox). |
[in] | x | Array of x coordinate values. |
[in] | y | Array of y coordinate values. |
[in] | z | Array of field values to be fit at each (x,y) point. |
[in] | w | Array of weights for each point in the fit. For points with Gaussian noise, w = 1/sigma. |
[in] | ctrl | Specifies the orders and triangularity of the coefficient matrix. |
Definition at line 167 of file ChebyshevBoundedField.cc.
|
inlineinherited |
Return the bounding box that defines the region where the field is valid.
Because this is an integer bounding box, its minimum and maximum positions are the centers of the pixels where the field is valid, but the field can be assumed to be valid to the edges of those pixels, which is the boundary you'd get by converting the returned lsst::geom::Box2I into a lsst::geom::Box2D.
Definition at line 112 of file BoundedField.h.
|
inline |
Return the coefficient matrix.
The coefficients are ordered [y,x], so the shape is (orderY+1, orderX+1).
Definition at line 180 of file ChebyshevBoundedField.h.
|
overrideprotectedvirtual |
Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 357 of file ChebyshevBoundedField.cc.
|
overrideprotectedvirtual |
Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.
Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.
Will be ignored if empty.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 361 of file ChebyshevBoundedField.cc.
|
overridevirtual |
Compute the integral of this function over its bounding-box.
Reimplemented from lsst::afw::math::BoundedField.
Definition at line 296 of file ChebyshevBoundedField.cc.
|
inlineoverridevirtualnoexcept |
ChebyshevBoundedField is always persistable.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 205 of file ChebyshevBoundedField.h.
|
overridevirtual |
Compute the mean of this function over its bounding-box.
Reimplemented from lsst::afw::math::BoundedField.
Definition at line 307 of file ChebyshevBoundedField.cc.
|
inherited |
Multiply an image by the field in-place.
[out] | image | Image to fill. |
[in] | overlapOnly | If true, only modify the region in the intersection of image.getBBox(image::PARENT) and this->getBBox(). |
[in] | xStep | Distance between grid points in X to evaluate; values between grid points will be linearly interpolated. |
[in] | yStep | Distance between grid points in Y to evaluate; values between grid points will be linearly interpolated. |
pex::exceptions::RuntimeError | if the bounding boxes do not overlap and overlapOnly=false. |
Definition at line 270 of file BoundedField.cc.
|
inlineinherited |
BoundedFields (of the same sublcass) are equal if their bounding boxes and parameters are equal.
Definition at line 195 of file BoundedField.h.
|
overridevirtual |
Return a scaled BoundedField.
[in] | scale | Scaling factor |
Implements lsst::afw::math::BoundedField.
Definition at line 375 of file ChebyshevBoundedField.cc.
|
inlineinherited |
Definition at line 190 of file BoundedField.h.
|
delete |
|
delete |
|
overridevirtual |
BoundedFields (of the same sublcass) are equal if their bounding boxes and parameters are equal.
Implements lsst::afw::math::BoundedField.
Definition at line 379 of file ChebyshevBoundedField.cc.
|
inlinestaticinherited |
Read an object from an already open FITS object.
[in] | fitsfile | FITS object to read from, already positioned at the desired HDU. |
Definition at line 183 of file Persistable.h.
|
inlinestaticinherited |
Read an object from an already open FITS object.
[in] | fitsfile | FITS object to read from, already positioned at the desired HDU. |
Definition at line 183 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a FITS file in memory.
[in] | manager | Manager for the memory to read from. |
[in] | hdu | HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty. |
Definition at line 205 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a FITS file in memory.
[in] | manager | Manager for the memory to read from. |
[in] | hdu | HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty. |
Definition at line 205 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a regular FITS file.
[in] | fileName | Name of the file to read. |
[in] | hdu | HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty. |
Definition at line 194 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a regular FITS file.
[in] | fileName | Name of the file to read. |
[in] | hdu | HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty. |
Definition at line 194 of file Persistable.h.
std::shared_ptr< ChebyshevBoundedField > lsst::afw::math::ChebyshevBoundedField::relocate | ( | lsst::geom::Box2I const & | bbox | ) | const |
Return a new ChebyshevBoundedField with domain set to the given bounding box.
Because this leaves the coefficients unchanged, it is equivalent to transforming the function by the affine transform that maps the old box to the new one.
Definition at line 239 of file ChebyshevBoundedField.cc.
|
overrideprivatevirtual |
Implements lsst::afw::math::BoundedField.
Definition at line 388 of file ChebyshevBoundedField.cc.
std::shared_ptr< ChebyshevBoundedField > lsst::afw::math::ChebyshevBoundedField::truncate | ( | Control const & | ctrl | ) | const |
Return a new ChebyshevBoudedField with maximum orders set by the given control object.
Definition at line 215 of file ChebyshevBoundedField.cc.
|
overrideprotectedvirtual |
Write the object to one or more catalogs.
The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 363 of file ChebyshevBoundedField.cc.
|
inherited |
Write the object to an already-open FITS object.
[in] | fitsfile | Open FITS object to write to. |
Definition at line 18 of file Persistable.cc.
|
inherited |
Write the object to a FITS image in memory.
[in] | manager | Name of the file to write to. |
[in] | mode | If "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file. |
Definition at line 29 of file Persistable.cc.
|
inherited |
Write the object to a regular FITS file.
[in] | fileName | Name of the file to write to. |
[in] | mode | If "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file. |
Definition at line 24 of file Persistable.cc.