LSST Applications g0b6bd0c080+a72a5dd7e6,g1182afd7b4+2a019aa3bb,g17e5ecfddb+2b8207f7de,g1d67935e3f+06cf436103,g38293774b4+ac198e9f13,g396055baef+6a2097e274,g3b44f30a73+6611e0205b,g480783c3b1+98f8679e14,g48ccf36440+89c08d0516,g4b93dc025c+98f8679e14,g5c4744a4d9+a302e8c7f0,g613e996a0d+e1c447f2e0,g6c8d09e9e7+25247a063c,g7271f0639c+98f8679e14,g7a9cd813b8+124095ede6,g9d27549199+a302e8c7f0,ga1cf026fa3+ac198e9f13,ga32aa97882+7403ac30ac,ga786bb30fb+7a139211af,gaa63f70f4e+9994eb9896,gabf319e997+ade567573c,gba47b54d5d+94dc90c3ea,gbec6a3398f+06cf436103,gc6308e37c7+07dd123edb,gc655b1545f+ade567573c,gcc9029db3c+ab229f5caf,gd01420fc67+06cf436103,gd877ba84e5+06cf436103,gdb4cecd868+6f279b5b48,ge2d134c3d5+cc4dbb2e3f,ge448b5faa6+86d1ceac1d,gecc7e12556+98f8679e14,gf3ee170dca+25247a063c,gf4ac96e456+ade567573c,gf9f5ea5b4d+ac198e9f13,gff490e6085+8c2580be5c,w.2022.27
LSST Data Management Base Package
Kernel.h
Go to the documentation of this file.
1// -*- LSST-C++ -*-
2
3/*
4 * LSST Data Management System
5 * Copyright 2008-2016 AURA/LSST.
6 *
7 * This product includes software developed by the
8 * LSST Project (http://www.lsst.org/).
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the LSST License Statement and
21 * the GNU General Public License along with this program. If not,
22 * see <http://www.lsstcorp.org/LegalNotices/>.
23 */
24
25#ifndef LSST_AFW_MATH_KERNEL_H
26#define LSST_AFW_MATH_KERNEL_H
27/*
28 * Declare the Kernel class and subclasses.
29 */
30#include <memory>
31#include <type_traits>
32#include <utility>
33#include <vector>
34
35#include "boost/format.hpp"
36
37#include "lsst/geom.h"
41
43
44namespace lsst {
45namespace afw {
46
47namespace math {
48
111public:
112 using Pixel = double;
116
117 // Traits values for this class of Kernel
119
125 explicit Kernel();
126
140 explicit Kernel(int width, int height, unsigned int nKernelParams,
141 SpatialFunction const &spatialFunction = NullSpatialFunction());
142
154 explicit Kernel(int width, int height, const std::vector<SpatialFunctionPtr> spatialFunctionList);
155
156 // prevent copying and assignment (to avoid problems from type slicing)
157 Kernel(const Kernel &) = delete;
158 Kernel(Kernel &&) = delete;
159 Kernel &operator=(const Kernel &) = delete;
160 Kernel &operator=(Kernel &&) = delete;
161
162 ~Kernel() override = default;
163
175 virtual std::shared_ptr<Kernel> clone() const = 0;
176
187 virtual std::shared_ptr<Kernel> resized(int width, int height) const = 0;
188
206 double computeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize, double x = 0.0,
207 double y = 0.0) const;
208
212 lsst::geom::Extent2I const getDimensions() const { return lsst::geom::Extent2I(_width, _height); }
213
215 _width = dims.getX();
216 _height = dims.getY();
217 }
218 inline void setWidth(int width) { _width = width; }
219 inline void setHeight(int height) { _height = height; }
220
224 inline int getWidth() const { return _width; }
225
229 inline int getHeight() const { return _height; }
230
234 inline lsst::geom::Point2I getCtr() const { return lsst::geom::Point2I(_ctrX, _ctrY); }
235
239 inline lsst::geom::Box2I getBBox() const {
240 return lsst::geom::Box2I(lsst::geom::Point2I(-_ctrX, -_ctrY), lsst::geom::Extent2I(_width, _height));
241 }
242
246 inline unsigned int getNKernelParameters() const { return _nKernelParams; }
247
251 inline int getNSpatialParameters() const {
252 return this->isSpatiallyVarying() ? _spatialFunctionList[0]->getNParameters() : 0;
253 }
254
265 SpatialFunctionPtr getSpatialFunction(unsigned int index) const;
266
274
277 virtual double getKernelParameter(unsigned int i) const { return getKernelParameters()[i]; }
278
287
296
308
312 inline void setCtr(lsst::geom::Point2I ctr) {
313 _ctrX = ctr.getX();
314 _ctrY = ctr.getY();
315 _setKernelXY();
316 }
317
322 std::vector<std::vector<double>> spatialParams;
324 for (; spFuncIter != _spatialFunctionList.end(); ++spFuncIter) {
325 spatialParams.push_back((*spFuncIter)->getParameters());
326 }
327 return spatialParams;
328 }
329
333 inline bool isSpatiallyVarying() const { return _spatialFunctionList.size() != 0; }
334
341 inline void setKernelParameters(std::vector<double> const &params) {
342 if (this->isSpatiallyVarying()) {
343 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Kernel is spatially varying");
344 }
345 const unsigned int nParams = this->getNKernelParameters();
346 if (nParams != params.size()) {
348 (boost::format("Number of parameters is wrong, saw %d expected %d") % nParams %
349 params.size())
350 .str());
351 }
352 for (unsigned int ii = 0; ii < nParams; ++ii) {
353 this->setKernelParameter(ii, params[ii]);
354 }
355 }
356
364 this->setKernelParameter(0, params.first);
365 this->setKernelParameter(1, params.second);
366 }
367
377
384 void computeKernelParametersFromSpatialModel(std::vector<double> &kernelParams, double x, double y) const;
385
389 virtual std::string toString(std::string const &prefix = "") const;
390
397 virtual void computeCache(int const
398 ) {}
399
403 virtual int getCacheSize() const { return 0; };
404
405#if 0 // fails to compile with icc; is it actually used?
406 virtual void toFile(std::string fileName) const;
407#endif
408
409 struct PersistenceHelper;
410
411protected:
412 std::string getPythonModule() const override;
413
424 virtual void setKernelParameter(unsigned int ind, double value) const;
425
434 void setKernelParametersFromSpatialModel(double x, double y) const;
435
447 virtual double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const = 0;
448
450
451private:
452 int _width;
453 int _height;
454 int _ctrX;
455 int _ctrY;
456 unsigned int _nKernelParams;
457
458 // Set the Kernel's ideas about the x- and y- coordinates
459 virtual void _setKernelXY() {}
460};
461
463
471class FixedKernel : public afw::table::io::PersistableFacade<FixedKernel>, public Kernel {
472public:
476 explicit FixedKernel();
477
482 );
483
487 explicit FixedKernel(lsst::afw::math::Kernel const &kernel,
488 lsst::geom::Point2D const &pos
489 );
490
491 FixedKernel(const FixedKernel &) = delete;
495
496 ~FixedKernel() override = default;
497
498 std::shared_ptr<Kernel> clone() const override;
499
500 std::shared_ptr<Kernel> resized(int width, int height) const override;
501
502 std::string toString(std::string const &prefix = "") const override;
503
504 virtual Pixel getSum() const { return _sum; }
505
506 bool isPersistable() const noexcept override { return true; }
507
508 class Factory;
509
510protected:
511 double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
512
513 std::string getPersistenceName() const override;
514
515 void write(OutputArchiveHandle &handle) const override;
516
517private:
519 Pixel _sum;
520};
521
535class AnalyticKernel : public afw::table::io::PersistableFacade<AnalyticKernel>, public Kernel {
536public:
539
543 explicit AnalyticKernel();
544
557 explicit AnalyticKernel(int width, int height, KernelFunction const &kernelFunction,
558 Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction());
559
573 explicit AnalyticKernel(int width, int height, KernelFunction const &kernelFunction,
574 std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
575
580
581 ~AnalyticKernel() override = default;
582
583 std::shared_ptr<Kernel> clone() const override;
584
585 std::shared_ptr<Kernel> resized(int width, int height) const override;
586
607 double computeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize, double x = 0.0,
608 double y = 0.0) const;
609
611
615 virtual KernelFunctionPtr getKernelFunction() const;
616
617 std::string toString(std::string const &prefix = "") const override;
618
619 bool isPersistable() const noexcept override { return true; }
620
621 class Factory;
622
623protected:
624 double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
625
626 std::string getPersistenceName() const override;
627
628 void write(OutputArchiveHandle &handle) const override;
629
630protected:
631 void setKernelParameter(unsigned int ind, double value) const override;
632
634};
635
643class DeltaFunctionKernel : public afw::table::io::PersistableFacade<DeltaFunctionKernel>, public Kernel {
644public:
645 // Traits values for this class of Kernel
647
657 explicit DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point);
658
663
664 ~DeltaFunctionKernel() override = default;
665
666 std::shared_ptr<Kernel> clone() const override;
667
668 std::shared_ptr<Kernel> resized(int width, int height) const override;
669
670 lsst::geom::Point2I getPixel() const { return _pixel; }
671
672 std::string toString(std::string const &prefix = "") const override;
673
674 bool isPersistable() const noexcept override { return true; }
675
676 class Factory;
677
678protected:
679 double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
680
681 std::string getPersistenceName() const override;
682
683 void write(OutputArchiveHandle &handle) const override;
684
685private:
686 lsst::geom::Point2I _pixel;
687};
688
703class LinearCombinationKernel : public afw::table::io::PersistableFacade<LinearCombinationKernel>,
704 public Kernel {
705public:
709 explicit LinearCombinationKernel();
710
717 explicit LinearCombinationKernel(KernelList const &kernelList,
718 std::vector<double> const &kernelParameters);
719
727 explicit LinearCombinationKernel(KernelList const &kernelList,
728 Kernel::SpatialFunction const &spatialFunction);
729
739 explicit LinearCombinationKernel(KernelList const &kernelList,
740 std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
741
746
747 ~LinearCombinationKernel() override = default;
748
749 std::shared_ptr<Kernel> clone() const override;
750
751 std::shared_ptr<Kernel> resized(int width, int height) const override;
752
754
758 virtual KernelList const &getKernelList() const;
759
764
768 int getNBasisKernels() const { return static_cast<int>(_kernelList.size()); };
769
775 void checkKernelList(const KernelList &kernelList) const;
776
780 bool isDeltaFunctionBasis() const { return _isDeltaFunctionBasis; };
781
817
818 std::string toString(std::string const &prefix = "") const override;
819
820 bool isPersistable() const noexcept override { return true; }
821
822 class Factory;
823
824protected:
825 double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
826
827 std::string getPersistenceName() const override;
828
829 void write(OutputArchiveHandle &handle) const override;
830
831 void setKernelParameter(unsigned int ind, double value) const override;
832
833private:
837 void _setKernelList(KernelList const &kernelList);
838
839 KernelList _kernelList;
842 std::vector<double> _kernelSumList;
843 mutable std::vector<double> _kernelParams;
844 bool _isDeltaFunctionBasis;
845};
846
860class SeparableKernel : public afw::table::io::PersistableFacade<SeparableKernel>, public Kernel {
861public:
864
868 explicit SeparableKernel();
869
882 explicit SeparableKernel(int width, int height, KernelFunction const &kernelColFunction,
883 KernelFunction const &kernelRowFunction,
884 Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction());
885
899 explicit SeparableKernel(int width, int height, KernelFunction const &kernelColFunction,
900 KernelFunction const &kernelRowFunction,
901 std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
902
907
908 ~SeparableKernel() override = default;
909
910 std::shared_ptr<Kernel> clone() const override;
911
912 std::shared_ptr<Kernel> resized(int width, int height) const override;
913
930 double computeVectors(std::vector<Pixel> &colList, std::vector<Pixel> &rowList, bool doNormalize,
931 double x = 0.0, double y = 0.0) const;
932
933 double getKernelParameter(unsigned int i) const override {
934 unsigned int const ncol = _kernelColFunctionPtr->getNParameters();
935 if (i < ncol) {
936 return _kernelColFunctionPtr->getParameter(i);
937 } else {
938 i -= ncol;
939 return _kernelRowFunctionPtr->getParameter(i);
940 }
941 }
943
948
953
954 std::string toString(std::string const &prefix = "") const override;
955
956 /***
957 * Compute a cache of values for the x and y kernel functions
958 *
959 * A value of 0 disables the cache for maximum accuracy.
960 * 10,000 typically results in a warping error of a fraction of a count.
961 * 100,000 typically results in a warping error of less than 0.01 count.
962 *
963 * @param cacheSize cache size (number of double precision array elements in the x and y caches)
964 */
965 void computeCache(int const cacheSize) override;
966
970 int getCacheSize() const override;
971
972protected:
973 double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
974
975 void setKernelParameter(unsigned int ind, double value) const override;
976
977private:
991 double basicComputeVectors(std::vector<Pixel> &colList, std::vector<Pixel> &rowList,
992 bool doNormalize) const;
993
994 KernelFunctionPtr _kernelColFunctionPtr;
995 KernelFunctionPtr _kernelRowFunctionPtr;
996 mutable std::vector<Pixel> _localColList; // used by doComputeImage
997 mutable std::vector<Pixel> _localRowList;
998 mutable std::vector<double> _kernelX; // used by SeparableKernel::basicComputeVectors
999 mutable std::vector<double> _kernelY;
1000 //
1001 // Cached values of the row- and column- kernels
1002 //
1003 mutable std::vector<std::vector<double>> _kernelRowCache;
1004 mutable std::vector<std::vector<double>> _kernelColCache;
1005
1006 virtual void _setKernelXY() override {
1007 lsst::geom::Extent2I const dim = getDimensions();
1008 lsst::geom::Point2I const ctr = getCtr();
1009
1010 assert(dim[0] == static_cast<int>(_kernelX.size()));
1011 for (int i = 0; i != dim.getX(); ++i) {
1012 _kernelX[i] = i - ctr.getX();
1013 }
1014
1015 assert(dim[1] == static_cast<int>(_kernelY.size()));
1016 for (int i = 0; i != dim.getY(); ++i) {
1017 _kernelY[i] = i - ctr.getY();
1018 }
1019 }
1020};
1021} // namespace math
1022} // namespace afw
1023} // namespace lsst
1024
1025#endif // !defined(LSST_AFW_MATH_KERNEL_H)
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
table::Key< int > kernelFunction
double x
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
std::string prefix
Definition: SchemaMapper.cc:72
int y
Definition: SpanSet.cc:48
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:51
A kernel described by a function.
Definition: Kernel.h:535
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:619
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.
AnalyticKernel(AnalyticKernel &&)=delete
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
AnalyticKernel(const AnalyticKernel &)=delete
virtual KernelFunctionPtr getKernelFunction() const
Get a deep copy of the kernel function.
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.
KernelFunctionPtr _kernelFunctionPtr
Definition: Kernel.h:633
AnalyticKernel & operator=(AnalyticKernel &&)=delete
AnalyticKernel & operator=(const AnalyticKernel &)=delete
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
AnalyticKernel()
Construct an empty spatially invariant AnalyticKernel of size 0x0.
~AnalyticKernel() override=default
A kernel that has only one non-zero pixel (of value 1)
Definition: Kernel.h:643
DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
DeltaFunctionKernel & operator=(DeltaFunctionKernel &&)=delete
~DeltaFunctionKernel() override=default
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
lsst::geom::Point2I getPixel() const
Definition: Kernel.h:670
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
DeltaFunctionKernel(DeltaFunctionKernel &&)=delete
DeltaFunctionKernel & operator=(const DeltaFunctionKernel &)=delete
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:674
DeltaFunctionKernel(const DeltaFunctionKernel &)=delete
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
A kernel created from an Image.
Definition: Kernel.h:471
FixedKernel(FixedKernel &&)=delete
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: FixedKernel.cc:180
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: FixedKernel.cc:62
FixedKernel()
Construct an empty FixedKernel of size 0x0.
Definition: FixedKernel.cc:43
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: FixedKernel.cc:105
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: FixedKernel.cc:68
~FixedKernel() override=default
FixedKernel & operator=(FixedKernel &&)=delete
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:506
virtual Pixel getSum() const
Definition: Kernel.h:504
FixedKernel & operator=(const FixedKernel &)=delete
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: FixedKernel.cc:128
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: FixedKernel.cc:182
FixedKernel(const FixedKernel &)=delete
A Function taking one argument.
Definition: Function.h:202
A Function taking two arguments.
Definition: Function.h:259
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
Definition: Function.h:119
unsigned int getNParameters() const noexcept
Return the number of function parameters.
Definition: Function.h:112
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:110
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
Definition: Kernel.h:212
virtual void _setKernelXY()
Definition: Kernel.h:459
std::vector< SpatialFunctionPtr > _spatialFunctionList
Definition: Kernel.h:449
Kernel(const Kernel &)=delete
virtual void computeCache(int const)
Compute a cache of Kernel values, if desired.
Definition: Kernel.h:397
int getHeight() const
Return the Kernel's height.
Definition: Kernel.h:229
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
Definition: Kernel.h:234
Kernel & operator=(const Kernel &)=delete
void setKernelParameters(std::vector< double > const &params)
Set the kernel parameters of a spatially invariant kernel.
Definition: Kernel.h:341
unsigned int getNKernelParameters() const
Return the number of kernel parameters (0 if none)
Definition: Kernel.h:246
void setSpatialParameters(const std::vector< std::vector< double > > params)
Set the parameters of all spatial functions.
Definition: Kernel.cc:110
virtual double getKernelParameter(unsigned int i) const
Return a particular Kernel Parameter (no bounds checking).
Definition: Kernel.h:277
std::shared_ptr< lsst::afw::math::Function2< double > > SpatialFunctionPtr
Definition: Kernel.h:113
int getNSpatialParameters() const
Return the number of spatial parameters (0 if not spatially varying)
Definition: Kernel.h:251
void setWidth(int width)
Definition: Kernel.h:218
std::vector< SpatialFunctionPtr > getSpatialFunctionList() const
Return a list of clones of the spatial functions.
Definition: Kernel.cc:157
virtual std::vector< double > getKernelParameters() const
Return the current kernel parameters.
Definition: Kernel.cc:165
~Kernel() override=default
Kernel & operator=(Kernel &&)=delete
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
Definition: Kernel.cc:185
lsst::afw::math::NullFunction2< double > NullSpatialFunction
Definition: Kernel.h:115
void computeKernelParametersFromSpatialModel(std::vector< double > &kernelParams, double x, double y) const
Compute the kernel parameters at a specified point.
Definition: Kernel.cc:135
SpatialFunctionPtr getSpatialFunction(unsigned int index) const
Return a clone of the specified spatial function (one component of the spatial model)
Definition: Kernel.cc:144
void setCtr(lsst::geom::Point2I ctr)
Set index of kernel's center.
Definition: Kernel.h:312
virtual int getCacheSize() const
Get the current size of the kernel cache (0 if none or if caches not supported)
Definition: Kernel.h:403
std::vector< std::vector< double > > getSpatialParameters() const
Return the spatial parameters parameters (an empty vector if not spatially varying)
Definition: Kernel.h:321
void setKernelParameters(std::pair< double, double > const &params)
Set the kernel parameters of a 2-component spatially invariant kernel.
Definition: Kernel.h:363
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...
Definition: Kernel.cc:173
int getWidth() const
Return the Kernel's width.
Definition: Kernel.h:224
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
Definition: Kernel.h:333
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,...
Definition: Kernel.cc:167
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
Definition: Kernel.cc:213
void setHeight(int height)
Definition: Kernel.h:219
void setDimensions(lsst::geom::Extent2I dims)
Definition: Kernel.h:214
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition: Kernel.cc:224
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.
Definition: Kernel.cc:76
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.
Definition: Kernel.cc:49
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
Definition: Kernel.cc:217
Kernel(Kernel &&)=delete
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
Definition: Kernel.h:239
virtual std::shared_ptr< Kernel > resized(int width, int height) const =0
Return a pointer to a clone with specified kernel dimensions.
A kernel that is a linear combination of fixed basis kernels.
Definition: Kernel.h:704
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:820
std::vector< double > getKernelSumList() const
Get the sum of the pixels of each fixed basis kernel.
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 KernelList const & getKernelList() const
Get the fixed basis kernels.
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
LinearCombinationKernel()
Construct an empty LinearCombinationKernel of size 0x0.
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
void checkKernelList(const KernelList &kernelList) const
Check that all kernels have the same size and center and that none are spatially varying.
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
LinearCombinationKernel & operator=(const LinearCombinationKernel &)=delete
int getNBasisKernels() const
Get the number of basis kernels.
Definition: Kernel.h:768
LinearCombinationKernel & operator=(LinearCombinationKernel &&)=delete
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
LinearCombinationKernel(LinearCombinationKernel &&)=delete
LinearCombinationKernel(const LinearCombinationKernel &)=delete
bool isDeltaFunctionBasis() const
Return true if all basis kernels are instances of DeltaFunctionKernel.
Definition: Kernel.h:780
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
a class used in function calls to indicate that no Function2 is being provided
Definition: Function.h:458
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
Definition: Kernel.h:860
~SeparableKernel() override=default
KernelFunctionPtr getKernelRowFunction() const
Get a deep copy of the row kernel function.
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
SeparableKernel(SeparableKernel &&)=delete
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
std::shared_ptr< KernelFunction > KernelFunctionPtr
Definition: Kernel.h:863
double getKernelParameter(unsigned int i) const override
Return a particular Kernel Parameter (no bounds checking).
Definition: Kernel.h:933
int getCacheSize() const override
Get the current cache size (0 if none)
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
SeparableKernel(const SeparableKernel &)=delete
KernelFunctionPtr getKernelColFunction() const
Get a deep copy of the col kernel function.
SeparableKernel & operator=(const SeparableKernel &)=delete
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)
SeparableKernel & operator=(SeparableKernel &&)=delete
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
virtual void _setKernelXY() override
Definition: Kernel.h:1006
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
SeparableKernel()
Construct an empty spatially invariant SeparableKernel of size 0x0.
void computeCache(int const cacheSize) override
Compute a cache of Kernel values, if desired.
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:108
An integer coordinate rectangle.
Definition: Box.h:55
Reports invalid arguments.
Definition: Runtime.h:66
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Extent< int, 2 > Extent2I
Definition: Extent.h:397
Point< int, 2 > Point2I
Definition: Point.h:321
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
A base class for image defects.
T push_back(T... args)
T size(T... args)
Kernel has only one non-zero pixel.
Definition: traits.h:56
Tags carrying information about Kernels Kernel with no special properties.
Definition: traits.h:53
table::Key< int > cacheSize