File FunctionLibrary.h¶
-
namespace
lsst
Class for a simple mapping implementing a generic AstrometryTransform.
Remove all non-astronomical counts from the Chunk Exposure’s pixels.
Forward declarations for lsst::utils::Cache
For details on the Cache class, see the Cache.h file.
It uses a template rather than a pointer so that the derived classes can use the specifics of the transform. The class simplePolyMapping overloads a few routines.
A base class for image defects
Numeric constants used by the Integrate.h integrator routines.
Compute Image Statistics
- Note
Gauss-Kronrod-Patterson quadrature coefficients for use in quadpack routine qng. These coefficients were calculated with 101 decimal digit arithmetic by L. W. Fullerton, Bell Labs, Nov 1981.
- Note
The Statistics class itself can only handle lsst::afw::image::MaskedImage() types. The philosophy has been to handle other types by making them look like lsst::afw::image::MaskedImage() and reusing that code. Users should have no need to instantiate a Statistics object directly, but should use the overloaded makeStatistics() factory functions.
-
namespace
afw
-
namespace
math
-
template<typename
ReturnT
>
classChebyshev1Function1
: public lsst::afw::math::Function1<ReturnT> - #include <FunctionLibrary.h>
1-dimensional weighted sum of Chebyshev polynomials of the first kind.
f(x) = c0 T0(x’) + c1 T1(x’) + c2 T2(x’) + … = c0 + c1 T1(x’) + c2 T2(x’) + … where:
Tn(x) is the nth Chebyshev function of the first kind: T0(x) = 1 T1(x) = 2 Tn+1(x) = 2xTn(x) + Tn-1(x)
x’ is x offset and scaled to range [-1, 1] as x ranges over [minX, maxX]
The function argument must be in the range [minX, maxX].
Public Functions
-
Chebyshev1Function1
(unsigned int order, double minX = -1, double maxX = 1) - Parameters
order
: order of polynomial (0 for constant)minX
: minimum allowed xmaxX
: maximum allowed x
Construct a Chebyshev polynomial of specified order and range.
The parameters are initialized to zero.
-
Chebyshev1Function1
(std::vector<double> params, double minX = -1, double maxX = 1) - Parameters
params
: polynomial coefficientsminX
: minimum allowed xmaxX
: maximum allowed x
Construct a Chebyshev polynomial with specified parameters and range.
The order of the polynomial is set to the length of the params vector.
- Exceptions
lsst::pex::exceptions::InvalidParameterError
: if params is empty
-
Chebyshev1Function1
(Chebyshev1Function1 const&)
-
Chebyshev1Function1
(Chebyshev1Function1&&)
-
Chebyshev1Function1 &
operator=
(Chebyshev1Function1 const&)
-
Chebyshev1Function1 &
operator=
(Chebyshev1Function1&&)
-
~Chebyshev1Function1
()
-
std::shared_ptr<Function1<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every concrete subclass must override this method.
- Return
a pointer to a deep copy of the function
-
double
getMinX
() const Get minimum allowed x
-
double
getMaxX
() const Get maximum allowed x
-
unsigned int
getOrder
() const Get the polynomial order
-
bool
isLinearCombination
() const Is the function a linear combination of its parameters?
- Return
true if the function can be expressed as: sum over i of parameter_i * function_i(args)
- Warning
: subclasses must override if true.
-
ReturnT
operator()
(double x) const
Protected Functions
-
Chebyshev1Function1
()
Private Functions
-
void
_initialize
(double minX, double maxX)¶ initialize private constants
-
template<typename
ReturnT
>
classChebyshev1Function2
: public lsst::afw::math::BasePolynomialFunction2<ReturnT> - #include <FunctionLibrary.h>
2-dimensional weighted sum of Chebyshev polynomials of the first kind.
f(x,y) = c0 T0(x’) T0(y’) # order 0
c1 T1(x’) T0(y’) + c2 T0(x’) T1(y’) # order 1
c3 T2(x’) T0(y’) + c4 T1(x’) T1(y’) + c5 T0(x’) T2(y’) # order 2
…
= c0 # order 0
c1 T1(x’) + c2 T1(y’) # order 1
c3 T2(x’) + c4 T1(x’) T1(y’) + c5 T2(y’) # order 2
…
where:
Tn(x) is the nth Chebyshev function of the first kind: T0(x) = 1 T1(x) = x Tn+1(x) = 2xTn(x) + Tn-1(x)
x’ is x offset and scaled to range [-1, 1] as x ranges over [minX, maxX]
y’ is y offset and scaled to range [-1, 1] as y ranges over [minY, maxY]
Return value is incorrect if function arguments are not in the range [minX, maxX], [minY, maxY].
Public Functions
-
Chebyshev1Function2
(unsigned int order, lsst::geom::Box2D const &xyRange = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, ), )) - Parameters
order
: order of polynomial (0 for constant)xyRange
: allowed x,y range
Construct a Chebyshev polynomial of specified order and range.
The parameters are initialized to zero.
-
Chebyshev1Function2
(std::vector<double> params, lsst::geom::Box2D const &xyRange = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, ), )) - Parameters
params
: polynomial coefficients length must be one of 1, 3, 6, 10, 15…xyRange
: allowed x,y range
Construct a Chebyshev polynomial with specified parameters and range.
The order of the polynomial is set to the length of the params vector.
- Exceptions
lsst::pex::exceptions::InvalidParameterError
: if params is empty
-
Chebyshev1Function2
(Chebyshev1Function2 const&)
-
Chebyshev1Function2
(Chebyshev1Function2&&)
-
Chebyshev1Function2 &
operator=
(Chebyshev1Function2 const&)
-
Chebyshev1Function2 &
operator=
(Chebyshev1Function2&&)
-
~Chebyshev1Function2
()
-
std::shared_ptr<Function2<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every non-virtual function must override this method.
- Return
a pointer to a deep copy of the function
-
lsst::geom::Box2D
getXYRange
() const Get x,y range
-
virtual Chebyshev1Function2
truncate
(int truncOrder) const - Parameters
truncOrder
: order of truncated polynomial
Return a truncated copy of lower (or equal) order
- Exceptions
lsst::pex::exceptions::InvalidParameter
: if truncated order > original order
-
ReturnT
operator()
(double x, double y) const
-
std::string
toString
(std::string const&) const Return a string representation of the function
- Return
a string representation of the function
-
bool
isPersistable
() const Return true if this particular object can be persisted using afw::table::io.
Protected Functions
-
std::string
getPersistenceName
() const Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
-
void
write
(afw::table::io::OutputArchiveHandle &handle) const 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.
-
Chebyshev1Function2
()
Private Members
-
double
_oldYPrime
¶
-
double
_minX
¶ minimum allowed x
-
double
_minY
¶ minimum allowed y
-
double
_maxX
¶ maximum allowed x
-
double
_maxY
¶ maximum allowed y
-
double
_scaleX
¶ x’ = (x + _offsetX) * _scaleX
-
double
_scaleY
¶ y’ = (y + _offsetY) * _scaleY
-
double
_offsetX
¶ x’ = (x + _offsetX) * _scaleX
-
double
_offsetY
¶ y’ = (y + _offsetY) * _scaleY
-
template<typename
ReturnT
>
classDoubleGaussianFunction2
: public lsst::afw::math::Function2<ReturnT> - #include <FunctionLibrary.h>
double Guassian (sum of two Gaussians)
Intended for use as a PSF model: the main Gaussian represents the core and the second Gaussian represents the wings.
f(x,y) = A (e^(-r^2 / 2 sigma1^2) + ampl2 e^(-r^2 / 2 sigma2^2)) where:
A = 1 / (2 pi (sigma1^2 + ampl2 sigma2^2))
r^2 = x^2 + y^2 coefficients c[0] = sigma1, c[1] = sigma2, c[2] = ampl2
Public Functions
-
DoubleGaussianFunction2
(double sigma1, double sigma2 = 0, double ampl2 = 0) - Parameters
sigma1
: sigma of main Gaussiansigma2
: sigma of second Gaussianampl2
: amplitude of second Gaussian as a fraction of main Gaussian at peak
Construct a Gaussian function with specified x and y sigma
-
DoubleGaussianFunction2
(DoubleGaussianFunction2 const&)
-
DoubleGaussianFunction2
(DoubleGaussianFunction2&&)
-
DoubleGaussianFunction2 &
operator=
(DoubleGaussianFunction2 const&)
-
DoubleGaussianFunction2 &
operator=
(DoubleGaussianFunction2&&)
-
~DoubleGaussianFunction2
()
-
std::shared_ptr<Function2<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every non-virtual function must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x, double y) const
-
std::string
toString
(std::string const&) const Return a string representation of the function
- Return
a string representation of the function
-
bool
isPersistable
() const Return true if this particular object can be persisted using afw::table::io.
Protected Functions
-
std::string
getPersistenceName
() const Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
-
void
write
(afw::table::io::OutputArchiveHandle &handle) const 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.
-
DoubleGaussianFunction2
()
Private Members
-
const double
_multFac
¶ precomputed scale factor
-
template<typename
ReturnT
>
classGaussianFunction1
: public lsst::afw::math::Function1<ReturnT> - #include <FunctionLibrary.h>
1-dimensional Gaussian
f(x) = A e^(-x^2 / 2 sigma^2) where:
A = 1 / (sqrt(2 pi) xSigma) coefficient c0 = sigma
Public Functions
-
GaussianFunction1
(double sigma) - Parameters
sigma
: sigma
Construct a Gaussian function with specified sigma
-
GaussianFunction1
(GaussianFunction1 const&)
-
GaussianFunction1
(GaussianFunction1&&)
-
GaussianFunction1 &
operator=
(GaussianFunction1 const&)
-
GaussianFunction1 &
operator=
(GaussianFunction1&&)
-
~GaussianFunction1
()
-
std::shared_ptr<Function1<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every concrete subclass must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x) const
Protected Functions
-
GaussianFunction1
()
Private Members
-
const double
_multFac
¶ precomputed scale factor
-
template<typename
ReturnT
>
classGaussianFunction2
: public lsst::afw::math::Function2<ReturnT> - #include <FunctionLibrary.h>
2-dimensional Gaussian
f(x,y) = A e^((-pos1^2 / 2 sigma1^2) - (pos2^2 / 2 sigma2^2)) where:
A = 1 / (2 pi sigma1 sigma2)
pos1 = cos(angle) x + sin(angle) y
pos2 = -sin(angle) x + cos(angle) y coefficients c0 = sigma1, c1 = sigma2, c2 = angle
- Note
if sigma1 > sigma2 then angle is the angle of the major axis
Public Functions
-
GaussianFunction2
(double sigma1, double sigma2, double angle = 0.0) - Parameters
sigma1
: sigma along the pos1 axissigma2
: sigma along the pos2 axisangle
: angle of pos1 axis, in rad (along x=0, y=pi/2)
Construct a 2-dimensional Gaussian function
-
GaussianFunction2
(GaussianFunction2 const&)
-
GaussianFunction2
(GaussianFunction2&&)
-
GaussianFunction2 &
operator=
(GaussianFunction2 const&)
-
GaussianFunction2 &
operator=
(GaussianFunction2&&)
-
~GaussianFunction2
()
-
std::shared_ptr<Function2<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every non-virtual function must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x, double y) const
-
std::string
toString
(std::string const&) const Return a string representation of the function
- Return
a string representation of the function
-
bool
isPersistable
() const Return true if this particular object can be persisted using afw::table::io.
Protected Functions
-
std::string
getPersistenceName
() const Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
-
void
write
(afw::table::io::OutputArchiveHandle &handle) const 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.
-
GaussianFunction2
()
Private Functions
-
void
_updateCache
() const¶ Update cached values
sin(angle) and cos(angle) are cached to speed computation and angle is cached so one can check if an update is required
The current design is to have operator() update the cache if needed. An alternate design is to update the cache when the parameters are set, not test in operator(). The main advantage to updating in operator() is safety and simplicity. The test is performed in one place, and it is the place where it matters the most. In contrast, there are multiple member functions to set parameters, and all must be overloaded to update the cache; miss one and the function silently misbehaves. There are trade-offs, of course. Testing the cache in operator() slows down operator() slightly. The overhead is small, but the function is typically evaulated more often than its parameters are changed.
-
template<typename
ReturnT
>
classIntegerDeltaFunction1
: public lsst::afw::math::Function1<ReturnT> - #include <FunctionLibrary.h>
1-dimensional integer delta function.
f(x) = 1 if x == xo, 0 otherwise.
For use as a kernel function be sure to handle the offset for row and column center; see examples/deltaFunctionKernel for an example.
Public Functions
-
IntegerDeltaFunction1
(double xo) Construct an integer delta function with specified xo
-
IntegerDeltaFunction1
(IntegerDeltaFunction1 const&)
-
IntegerDeltaFunction1
(IntegerDeltaFunction1&&)
-
IntegerDeltaFunction1 &
operator=
(IntegerDeltaFunction1 const&)
-
IntegerDeltaFunction1 &
operator=
(IntegerDeltaFunction1&&)
-
~IntegerDeltaFunction1
()
-
std::shared_ptr<Function1<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every concrete subclass must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x) const
Protected Functions
-
IntegerDeltaFunction1
()
Private Members
-
double
_xo
¶
-
-
template<typename
ReturnT
>
classIntegerDeltaFunction2
: public lsst::afw::math::Function2<ReturnT> - #include <FunctionLibrary.h>
2-dimensional integer delta function.
f(x) = 1 if x == xo and y == yo, 0 otherwise.
For use as a kernel function be sure to handle the offset for row and column center; see examples/deltaFunctionKernel for an example.
Public Functions
-
IntegerDeltaFunction2
(double xo, double yo) Construct an integer delta function with specified xo, yo
-
IntegerDeltaFunction2
(IntegerDeltaFunction2 const&)
-
IntegerDeltaFunction2
(IntegerDeltaFunction2&&)
-
IntegerDeltaFunction2 &
operator=
(IntegerDeltaFunction2 const&)
-
IntegerDeltaFunction2 &
operator=
(IntegerDeltaFunction2&&)
-
~IntegerDeltaFunction2
()
-
std::shared_ptr<Function2<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every non-virtual function must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x, double y) const
Protected Functions
-
IntegerDeltaFunction2
()
-
-
template<typename
ReturnT
>
classLanczosFunction1
: public lsst::afw::math::Function1<ReturnT> - #include <FunctionLibrary.h>
1-dimensional Lanczos function
f(x) = sinc(pi x’) sinc(pi x’ / n) where x’ = x - xOffset and coefficient c0 = xOffset
Warning: the Lanczos function is sometimes forced to 0 if |x’| > n but this implementation does not perform that truncation so as to improve Lanczos kernels.
Public Functions
-
LanczosFunction1
(unsigned int n, double xOffset = 0.0) - Parameters
n
: order of Lanczos functionxOffset
: x offset
Construct a Lanczos function of specified order and x,y offset.
-
LanczosFunction1
(LanczosFunction1 const&)
-
LanczosFunction1
(LanczosFunction1&&)
-
LanczosFunction1 &
operator=
(LanczosFunction1 const&)
-
LanczosFunction1 &
operator=
(LanczosFunction1&&)
-
~LanczosFunction1
()
-
std::shared_ptr<Function1<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every concrete subclass must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x) const
-
unsigned int
getOrder
() const Get the order of the Lanczos function
Protected Functions
-
LanczosFunction1
()
Private Members
-
double
_invN
¶
-
-
template<typename
ReturnT
>
classLanczosFunction2
: public lsst::afw::math::Function2<ReturnT> - #include <FunctionLibrary.h>
2-dimensional separable Lanczos function
f(x, y) = sinc(pi x’) sinc(pi x’ / n) sinc(pi y’) sinc(pi y’ / n) where x’ = x - xOffset and y’ = y - yOffset and coefficients c0 = xOffset, c1 = yOffset
- Warning
the Lanczos function is sometimes forced to 0 if |x’| > n or |y’| > n but this implementation does not perform that truncation so as to improve Lanczos kernels.
Public Functions
-
LanczosFunction2
(unsigned int n, double xOffset = 0.0, double yOffset = 0.0) - Parameters
n
: order of Lanczos functionxOffset
: x offsetyOffset
: y offset
Construct a Lanczos function of specified order and x,y offset.
-
LanczosFunction2
(LanczosFunction2 const&)
-
LanczosFunction2
(LanczosFunction2&&)
-
LanczosFunction2 &
operator=
(LanczosFunction2 const&)
-
LanczosFunction2 &
operator=
(LanczosFunction2&&)
-
~LanczosFunction2
()
-
std::shared_ptr<Function2<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every non-virtual function must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x, double y) const
-
unsigned int
getOrder
() const Get the order of Lanczos function
Protected Functions
-
LanczosFunction2
()
Private Members
-
double
_invN
¶ 1/n
-
template<typename
ReturnT
>
classPolynomialFunction1
: public lsst::afw::math::Function1<ReturnT> - #include <FunctionLibrary.h>
1-dimensional polynomial function.
f(x) = c0 + c1 x + c2 x^2 + … cn-1 x^(n-1)
Public Functions
-
PolynomialFunction1
(unsigned int order) - Parameters
order
: order of polynomial (0 for constant)
Construct a polynomial function of the specified order.
The parameters are initialized to zero.
-
PolynomialFunction1
(std::vector<double> params) - Parameters
params
: polynomial coefficients (const, x, x^2…)
Construct a polynomial function with the specified parameters.
The order of the polynomial is set to the length of the params vector.
- Exceptions
lsst::pex::exceptions::InvalidParameter
: if params is empty
-
PolynomialFunction1
(PolynomialFunction1 const&)
-
PolynomialFunction1
(PolynomialFunction1&&)
-
PolynomialFunction1 &
operator=
(PolynomialFunction1 const&)
-
PolynomialFunction1 &
operator=
(PolynomialFunction1&&)
-
~PolynomialFunction1
()
-
std::shared_ptr<Function1<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every concrete subclass must override this method.
- Return
a pointer to a deep copy of the function
-
bool
isLinearCombination
() const Is the function a linear combination of its parameters?
- Return
true if the function can be expressed as: sum over i of parameter_i * function_i(args)
- Warning
: subclasses must override if true.
-
ReturnT
operator()
(double x) const
-
unsigned int
getOrder
() const Get the polynomial order
Protected Functions
-
PolynomialFunction1
()
-
-
template<typename
ReturnT
>
classPolynomialFunction2
: public lsst::afw::math::BasePolynomialFunction2<ReturnT> - #include <FunctionLibrary.h>
2-dimensional polynomial function with cross terms
f(x,y) = c0 (0th order)
c1 x + c2 y (1st order)
c3 x^2 + c4 x y + c5 y^2 (2nd order)
c6 x^3 + c7 x^2 y + c8 x y^2 + c9 y^3 (3rd order)
…
Intermediate products for the most recent y are cached, so when computing for a set of x, y it is more efficient to change x before you change y.
Public Functions
-
PolynomialFunction2
(unsigned int order) - Parameters
order
: order of polynomial (0 for constant)
Construct a polynomial function of specified order.
The polynomial will have (order + 1) * (order + 2) / 2 coefficients
The parameters are initialized to zero.
-
PolynomialFunction2
(std::vector<double> params) - Parameters
params
: polynomial coefficients (const, x, y, x^2, xy, y^2…); length must be one of 1, 3, 6, 10, 15…
Construct a polynomial function with specified parameters.
The order of the polynomial is determined from the length of the params vector: order = (sqrt(1 + 8 * length) - 3) / 2 and if this is not an integer then the length is unsuitable
- Exceptions
lsst::pex::exceptions::InvalidParameterError
: if params length is unsuitablelsst::pex::exceptions::Exception
: if an internal sanity check fails
-
PolynomialFunction2
(PolynomialFunction2 const&)
-
PolynomialFunction2
(PolynomialFunction2&&)
-
PolynomialFunction2 &
operator=
(PolynomialFunction2 const&)
-
PolynomialFunction2 &
operator=
(PolynomialFunction2&&)
-
~PolynomialFunction2
()
-
std::shared_ptr<Function2<ReturnT>>
clone
() const Return a pointer to a deep copy of this function
This function exists instead of a copy constructor so one can obtain a copy of an actual function instead of a useless copy of the base class.
Every non-virtual function must override this method.
- Return
a pointer to a deep copy of the function
-
ReturnT
operator()
(double x, double y) const
-
std::vector<double>
getDFuncDParameters
(double x, double y) const Return the coefficients of the Function’s parameters, evaluated at (x, y) I.e. given c0, c1, c2, c3 … return 1, x, y, x^2 …
-
std::string
toString
(std::string const&) const Return a string representation of the function
- Return
a string representation of the function
-
bool
isPersistable
() const Return true if this particular object can be persisted using afw::table::io.
Protected Functions
-
std::string
getPersistenceName
() const Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
-
void
write
(afw::table::io::OutputArchiveHandle &handle) const 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.
-
PolynomialFunction2
()
-
template<typename
-
namespace