12 #ifndef LSST_IP_DIFFIM_KERNELSOLUTION_H 13 #define LSST_IP_DIFFIM_KERNELSOLUTION_H 18 #include "lsst/afw/math.h" 19 #include "lsst/afw/geom.h" 20 #include "lsst/afw/image.h" 32 typedef std::shared_ptr<KernelSolution>
Ptr;
33 typedef lsst::afw::math::Kernel::Pixel
PixelT;
34 typedef lsst::afw::image::Image<lsst::afw::math::Kernel::Pixel>
ImageT;
51 bool fitForBackground);
57 virtual void solve(Eigen::MatrixXd
const& mMat,
58 Eigen::VectorXd
const& bVec);
63 inline Eigen::MatrixXd
const&
getM() {
return _mMat;}
64 inline Eigen::VectorXd
const&
getB() {
return _bVec;}
81 template <
typename InputT>
84 typedef std::shared_ptr<StaticKernelSolution<InputT> >
Ptr;
87 bool fitForBackground);
94 virtual void build(lsst::afw::image::Image<InputT>
const &templateImage,
95 lsst::afw::image::Image<InputT>
const &scienceImage,
96 lsst::afw::image::Image<lsst::afw::image::VariancePixel>
const &varianceEstimate);
97 virtual std::shared_ptr<lsst::afw::math::Kernel> getKernel();
98 virtual std::shared_ptr<lsst::afw::image::Image<lsst::afw::math::Kernel::Pixel>> makeKernelImage();
99 virtual double getBackground();
100 virtual double getKsum();
101 virtual std::pair<std::shared_ptr<lsst::afw::math::Kernel>,
double> getSolutionPair();
108 std::shared_ptr<lsst::afw::math::Kernel>
_kernel;
113 void _setKernelUncertainty();
117 template <
typename InputT>
120 typedef std::shared_ptr<MaskedKernelSolution<InputT> >
Ptr;
123 bool fitForBackground);
125 virtual void buildOrig(lsst::afw::image::Image<InputT>
const &templateImage,
126 lsst::afw::image::Image<InputT>
const &scienceImage,
127 lsst::afw::image::Image<lsst::afw::image::VariancePixel>
128 const &varianceEstimate,
129 lsst::afw::image::Mask<lsst::afw::image::MaskPixel> pixelMask);
131 virtual void buildWithMask(lsst::afw::image::Image<InputT>
const &templateImage,
132 lsst::afw::image::Image<InputT>
const &scienceImage,
133 lsst::afw::image::Image<lsst::afw::image::VariancePixel>
134 const &varianceEstimate,
135 lsst::afw::image::Mask<lsst::afw::image::MaskPixel>
const &pixelMask);
137 virtual void buildSingleMaskOrig(lsst::afw::image::Image<InputT>
const &templateImage,
138 lsst::afw::image::Image<InputT>
const &scienceImage,
139 lsst::afw::image::Image<lsst::afw::image::VariancePixel>
140 const &varianceEstimate,
141 lsst::afw::geom::Box2I maskBox);
146 template <
typename InputT>
149 typedef std::shared_ptr<RegularizedKernelSolution<InputT> >
Ptr;
152 bool fitForBackground,
153 Eigen::MatrixXd
const& hMat,
154 lsst::pex::policy::Policy policy
159 double estimateRisk(
double maxCond);
162 Eigen::MatrixXd
getM(
bool includeHmat =
true);
169 std::vector<double> _createLambdaSteps();
175 typedef std::shared_ptr<SpatialKernelSolution>
Ptr;
179 lsst::afw::math::Kernel::SpatialFunctionPtr spatialKernelFunction,
180 lsst::afw::math::Kernel::SpatialFunctionPtr background,
181 lsst::pex::policy::Policy policy
186 void addConstraint(
float xCenter,
float yCenter,
187 Eigen::MatrixXd
const& qMat,
188 Eigen::VectorXd
const& wVec);
191 std::shared_ptr<lsst::afw::image::Image<lsst::afw::math::Kernel::Pixel>> makeKernelImage(lsst::afw::geom::Point2D
const& pos);
192 std::pair<std::shared_ptr<lsst::afw::math::LinearCombinationKernel>,
193 lsst::afw::math::Kernel::SpatialFunctionPtr> getSolutionPair();
199 std::shared_ptr<lsst::afw::math::LinearCombinationKernel>
_kernel;
210 void _setKernelUncertainty();
std::shared_ptr< SpatialKernelSolution > Ptr
std::shared_ptr< RegularizedKernelSolution< InputT > > Ptr
Eigen::MatrixXd _cMat
K_i x R.
Eigen::VectorXd _bVec
Derived least squares B vector.
virtual ~SpatialKernelSolution()
KernelSolvedBy _solvedBy
Type of algorithm used to make solution.
double _background
Derived differential background estimate.
Eigen::VectorXd _iVec
Vectorized I.
lsst::afw::math::Kernel::Pixel PixelT
Eigen::VectorXd _ivVec
Inverse variance.
virtual ~RegularizedKernelSolution()
Eigen::VectorXd const & getB()
std::shared_ptr< StaticKernelSolution< InputT > > Ptr
double _kSum
Derived kernel sum.
static int _SolutionId
Unique identifier for solution.
bool _fitForBackground
Background terms included in fit.
lsst::afw::image::Image< lsst::afw::math::Kernel::Pixel > ImageT
virtual double getConditionNumber(ConditionNumberType conditionType)
int _id
Unique ID for object.
KernelSolvedBy getSolvedBy()
std::shared_ptr< KernelSolution > Ptr
lsst::afw::math::Kernel::SpatialFunctionPtr _spatialKernelFunction
Spatial function for Kernel.
Eigen::MatrixXd const _hMat
Regularization weights.
int _nbt
Number of background terms.
Eigen::MatrixXd _mMat
Derived least squares M matrix.
bool _constantFirstTerm
Is the first term constant.
lsst::pex::policy::Policy _policy
Policy to control processing.
double _kSum
Derived kernel sum.
lsst::afw::math::Kernel::SpatialFunctionPtr _background
Spatial background model.
int _nkt
Number of kernel terms.
std::shared_ptr< lsst::afw::math::LinearCombinationKernel > _kernel
Spatial convolution kernel.
int _nbases
Number of basis functions.
virtual ~StaticKernelSolution()
Eigen::MatrixXd const & getM()
Eigen::VectorXd _aVec
Derived least squares solution matrix.
double _lambda
Overall regularization strength.
std::shared_ptr< lsst::afw::math::Kernel > _kernel
Derived single-object convolution kernel.
std::shared_ptr< MaskedKernelSolution< InputT > > Ptr
lsst::pex::policy::Policy _policy
virtual ~KernelSolution()
virtual ~MaskedKernelSolution()
int _nt
Total number of terms.