26#include "boost/format.hpp"
49Kernel::Kernel() : _spatialFunctionList(), _width(0), _height(0), _ctrX(0), _ctrY(0), _nKernelParams(0) {}
52 : _spatialFunctionList(),
55 _ctrX((width - 1) / 2),
56 _ctrY((height - 1) / 2),
57 _nKernelParams(nKernelParams) {
58 if ((width < 1) || (height < 1)) {
60 os <<
"kernel height = " << height <<
" and/or width = " << width <<
" < 1";
66 if (nKernelParams == 0) {
69 for (
unsigned int ii = 0; ii < nKernelParams; ++ii) {
77 if (
image.getDimensions() != this->getDimensions()) {
79 os <<
"image dimensions = ( " <<
image.getWidth() <<
", " <<
image.getHeight() <<
") != ("
83 image.setXY0(-_ctrX, -_ctrY);
95 _nKernelParams(spatialFunctionList.size()) {
96 if ((width < 1) || (height < 1)) {
98 os <<
"kernel height = " << height <<
" and/or width = " << width <<
" < 1";
101 for (
auto const &ii : spatialFunctionList) {
113 if (params.size() != nKernelParams) {
116 (
boost::format(
"params has %d entries instead of %d") % params.size() % nKernelParams).str());
119 for (
unsigned int ii = 0; ii < nKernelParams; ++ii) {
120 if (params[ii].size() != nSpatialParams) {
122 (
boost::format(
"params[%d] has %d entries instead of %d") % ii %
123 params[ii].size() % nSpatialParams)
128 if (nSpatialParams > 0) {
129 for (
unsigned int ii = 0; ii < nKernelParams; ++ii) {
140 *paramIter = (*(*funcIter))(
x,
y);
160 spFuncCopyList.
push_back((*spFuncIter).clone());
162 return spFuncCopyList;
177 <<
") in one or both dimensions";
204 boost::archive::text_oarchive oa(
os);
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
A class to represent a 2-dimensional array of pixels.
A Function taking two arguments.
virtual std::shared_ptr< Function2< ReturnT > > clone() const =0
Return a pointer to a deep copy of this function.
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
std::vector< SpatialFunctionPtr > _spatialFunctionList
int getHeight() const
Return the Kernel's height.
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
unsigned int getNKernelParameters() const
Return the number of kernel parameters (0 if none)
void setSpatialParameters(const std::vector< std::vector< double > > params)
Set the parameters of all spatial functions.
int getNSpatialParameters() const
Return the number of spatial parameters (0 if not spatially varying)
std::vector< SpatialFunctionPtr > getSpatialFunctionList() const
Return a list of clones of the spatial functions.
virtual std::vector< double > getKernelParameters() const
Return the current kernel parameters.
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
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)
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...
int getWidth() const
Return the Kernel's width.
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
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,...
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
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.
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const =0
Low-level version of computeImage.
Kernel()
Construct a null Kernel of size 0,0.
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
a class used in function calls to indicate that no Function2 is being provided
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
An integer coordinate rectangle.
Reports invalid arguments.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
deltafunction_kernel_tag deltafunction_kernel_tag_
Used as default value in argument lists.
generic_kernel_tag generic_kernel_tag_
Used as default value in argument lists.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
A base class for image defects.
Kernel has only one non-zero pixel.
Tags carrying information about Kernels Kernel with no special properties.