LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
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/mpl/or.hpp"
36 
37 #include "lsst/geom.h"
38 #include "lsst/afw/image/Image.h"
39 #include "lsst/afw/image/Utils.h"
40 #include "lsst/afw/math/Function.h"
41 #include "lsst/afw/math/traits.h"
42 
44 
45 namespace lsst {
46 namespace afw {
47 
48 namespace math {
49 
112 public:
113  typedef double Pixel;
117 
118  // Traits values for this class of Kernel
120 
126  explicit Kernel();
127 
141  explicit Kernel(int width, int height, unsigned int nKernelParams,
142  SpatialFunction const &spatialFunction = NullSpatialFunction());
143 
155  explicit Kernel(int width, int height, const std::vector<SpatialFunctionPtr> spatialFunctionList);
156 
157  // prevent copying and assignment (to avoid problems from type slicing)
158  Kernel(const Kernel &) = delete;
159  Kernel(Kernel &&) = delete;
160  Kernel &operator=(const Kernel &) = delete;
161  Kernel &operator=(Kernel &&) = delete;
162 
163  ~Kernel() override = default;
164 
176  virtual std::shared_ptr<Kernel> clone() const = 0;
177 
188  virtual std::shared_ptr<Kernel> resized(int width, int height) const = 0;
189 
207  double computeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize, double x = 0.0,
208  double y = 0.0) const;
209 
213  lsst::geom::Extent2I const getDimensions() const { return lsst::geom::Extent2I(_width, _height); }
214 
216  _width = dims.getX();
217  _height = dims.getY();
218  }
219  inline void setWidth(int width) { _width = width; }
220  inline void setHeight(int height) { _height = height; }
221 
225  inline int getWidth() const { return _width; }
226 
230  inline int getHeight() const { return _height; }
231 
235  inline lsst::geom::Point2I getCtr() const { return lsst::geom::Point2I(_ctrX, _ctrY); }
236 
240  inline lsst::geom::Box2I getBBox() const {
241  return lsst::geom::Box2I(lsst::geom::Point2I(-_ctrX, -_ctrY), lsst::geom::Extent2I(_width, _height));
242  }
243 
247  inline unsigned int getNKernelParameters() const { return _nKernelParams; }
248 
252  inline int getNSpatialParameters() const {
253  return this->isSpatiallyVarying() ? _spatialFunctionList[0]->getNParameters() : 0;
254  }
255 
266  SpatialFunctionPtr getSpatialFunction(unsigned int index) const;
267 
275 
278  virtual double getKernelParameter(unsigned int i) const { return getKernelParameters()[i]; }
279 
288 
297 
309 
313  inline void setCtr(lsst::geom::Point2I ctr) {
314  _ctrX = ctr.getX();
315  _ctrY = ctr.getY();
316  _setKernelXY();
317  }
318 
323  std::vector<std::vector<double>> spatialParams;
325  for (; spFuncIter != _spatialFunctionList.end(); ++spFuncIter) {
326  spatialParams.push_back((*spFuncIter)->getParameters());
327  }
328  return spatialParams;
329  }
330 
334  inline bool isSpatiallyVarying() const { return _spatialFunctionList.size() != 0; }
335 
342  inline void setKernelParameters(std::vector<double> const &params) {
343  if (this->isSpatiallyVarying()) {
344  throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError, "Kernel is spatially varying");
345  }
346  const unsigned int nParams = this->getNKernelParameters();
347  if (nParams != params.size()) {
349  (boost::format("Number of parameters is wrong, saw %d expected %d") % nParams %
350  params.size())
351  .str());
352  }
353  for (unsigned int ii = 0; ii < nParams; ++ii) {
354  this->setKernelParameter(ii, params[ii]);
355  }
356  }
357 
364  inline void setKernelParameters(std::pair<double, double> const &params) {
365  this->setKernelParameter(0, params.first);
366  this->setKernelParameter(1, params.second);
367  }
368 
378 
385  void computeKernelParametersFromSpatialModel(std::vector<double> &kernelParams, double x, double y) const;
386 
390  virtual std::string toString(std::string const &prefix = "") const;
391 
398  virtual void computeCache(int const
399  ) {}
400 
404  virtual int getCacheSize() const { return 0; };
405 
406 #if 0 // fails to compile with icc; is it actually used?
407  virtual void toFile(std::string fileName) const;
408 #endif
409 
410  struct PersistenceHelper;
411 
412 protected:
413  std::string getPythonModule() const override;
414 
425  virtual void setKernelParameter(unsigned int ind, double value) const;
426 
435  void setKernelParametersFromSpatialModel(double x, double y) const;
436 
448  virtual double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const = 0;
449 
451 
452 private:
453  int _width;
454  int _height;
455  int _ctrX;
456  int _ctrY;
457  unsigned int _nKernelParams;
458 
459  // Set the Kernel's ideas about the x- and y- coordinates
460  virtual void _setKernelXY() {}
461 };
462 
464 
472 class FixedKernel : public afw::table::io::PersistableFacade<FixedKernel>, public Kernel {
473 public:
477  explicit FixedKernel();
478 
483  );
484 
488  explicit FixedKernel(lsst::afw::math::Kernel const &kernel,
489  lsst::geom::Point2D const &pos
490  );
491 
492  FixedKernel(const FixedKernel &) = delete;
493  FixedKernel(FixedKernel &&) = delete;
494  FixedKernel &operator=(const FixedKernel &) = delete;
496 
497  ~FixedKernel() override = default;
498 
499  std::shared_ptr<Kernel> clone() const override;
500 
501  std::shared_ptr<Kernel> resized(int width, int height) const override;
502 
503  std::string toString(std::string const &prefix = "") const override;
504 
505  virtual Pixel getSum() const { return _sum; }
506 
507  bool isPersistable() const noexcept override { return true; }
508 
509  class Factory;
510 
511 protected:
512  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
513 
514  std::string getPersistenceName() const override;
515 
516  void write(OutputArchiveHandle &handle) const override;
517 
518 private:
520  Pixel _sum;
521 };
522 
536 class AnalyticKernel : public afw::table::io::PersistableFacade<AnalyticKernel>, public Kernel {
537 public:
540 
544  explicit AnalyticKernel();
545 
558  explicit AnalyticKernel(int width, int height, KernelFunction const &kernelFunction,
559  Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction());
560 
574  explicit AnalyticKernel(int width, int height, KernelFunction const &kernelFunction,
575  std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
576 
577  AnalyticKernel(const AnalyticKernel &) = delete;
581 
582  ~AnalyticKernel() override = default;
583 
584  std::shared_ptr<Kernel> clone() const override;
585 
586  std::shared_ptr<Kernel> resized(int width, int height) const override;
587 
608  double computeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize, double x = 0.0,
609  double y = 0.0) const;
610 
611  std::vector<double> getKernelParameters() const override;
612 
616  virtual KernelFunctionPtr getKernelFunction() const;
617 
618  std::string toString(std::string const &prefix = "") const override;
619 
620  bool isPersistable() const noexcept override { return true; }
621 
622  class Factory;
623 
624 protected:
625  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
626 
627  std::string getPersistenceName() const override;
628 
629  void write(OutputArchiveHandle &handle) const override;
630 
631 protected:
632  void setKernelParameter(unsigned int ind, double value) const override;
633 
635 };
636 
644 class DeltaFunctionKernel : public afw::table::io::PersistableFacade<DeltaFunctionKernel>, public Kernel {
645 public:
646  // Traits values for this class of Kernel
648 
658  explicit DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point);
659 
664 
665  ~DeltaFunctionKernel() override = default;
666 
667  std::shared_ptr<Kernel> clone() const override;
668 
669  std::shared_ptr<Kernel> resized(int width, int height) const override;
670 
671  lsst::geom::Point2I getPixel() const { return _pixel; }
672 
673  std::string toString(std::string const &prefix = "") const override;
674 
675  bool isPersistable() const noexcept override { return true; }
676 
677  class Factory;
678 
679 protected:
680  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
681 
682  std::string getPersistenceName() const override;
683 
684  void write(OutputArchiveHandle &handle) const override;
685 
686 private:
687  lsst::geom::Point2I _pixel;
688 };
689 
704 class LinearCombinationKernel : public afw::table::io::PersistableFacade<LinearCombinationKernel>,
705  public Kernel {
706 public:
710  explicit LinearCombinationKernel();
711 
718  explicit LinearCombinationKernel(KernelList const &kernelList,
719  std::vector<double> const &kernelParameters);
720 
728  explicit LinearCombinationKernel(KernelList const &kernelList,
729  Kernel::SpatialFunction const &spatialFunction);
730 
740  explicit LinearCombinationKernel(KernelList const &kernelList,
741  std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
742 
747 
748  ~LinearCombinationKernel() override = default;
749 
750  std::shared_ptr<Kernel> clone() const override;
751 
752  std::shared_ptr<Kernel> resized(int width, int height) const override;
753 
754  std::vector<double> getKernelParameters() const override;
755 
759  virtual KernelList const &getKernelList() const;
760 
765 
769  int getNBasisKernels() const { return static_cast<int>(_kernelList.size()); };
770 
776  void checkKernelList(const KernelList &kernelList) const;
777 
781  bool isDeltaFunctionBasis() const { return _isDeltaFunctionBasis; };
782 
818 
819  std::string toString(std::string const &prefix = "") const override;
820 
821  bool isPersistable() const noexcept override { return true; }
822 
823  class Factory;
824 
825 protected:
826  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
827 
828  std::string getPersistenceName() const override;
829 
830  void write(OutputArchiveHandle &handle) const override;
831 
832  void setKernelParameter(unsigned int ind, double value) const override;
833 
834 private:
838  void _setKernelList(KernelList const &kernelList);
839 
840  KernelList _kernelList;
843  std::vector<double> _kernelSumList;
844  mutable std::vector<double> _kernelParams;
845  bool _isDeltaFunctionBasis;
846 };
847 
861 class SeparableKernel : public afw::table::io::PersistableFacade<SeparableKernel>, public Kernel {
862 public:
865 
869  explicit SeparableKernel();
870 
883  explicit SeparableKernel(int width, int height, KernelFunction const &kernelColFunction,
884  KernelFunction const &kernelRowFunction,
885  Kernel::SpatialFunction const &spatialFunction = NullSpatialFunction());
886 
900  explicit SeparableKernel(int width, int height, KernelFunction const &kernelColFunction,
901  KernelFunction const &kernelRowFunction,
902  std::vector<Kernel::SpatialFunctionPtr> const &spatialFunctionList);
903 
904  SeparableKernel(const SeparableKernel &) = delete;
908 
909  ~SeparableKernel() override = default;
910 
911  std::shared_ptr<Kernel> clone() const override;
912 
913  std::shared_ptr<Kernel> resized(int width, int height) const override;
914 
931  double computeVectors(std::vector<Pixel> &colList, std::vector<Pixel> &rowList, bool doNormalize,
932  double x = 0.0, double y = 0.0) const;
933 
934  double getKernelParameter(unsigned int i) const override {
935  unsigned int const ncol = _kernelColFunctionPtr->getNParameters();
936  if (i < ncol) {
937  return _kernelColFunctionPtr->getParameter(i);
938  } else {
939  i -= ncol;
940  return _kernelRowFunctionPtr->getParameter(i);
941  }
942  }
943  std::vector<double> getKernelParameters() const override;
944 
949 
954 
955  std::string toString(std::string const &prefix = "") const override;
956 
957  /***
958  * Compute a cache of values for the x and y kernel functions
959  *
960  * A value of 0 disables the cache for maximum accuracy.
961  * 10,000 typically results in a warping error of a fraction of a count.
962  * 100,000 typically results in a warping error of less than 0.01 count.
963  *
964  * @param cacheSize cache size (number of double precision array elements in the x and y caches)
965  */
966  void computeCache(int const cacheSize) override;
967 
971  int getCacheSize() const override;
972 
973 protected:
974  double doComputeImage(lsst::afw::image::Image<Pixel> &image, bool doNormalize) const override;
975 
976  void setKernelParameter(unsigned int ind, double value) const override;
977 
978 private:
992  double basicComputeVectors(std::vector<Pixel> &colList, std::vector<Pixel> &rowList,
993  bool doNormalize) const;
994 
995  KernelFunctionPtr _kernelColFunctionPtr;
996  KernelFunctionPtr _kernelRowFunctionPtr;
997  mutable std::vector<Pixel> _localColList; // used by doComputeImage
998  mutable std::vector<Pixel> _localRowList;
999  mutable std::vector<double> _kernelX; // used by SeparableKernel::basicComputeVectors
1000  mutable std::vector<double> _kernelY;
1001  //
1002  // Cached values of the row- and column- kernels
1003  //
1004  mutable std::vector<std::vector<double>> _kernelRowCache;
1005  mutable std::vector<std::vector<double>> _kernelColCache;
1006 
1007  virtual void _setKernelXY() override {
1008  lsst::geom::Extent2I const dim = getDimensions();
1009  lsst::geom::Point2I const ctr = getCtr();
1010 
1011  assert(dim[0] == static_cast<int>(_kernelX.size()));
1012  for (int i = 0; i != dim.getX(); ++i) {
1013  _kernelX[i] = i - ctr.getX();
1014  }
1015 
1016  assert(dim[1] == static_cast<int>(_kernelY.size()));
1017  for (int i = 0; i != dim.getY(); ++i) {
1018  _kernelY[i] = i - ctr.getY();
1019  }
1020  }
1021 };
1022 } // namespace math
1023 } // namespace afw
1024 } // namespace lsst
1025 
1026 #endif // !defined(LSST_AFW_MATH_KERNEL_H)
y
int y
Definition: SpanSet.cc:49
lsst::afw::math::AnalyticKernel::operator=
AnalyticKernel & operator=(AnalyticKernel &&)=delete
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::math::Kernel::getBBox
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
Definition: Kernel.h:240
lsst::afw::math::Kernel::setKernelParametersFromSpatialModel
void setKernelParametersFromSpatialModel(double x, double y) const
Set the kernel parameters from the spatial model (if any).
Definition: Kernel.cc:228
lsst::afw::math::Kernel::setKernelParameter
virtual void setKernelParameter(unsigned int ind, double value) const
Set one kernel parameter.
Definition: Kernel.cc:224
lsst::afw::math::SeparableKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: SeparableKernel.cc:111
lsst::afw::math::SeparableKernel::operator=
SeparableKernel & operator=(const SeparableKernel &)=delete
std::string
STL class.
std::shared_ptr
STL class.
Persistable.h
lsst::afw::math::Kernel::getNSpatialParameters
int getNSpatialParameters() const
Return the number of spatial parameters (0 if not spatially varying)
Definition: Kernel.h:252
lsst::afw::math::DeltaFunctionKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:675
lsst::afw::math::Kernel::getDimensions
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
Definition: Kernel.h:213
Utils.h
lsst::afw::math::LinearCombinationKernel::LinearCombinationKernel
LinearCombinationKernel()
Construct an empty LinearCombinationKernel of size 0x0.
Definition: LinearCombinationKernel.cc:48
lsst::afw::math::Kernel::isSpatiallyVarying
bool isSpatiallyVarying() const
Return true iff the kernel is spatially varying (has a spatial function)
Definition: Kernel.h:334
kernelFunction
table::Key< int > kernelFunction
Definition: AnalyticKernel.cc:144
lsst::afw::math::DeltaFunctionKernel
A kernel that has only one non-zero pixel (of value 1)
Definition: Kernel.h:644
lsst::afw::math::FixedKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: FixedKernel.cc:61
lsst::afw::math::AnalyticKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: AnalyticKernel.cc:95
lsst::afw::math::LinearCombinationKernel::getKernelParameters
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
Definition: LinearCombinationKernel.cc:160
lsst::afw::math::Kernel::~Kernel
~Kernel() override=default
std::pair< double, double >
lsst::afw::math::AnalyticKernel::operator=
AnalyticKernel & operator=(const AnalyticKernel &)=delete
lsst::afw::math::Kernel::getHeight
int getHeight() const
Return the Kernel's height.
Definition: Kernel.h:230
lsst::afw::math::SeparableKernel::SeparableKernel
SeparableKernel()
Construct an empty spatially invariant SeparableKernel of size 0x0.
Definition: SeparableKernel.cc:43
lsst::afw::math::AnalyticKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: AnalyticKernel.cc:111
lsst::afw::math::deltafunction_kernel_tag
Kernel has only one non-zero pixel.
Definition: traits.h:56
lsst::afw::math::DeltaFunctionKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: DeltaFunctionKernel.cc:75
cacheSize
afw::table::Key< int > cacheSize
Definition: CoaddPsf.cc:339
lsst::afw::math::DeltaFunctionKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: DeltaFunctionKernel.cc:86
std::vector
STL class.
std::vector::size
T size(T... args)
lsst::afw::math::LinearCombinationKernel::operator=
LinearCombinationKernel & operator=(const LinearCombinationKernel &)=delete
lsst::afw::math::DeltaFunctionKernel::getPixel
lsst::geom::Point2I getPixel() const
Definition: Kernel.h:671
lsst::afw::math::DeltaFunctionKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: DeltaFunctionKernel.cc:52
lsst::afw::math::FixedKernel
A kernel created from an Image.
Definition: Kernel.h:472
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::math::FixedKernel::FixedKernel
FixedKernel(FixedKernel &&)=delete
lsst::afw::math::SeparableKernel::getKernelRowFunction
KernelFunctionPtr getKernelRowFunction() const
Get a deep copy of the row kernel function.
Definition: SeparableKernel.cc:144
lsst::afw::math::Kernel::clone
virtual std::shared_ptr< Kernel > clone() const =0
Return a pointer to a deep copy of this kernel.
lsst::afw::math::AnalyticKernel::computeImage
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: AnalyticKernel.cc:82
lsst::afw::math::Kernel::setHeight
void setHeight(int height)
Definition: Kernel.h:220
lsst::afw::math::SeparableKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: SeparableKernel.cc:97
lsst::afw::math::FixedKernel::FixedKernel
FixedKernel(const FixedKernel &)=delete
lsst::afw::math::SeparableKernel::getCacheSize
int getCacheSize() const override
Get the current cache size (0 if none)
Definition: SeparableKernel.cc:320
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::math::Kernel::growBBox
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:177
lsst::afw::math::Kernel::computeImage
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:85
lsst::afw::math::Kernel::Kernel
Kernel(Kernel &&)=delete
lsst::afw::math::SeparableKernel::~SeparableKernel
~SeparableKernel() override=default
lsst::afw::math::Kernel::getKernelParameter
virtual double getKernelParameter(unsigned int i) const
Return a particular Kernel Parameter (no bounds checking).
Definition: Kernel.h:278
lsst::afw::math::FixedKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:507
lsst::afw::math::Kernel::operator=
Kernel & operator=(Kernel &&)=delete
Image.h
lsst::afw::math::AnalyticKernel::_kernelFunctionPtr
KernelFunctionPtr _kernelFunctionPtr
Definition: Kernel.h:634
lsst::afw::math::Kernel::getCtr
lsst::geom::Point2I getCtr() const
Return index of kernel's center.
Definition: Kernel.h:235
lsst::afw::math::LinearCombinationKernel::LinearCombinationKernel
LinearCombinationKernel(const LinearCombinationKernel &)=delete
lsst::afw::math::AnalyticKernel::AnalyticKernel
AnalyticKernel(AnalyticKernel &&)=delete
lsst::afw::math::SeparableKernel::KernelFunctionPtr
std::shared_ptr< KernelFunction > KernelFunctionPtr
Definition: Kernel.h:864
lsst::afw::math::AnalyticKernel::KernelFunction
lsst::afw::math::Function2< Pixel > KernelFunction
Definition: Kernel.h:538
lsst::afw::math::FixedKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: FixedKernel.cc:67
lsst::afw::math::AnalyticKernel::setKernelParameter
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Definition: AnalyticKernel.cc:135
std::vector::push_back
T push_back(T... args)
lsst::afw::math::Kernel::Kernel
Kernel(const Kernel &)=delete
lsst::afw::math::Kernel::NullSpatialFunction
lsst::afw::math::NullFunction2< double > NullSpatialFunction
Definition: Kernel.h:116
lsst::afw::math::LinearCombinationKernel::refactor
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...
Definition: LinearCombinationKernel.cc:162
lsst::afw::math::Kernel::toString
virtual std::string toString(std::string const &prefix="") const
Return a string representation of the kernel.
Definition: Kernel.cc:195
lsst::afw::math::Kernel::setCtr
void setCtr(lsst::geom::Point2I ctr)
Set index of kernel's center.
Definition: Kernel.h:313
lsst::afw::math::AnalyticKernel::AnalyticKernel
AnalyticKernel(const AnalyticKernel &)=delete
lsst::afw::math::FixedKernel::FixedKernel
FixedKernel()
Construct an empty FixedKernel of size 0x0.
Definition: FixedKernel.cc:42
lsst::afw::math::Kernel::getCacheSize
virtual int getCacheSize() const
Get the current size of the kernel cache (0 if none or if caches not supported)
Definition: Kernel.h:404
lsst::afw::math::LinearCombinationKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: LinearCombinationKernel.cc:115
lsst::afw::math::Kernel::doComputeImage
virtual double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const =0
Low-level version of computeImage.
lsst::afw::math::SeparableKernel::getKernelColFunction
KernelFunctionPtr getKernelColFunction() const
Get a deep copy of the col kernel function.
Definition: SeparableKernel.cc:140
lsst::afw::math::LinearCombinationKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: LinearCombinationKernel.cc:227
lsst::afw::math::LinearCombinationKernel
A kernel that is a linear combination of fixed basis kernels.
Definition: Kernel.h:705
lsst::afw::math::LinearCombinationKernel::setKernelParameter
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Definition: LinearCombinationKernel.cc:270
lsst::afw::math::DeltaFunctionKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: DeltaFunctionKernel.cc:59
lsst::afw::math::SeparableKernel::getKernelParameters
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
Definition: SeparableKernel.cc:161
lsst::afw::math::DeltaFunctionKernel::operator=
DeltaFunctionKernel & operator=(DeltaFunctionKernel &&)=delete
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::afw::math::LinearCombinationKernel::getNBasisKernels
int getNBasisKernels() const
Get the number of basis kernels.
Definition: Kernel.h:769
lsst::afw::math::FixedKernel::getSum
virtual Pixel getSum() const
Definition: Kernel.h:505
lsst::afw::math::NullFunction2
a class used in function calls to indicate that no Function2 is being provided
Definition: Function.h:458
lsst::afw::math::Kernel::kernel_fill_factor
generic_kernel_tag kernel_fill_factor
Definition: Kernel.h:119
lsst::afw::math::LinearCombinationKernel::isDeltaFunctionBasis
bool isDeltaFunctionBasis() const
Return true if all basis kernels are instances of DeltaFunctionKernel.
Definition: Kernel.h:781
lsst::afw::math::Kernel::setWidth
void setWidth(int width)
Definition: Kernel.h:219
lsst::afw::math::LinearCombinationKernel::LinearCombinationKernel
LinearCombinationKernel(LinearCombinationKernel &&)=delete
lsst::afw::math::AnalyticKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: AnalyticKernel.cc:193
lsst::afw::math::DeltaFunctionKernel::~DeltaFunctionKernel
~DeltaFunctionKernel() override=default
lsst::afw::math::LinearCombinationKernel::~LinearCombinationKernel
~LinearCombinationKernel() override=default
lsst::afw::math::DeltaFunctionKernel::DeltaFunctionKernel
DeltaFunctionKernel(const DeltaFunctionKernel &)=delete
lsst::afw::math::Kernel::operator=
Kernel & operator=(const Kernel &)=delete
lsst::afw::math::FixedKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: FixedKernel.cc:104
lsst::afw::math::LinearCombinationKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: LinearCombinationKernel.cc:370
lsst::afw::math::SeparableKernel::operator=
SeparableKernel & operator=(SeparableKernel &&)=delete
lsst::afw::math::Kernel::getSpatialParameters
std::vector< std::vector< double > > getSpatialParameters() const
Return the spatial parameters parameters (an empty vector if not spatially varying)
Definition: Kernel.h:322
lsst::afw::math::DeltaFunctionKernel::DeltaFunctionKernel
DeltaFunctionKernel(int width, int height, lsst::geom::Point2I const &point)
Construct a spatially invariant DeltaFunctionKernel.
Definition: DeltaFunctionKernel.cc:42
lsst::afw::math::FixedKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: FixedKernel.cc:179
lsst::afw::math::SeparableKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: SeparableKernel.cc:172
lsst::afw::math::Kernel::shrinkBBox
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:183
lsst::afw::math::FixedKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: FixedKernel.cc:127
lsst::afw::math::Kernel::getWidth
int getWidth() const
Return the Kernel's width.
Definition: Kernel.h:225
lsst::afw::math::Function::getParameter
virtual double getParameter(unsigned int ind) const
Get one function parameter without range checking.
Definition: Function.h:119
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::math::AnalyticKernel::KernelFunctionPtr
std::shared_ptr< lsst::afw::math::Function2< Pixel > > KernelFunctionPtr
Definition: Kernel.h:539
lsst::afw::math::SeparableKernel::KernelFunction
lsst::afw::math::Function1< Pixel > KernelFunction
Definition: Kernel.h:863
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::math::SeparableKernel::computeVectors
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)
Definition: SeparableKernel.cc:123
lsst::afw::math::KernelList
std::vector< std::shared_ptr< Kernel > > KernelList
Definition: Kernel.h:463
lsst::afw::math::Kernel::_spatialFunctionList
std::vector< SpatialFunctionPtr > _spatialFunctionList
Definition: Kernel.h:450
lsst::afw::math::LinearCombinationKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: LinearCombinationKernel.cc:104
lsst::afw::math::Function2< double >
lsst::afw::table::io::Persistable
A base class for objects that can be persisted via afw::table::io Archive classes.
Definition: Persistable.h:74
lsst::afw::math::SeparableKernel::setKernelParameter
void setKernelParameter(unsigned int ind, double value) const override
Set one kernel parameter.
Definition: SeparableKernel.cc:186
lsst::afw::math::DeltaFunctionKernel::DeltaFunctionKernel
DeltaFunctionKernel(DeltaFunctionKernel &&)=delete
lsst::afw::math::AnalyticKernel
A kernel described by a function.
Definition: Kernel.h:536
lsst::afw::math::DeltaFunctionKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: DeltaFunctionKernel.cc:151
lsst::afw::math::Kernel::setKernelParameters
void setKernelParameters(std::pair< double, double > const &params)
Set the kernel parameters of a 2-component spatially invariant kernel.
Definition: Kernel.h:364
lsst::afw::math::LinearCombinationKernel::getKernelList
virtual KernelList const & getKernelList() const
Get the fixed basis kernels.
Definition: LinearCombinationKernel.cc:156
lsst::afw::math::AnalyticKernel::getKernelParameters
std::vector< double > getKernelParameters() const override
Return the current kernel parameters.
Definition: AnalyticKernel.cc:104
lsst::afw::math::Kernel::getKernelParameters
virtual std::vector< double > getKernelParameters() const
Return the current kernel parameters.
Definition: Kernel.cc:175
lsst::afw::math::FixedKernel::operator=
FixedKernel & operator=(const FixedKernel &)=delete
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::afw::math::AnalyticKernel::resized
std::shared_ptr< Kernel > resized(int width, int height) const override
Return a pointer to a clone with specified kernel dimensions.
Definition: AnalyticKernel.cc:72
lsst::afw::image.slicing.Factory
Factory
Definition: slicing.py:252
lsst::afw::math::Function::getNParameters
unsigned int getNParameters() const noexcept
Return the number of function parameters.
Definition: Function.h:112
lsst::afw::math::DeltaFunctionKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: DeltaFunctionKernel.cc:155
lsst::geom::Extent2I
Extent< int, 2 > Extent2I
Definition: Extent.h:397
lsst::afw::math::SeparableKernel::SeparableKernel
SeparableKernel(const SeparableKernel &)=delete
lsst::afw::math::DeltaFunctionKernel::kernel_fill_factor
deltafunction_kernel_tag kernel_fill_factor
Definition: Kernel.h:647
lsst::geom::Point< int, 2 >
lsst::afw::math::LinearCombinationKernel::checkKernelList
void checkKernelList(const KernelList &kernelList) const
Check that all kernels have the same size and center and that none are spatially varying.
Definition: LinearCombinationKernel.cc:132
lsst::afw::math::SeparableKernel::toString
std::string toString(std::string const &prefix="") const override
Return a string representation of the kernel.
Definition: SeparableKernel.cc:148
lsst::afw::math::SeparableKernel::getKernelParameter
double getKernelParameter(unsigned int i) const override
Return a particular Kernel Parameter (no bounds checking).
Definition: Kernel.h:934
lsst::afw::math::AnalyticKernel::AnalyticKernel
AnalyticKernel()
Construct an empty spatially invariant AnalyticKernel of size 0x0.
Definition: AnalyticKernel.cc:41
lsst::afw::table::io::PersistableFacade
A CRTP facade class for subclasses of Persistable.
Definition: Persistable.h:176
lsst::afw::math::Kernel::SpatialFunction
lsst::afw::math::Function2< double > SpatialFunction
Definition: Kernel.h:115
lsst::geom::Point2I
Point< int, 2 > Point2I
Definition: Point.h:321
lsst::afw::math::Kernel::computeCache
virtual void computeCache(int const)
Compute a cache of Kernel values, if desired.
Definition: Kernel.h:398
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::math::AnalyticKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:620
lsst::afw::math::DeltaFunctionKernel::operator=
DeltaFunctionKernel & operator=(const DeltaFunctionKernel &)=delete
lsst::afw::math::LinearCombinationKernel::doComputeImage
double doComputeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize) const override
Low-level version of computeImage.
Definition: LinearCombinationKernel.cc:247
lsst::afw::math::AnalyticKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: AnalyticKernel.cc:191
lsst::afw::math::LinearCombinationKernel::getKernelSumList
std::vector< double > getKernelSumList() const
Get the sum of the pixels of each fixed basis kernel.
Definition: LinearCombinationKernel.cc:158
lsst::afw::math::Kernel::setSpatialParameters
void setSpatialParameters(const std::vector< std::vector< double >> params)
Set the parameters of all spatial functions.
Definition: Kernel.cc:119
lsst::afw::math::Kernel
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:111
lsst::afw::math::SeparableKernel::computeCache
void computeCache(int const cacheSize) override
Compute a cache of Kernel values, if desired.
Definition: SeparableKernel.cc:310
lsst::afw::math::LinearCombinationKernel::getPersistenceName
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: LinearCombinationKernel.cc:366
lsst::afw::math::Kernel::SpatialFunctionPtr
std::shared_ptr< lsst::afw::math::Function2< double > > SpatialFunctionPtr
Definition: Kernel.h:114
lsst::afw::image::Image< Pixel >
traits.h
lsst::afw::math::Kernel::getPythonModule
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:235
lsst::afw::math::Kernel::setKernelParameters
void setKernelParameters(std::vector< double > const &params)
Set the kernel parameters of a spatially invariant kernel.
Definition: Kernel.h:342
lsst::afw::math::Kernel::getSpatialFunctionList
std::vector< SpatialFunctionPtr > getSpatialFunctionList() const
Return a list of clones of the spatial functions.
Definition: Kernel.cc:166
lsst::afw::math::AnalyticKernel::clone
std::shared_ptr< Kernel > clone() const override
Return a pointer to a deep copy of this kernel.
Definition: AnalyticKernel.cc:60
lsst::afw::math::Function1
A Function taking one argument.
Definition: Function.h:202
lsst::afw::math::generic_kernel_tag
Tags carrying information about Kernels Kernel with no special properties.
Definition: traits.h:53
lsst::afw::math::FixedKernel::~FixedKernel
~FixedKernel() override=default
lsst::afw::math::FixedKernel::write
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: FixedKernel.cc:181
lsst::afw::math::LinearCombinationKernel::operator=
LinearCombinationKernel & operator=(LinearCombinationKernel &&)=delete
Function.h
lsst::afw::math::Kernel::Kernel
Kernel()
Construct a null Kernel of size 0,0.
Definition: Kernel.cc:58
lsst::afw::math::Kernel::resized
virtual std::shared_ptr< Kernel > resized(int width, int height) const =0
Return a pointer to a clone with specified kernel dimensions.
lsst::afw::math::FixedKernel::operator=
FixedKernel & operator=(FixedKernel &&)=delete
lsst::afw::table::io::Persistable::OutputArchiveHandle
io::OutputArchiveHandle OutputArchiveHandle
Definition: Persistable.h:108
lsst::geom::Extent< int, 2 >
lsst::afw::math::AnalyticKernel::~AnalyticKernel
~AnalyticKernel() override=default
geom.h
lsst::afw::math::Kernel::getNKernelParameters
unsigned int getNKernelParameters() const
Return the number of kernel parameters (0 if none)
Definition: Kernel.h:247
lsst::afw::math::AnalyticKernel::getKernelFunction
virtual KernelFunctionPtr getKernelFunction() const
Get a deep copy of the kernel function.
Definition: AnalyticKernel.cc:91
prefix
std::string prefix
Definition: SchemaMapper.cc:79
lsst::afw::math::SeparableKernel
A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y)
Definition: Kernel.h:861
lsst::afw::math::LinearCombinationKernel::isPersistable
bool isPersistable() const noexcept override
Return true if this particular object can be persisted using afw::table::io.
Definition: Kernel.h:821
lsst::afw::math::SeparableKernel::SeparableKernel
SeparableKernel(SeparableKernel &&)=delete
lsst::afw::math::Kernel::setDimensions
void setDimensions(lsst::geom::Extent2I dims)
Definition: Kernel.h:215
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst.pex::exceptions::RuntimeError
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104
lsst::afw::math::Kernel::computeKernelParametersFromSpatialModel
void computeKernelParametersFromSpatialModel(std::vector< double > &kernelParams, double x, double y) const
Compute the kernel parameters at a specified point.
Definition: Kernel.cc:144
lsst::afw::math::Kernel::Pixel
double Pixel
Definition: Kernel.h:113
lsst::afw::math::Kernel::getSpatialFunction
SpatialFunctionPtr getSpatialFunction(unsigned int index) const
Return a clone of the specified spatial function (one component of the spatial model)
Definition: Kernel.cc:153