512 "Error: variance less than 0.0");
516 "Error: variance equals 0.0, cannot inverse variance weight");
524 std::dynamic_pointer_cast<afwMath::LinearCombinationKernel>(this->
_kernel)->getKernelList();
539 int growPix = (*kiter)->getCtr().getX();
543 for (
typename afwDet::FootprintSet::FootprintList::iterator
544 ptr = maskedFpSetGrown.getFootprints()->begin(),
545 end = maskedFpSetGrown.getFootprints()->end();
549 afwDet::setMaskFromFootprint(finalMask,
556 for (
auto const & foot : *(maskedFpSetGrown.getFootprints())) {
560 finalMask.writeFits(
"finalmask.fits");
563 ndarray::Array<int, 1, 1> maskArray =
564 ndarray::allocate(ndarray::makeVector(fullFp->getArea()));
565 fullFp->getSpans()->flatten(maskArray, finalMask.getArray(), templateImage.
getXY0());
566 auto maskEigen = ndarray::asEigenMatrix(maskArray);
568 ndarray::Array<InputT, 1, 1> arrayTemplate =
569 ndarray::allocate(ndarray::makeVector(fullFp->getArea()));
570 fullFp->getSpans()->flatten(arrayTemplate, templateImage.
getArray(), templateImage.
getXY0());
571 auto eigenTemplate0 = ndarray::asEigenMatrix(arrayTemplate);
573 ndarray::Array<InputT, 1, 1> arrayScience =
574 ndarray::allocate(ndarray::makeVector(fullFp->getArea()));
575 fullFp->getSpans()->flatten(arrayScience, scienceImage.
getArray(), scienceImage.
getXY0());
576 auto eigenScience0 = ndarray::asEigenMatrix(arrayScience);
578 ndarray::Array<afwImage::VariancePixel, 1, 1> arrayVariance =
579 ndarray::allocate(ndarray::makeVector(fullFp->getArea()));
580 fullFp->getSpans()->flatten(arrayVariance, varianceEstimate.
getArray(), varianceEstimate.
getXY0());
581 auto eigenVariance0 = ndarray::asEigenMatrix(arrayVariance);
584 for (
int i = 0; i < maskEigen.size(); i++) {
585 if (maskEigen(i) == 0.0)
589 Eigen::VectorXd eigenTemplate(nGood);
590 Eigen::VectorXd eigenScience(nGood);
591 Eigen::VectorXd eigenVariance(nGood);
593 for (
int i = 0; i < maskEigen.size(); i++) {
594 if (maskEigen(i) == 0.0) {
595 eigenTemplate(nUsed) = eigenTemplate0(i);
596 eigenScience(nUsed) = eigenScience0(i);
597 eigenVariance(nUsed) = eigenVariance0(i);
606 unsigned int const nKernelParameters = basisList.
size();
608 unsigned int const nParameters = nKernelParameters + nBackgroundParameters;
622 for (kiter = basisList.
begin(); kiter != basisList.
end(); ++kiter, ++eiter) {
625 ndarray::Array<InputT, 1, 1> arrayC =
626 ndarray::allocate(ndarray::makeVector(fullFp->getArea()));
627 fullFp->getSpans()->flatten(arrayC, cimage.getArray(), cimage.getXY0());
628 auto eigenC0 = ndarray::asEigenMatrix(arrayC);
630 Eigen::VectorXd eigenC(nGood);
632 for (
int i = 0; i < maskEigen.size(); i++) {
633 if (maskEigen(i) == 0.0) {
634 eigenC(nUsed) = eigenC0(i);
641 double time = t.elapsed();
642 LOGL_DEBUG(
"TRACE3.ip.diffim.StaticKernelSolution.buildWithMask",
643 "Total compute time to do basis convolutions : %.2f s", time);
647 Eigen::MatrixXd cMat(eigenTemplate.size(), nParameters);
650 for (
unsigned int kidxj = 0; eiterj != eiterE; eiterj++, kidxj++) {
651 cMat.block(0, kidxj, eigenTemplate.size(), 1) =
652 Eigen::MatrixXd(*eiterj).block(0, 0, eigenTemplate.size(), 1);
656 cMat.col(nParameters-1).fill(1.);
659 this->
_ivVec = eigenVariance.array().inverse().matrix();
660 this->
_iVec = eigenScience;
A Threshold is used to pass a threshold value to detection algorithms.
@ BITMASK
Use (pixels & (given mask))
lsst::geom::Point2I getXY0() const
Return the image's origin.
void writeFits(std::string const &fileName, std::shared_ptr< lsst::daf::base::PropertySet const > metadata=std::shared_ptr< lsst::daf::base::PropertySet >(), std::string const &mode="w") const
Write a mask to a regular FITS file.