LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
25 #ifndef LSST_AFW_MATH_KERNEL_H
26 #define LSST_AFW_MATH_KERNEL_H
31 #include <type_traits>
35 #include "boost/mpl/or.hpp"
141 explicit Kernel(
int width,
int height,
unsigned int nKernelParams,
208 double y = 0.0)
const;
216 _width = dims.getX();
217 _height = dims.getY();
219 inline void setWidth(
int width) { _width = width; }
242 [[deprecated(
"Use `getCtr` instead. To be removed after 20.0.0.")]]
253 [[deprecated(
"Use `getCtr` instead. To be removed after 20.0.0.")]]
346 [[deprecated(
"Use `setCtr` instead. To be removed after 20.0.0.")]]
358 [[deprecated(
"Use `setCtr` instead. To be removed after 20.0.0.")]]
372 spatialParams.
push_back((*spFuncIter)->getParameters());
374 return spatialParams;
393 if (nParams != params.
size()) {
395 (
boost::format(
"Number of parameters is wrong, saw %d expected %d") % nParams %
399 for (
unsigned int ii = 0; ii < nParams; ++ii) {
452 #if 0 // fails to compile with icc; is it actually used?
456 struct PersistenceHelper;
503 unsigned int _nKernelParams;
506 virtual void _setKernelXY() {}
655 double y = 0.0)
const;
884 void _setKernelList(
KernelList const &kernelList);
891 bool _isDeltaFunctionBasis;
978 double x = 0.0,
double y = 0.0)
const;
981 unsigned int const ncol = _kernelColFunctionPtr->
getNParameters();
1039 bool doNormalize)
const;
1053 virtual void _setKernelXY()
override {
1057 assert(dim[0] ==
static_cast<int>(_kernelX.
size()));
1058 for (
int i = 0; i != dim.getX(); ++i) {
1059 _kernelX[i] = i - ctr.getX();
1062 assert(dim[1] ==
static_cast<int>(_kernelY.
size()));
1063 for (
int i = 0; i != dim.getY(); ++i) {
1064 _kernelY[i] = i - ctr.getY();
1072 #endif // !defined(LSST_AFW_MATH_KERNEL_H)
AnalyticKernel & operator=(AnalyticKernel &&)=delete
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
SeparableKernel & operator=(const SeparableKernel &)=delete
int getNSpatialParameters() const
Return the number of spatial parameters (0 if not spatially varying)
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
LinearCombinationKernel()
Construct an empty LinearCombinationKernel of size 0x0.
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
table::Key< int > kernelFunction
A kernel that has only one non-zero pixel (of value 1)
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
~Kernel() override=default
AnalyticKernel & operator=(const AnalyticKernel &)=delete
int getHeight() const
Return the Kernel's height.
SeparableKernel()
Construct an empty spatially invariant SeparableKernel of size 0x0.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Kernel has only one non-zero pixel.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
afw::table::Key< int > cacheSize
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
LinearCombinationKernel & operator=(const LinearCombinationKernel &)=delete
lsst::geom::Point2I getPixel() const
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A kernel created from an Image.
FixedKernel(FixedKernel &&)=delete
KernelFunctionPtr getKernelRowFunction() const
Get a deep copy of the row kernel function.
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
void setHeight(int height)
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
FixedKernel(const FixedKernel &)=delete
int getCacheSize() const override
Get the current cache size (0 if none)
lsst::geom::Box2I growBBox(lsst::geom::Box2I const &bbox) const
Given a bounding box for pixels one wishes to compute by convolving an image with this kernel,...
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
~SeparableKernel() override=default
virtual double getKernelParameter(unsigned int i) const
Return a particular Kernel Parameter (no bounds checking).
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Kernel & operator=(Kernel &&)=delete
KernelFunctionPtr _kernelFunctionPtr
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
LinearCombinationKernel(const LinearCombinationKernel &)=delete
AnalyticKernel(AnalyticKernel &&)=delete
std::shared_ptr< KernelFunction > KernelFunctionPtr
lsst::afw::math::Function2< Pixel > KernelFunction
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Kernel(const Kernel &)=delete
lsst::afw::math::NullFunction2< double > NullSpatialFunction
std::shared_ptr< Kernel > refactor() const
Refactor the kernel as a linear combination of N bases where N is the number of parameters for the sp...
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
void setCtr(lsst::geom::Point2I ctr)
Set index of kernel's center.
AnalyticKernel(const AnalyticKernel &)=delete
FixedKernel()
Construct an empty FixedKernel of size 0x0.
virtual int getCacheSize() const
Get the current size of the kernel cache (0 if none or if caches not supported)
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const =0
Low-level version of computeImage.
KernelFunctionPtr getKernelColFunction() const
Get a deep copy of the col kernel function.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
A kernel that is a linear combination of fixed basis kernels.
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
DeltaFunctionKernel & operator=(DeltaFunctionKernel &&)=delete
int getNBasisKernels() const
Get the number of basis kernels.
virtual Pixel getSum() const
a class used in function calls to indicate that no Function2 is being provided
generic_kernel_tag kernel_fill_factor
bool isDeltaFunctionBasis() const
Return true if all basis kernels are instances of DeltaFunctionKernel.
LinearCombinationKernel(LinearCombinationKernel &&)=delete
void setCtrY(int ctrY)
Set y index of kernel's center.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
~DeltaFunctionKernel() override=default
~LinearCombinationKernel() override=default
DeltaFunctionKernel(const DeltaFunctionKernel &)=delete
Kernel & operator=(const Kernel &)=delete
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
SeparableKernel & operator=(SeparableKernel &&)=delete
std::vector< std::vector< double > > getSpatialParameters() const
Return the spatial parameters parameters (an empty vector if not spatially varying)
DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
int getCtrY() const
Return y index of kernel's center.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
lsst::geom::Box2I shrinkBBox(lsst::geom::Box2I const &bbox) const
Given a bounding box for an image one wishes to convolve with this kernel, return the bounding box fo...
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
int getWidth() const
Return the Kernel's width.
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
A base class for image defects.
std::shared_ptr< lsst::afw::math::Function2< Pixel > > KernelFunctionPtr
lsst::afw::math::Function1< Pixel > KernelFunction
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
double computeVectors(std::vector< Pixel > &colList, std::vector< Pixel > &rowList, bool doNormalize, double x=0.0, double y=0.0) const
Compute the column and row arrays in place, where kernel(col, row) = colList(col) * rowList(row)
std::vector< std::shared_ptr< Kernel > > KernelList
std::vector< SpatialFunctionPtr > _spatialFunctionList
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
A base class for objects that can be persisted via afw::table::io Archive classes.
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
DeltaFunctionKernel(DeltaFunctionKernel &&)=delete
A kernel described by a function.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
void setKernelParameters(std::pair< double, double > const ¶ms)
Set the kernel parameters of a 2-component spatially invariant kernel.
virtual KernelList const & getKernelList() const
Get the fixed basis kernels.
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
virtual std::vector< double > getKernelParameters() const
Return the current kernel parameters.
FixedKernel & operator=(const FixedKernel &)=delete
Reports invalid arguments.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
unsigned int getNParameters() const noexcept
Return the number of function parameters.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Extent< int, 2 > Extent2I
SeparableKernel(const SeparableKernel &)=delete
deltafunction_kernel_tag kernel_fill_factor
void checkKernelList(const KernelList &kernelList) const
Check that all kernels have the same size and center and that none are spatially varying.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
double getKernelParameter(unsigned int i) const override
Return a particular Kernel Parameter (no bounds checking).
AnalyticKernel()
Construct an empty spatially invariant AnalyticKernel of size 0x0.
A CRTP facade class for subclasses of Persistable.
lsst::afw::math::Function2< double > SpatialFunction
virtual void computeCache(int const)
Compute a cache of Kernel values, if desired.
An integer coordinate rectangle.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
DeltaFunctionKernel & operator=(const DeltaFunctionKernel &)=delete
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::vector< double > getKernelSumList() const
Get the sum of the pixels of each fixed basis kernel.
void setSpatialParameters(const std::vector< std::vector< double >> params)
Set the parameters of all spatial functions.
Kernels are used for convolution with MaskedImages and (eventually) Images.
void computeCache(int const cacheSize) override
Compute a cache of Kernel values, if desired.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::shared_ptr< lsst::afw::math::Function2< double > > SpatialFunctionPtr
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
void setKernelParameters(std::vector< double > const ¶ms)
Set the kernel parameters of a spatially invariant kernel.
std::vector< SpatialFunctionPtr > getSpatialFunctionList() const
Return a list of clones of the spatial functions.
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
A Function taking one argument.
Tags carrying information about Kernels Kernel with no special properties.
~FixedKernel() override=default
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
LinearCombinationKernel & operator=(LinearCombinationKernel &&)=delete
Kernel()
Construct a null Kernel of size 0,0.
virtual std::shared_ptr< Kernel > resized(int width, int height) const =0
Return a pointer to a clone with specified kernel dimensions.
FixedKernel & operator=(FixedKernel &&)=delete
io::OutputArchiveHandle OutputArchiveHandle
int getCtrX() const
Return x index of kernel's center.
~AnalyticKernel() override=default
unsigned int getNKernelParameters() const
Return the number of kernel parameters (0 if none)
virtual KernelFunctionPtr getKernelFunction() const
Get a deep copy of the kernel function.
void setCtrX(int ctrX)
Set x index of kernel's center.
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
SeparableKernel(SeparableKernel &&)=delete
void setDimensions(lsst::geom::Extent2I dims)
Reports errors that are due to events beyond the control of the program.
void computeKernelParametersFromSpatialModel(std::vector< double > &kernelParams, double x, double y) const
Compute the kernel parameters at a specified point.
SpatialFunctionPtr getSpatialFunction(unsigned int index) const
Return a clone of the specified spatial function (one component of the spatial model)