444 PTR(afwImage::Image<afwMath::Kernel::Pixel>) negPsf = psf->computeImage(negCenter);
445 PTR(afwImage::Image<afwMath::Kernel::Pixel>) posPsf = psf->computeImage(posCenter);
447 afwImage::Image<
double> negModel(footprint->getBBox());
448 afwImage::Image<
double> posModel(footprint->getBBox());
449 afwImage::Image<
PixelT> data(*(exposure.getMaskedImage().getImage()),
450 footprint->getBBox());
451 afwImage::Image<afwImage::
VariancePixel> var(*(exposure.getMaskedImage().getVariance()),
452 footprint->getBBox());
454 afwGeom::Box2I negPsfBBox = negPsf->getBBox();
455 afwGeom::Box2I posPsfBBox = posPsf->getBBox();
456 afwGeom::Box2I negModelBBox = negModel.getBBox();
457 afwGeom::Box2I posModelBBox = posModel.getBBox();
460 int negXmin = std::
max(negPsfBBox.getMinX(), negModelBBox.getMinX());
461 int negYmin = std::
max(negPsfBBox.getMinY(), negModelBBox.getMinY());
462 int negXmax = std::
min(negPsfBBox.getMaxX(), negModelBBox.getMaxX());
463 int negYmax = std::
min(negPsfBBox.getMaxY(), negModelBBox.getMaxY());
464 afwGeom::Box2I negBBox = afwGeom::Box2I(afwGeom::
Point2I(negXmin, negYmin),
465 afwGeom::
Point2I(negXmax, negYmax));
466 afwImage::Image<afwMath::Kernel::Pixel> negSubim(*negPsf, negBBox);
467 afwImage::Image<
double> negModelSubim(negModel, negBBox);
468 negModelSubim += negSubim;
471 int posXmin = std::
max(posPsfBBox.getMinX(), posModelBBox.getMinX());
472 int posYmin = std::
max(posPsfBBox.getMinY(), posModelBBox.getMinY());
473 int posXmax = std::
min(posPsfBBox.getMaxX(), posModelBBox.getMaxX());
474 int posYmax = std::
min(posPsfBBox.getMaxY(), posModelBBox.getMaxY());
475 afwGeom::Box2I posBBox = afwGeom::Box2I(afwGeom::
Point2I(posXmin, posYmin),
476 afwGeom::
Point2I(posXmax, posYmax));
477 afwImage::Image<afwMath::Kernel::Pixel> posSubim(*posPsf, posBBox);
478 afwImage::Image<
double> posModelSubim(posModel, posBBox);
479 posModelSubim += posSubim;
483 afwImage::Image<
double> residuals(negModel, true);
484 residuals += posModel;
486 residuals *= residuals;
489 double chi2 = stats.getValue(afwMath::
SUM);
490 int nPix = stats.getValue(afwMath::NPOINT);
491 return std::pair<
double,
int>(
chi2, nPix);
Point< double, 2 > Point2D
std::pair< double, int > chi2(afw::table::SourceRecord &source, afw::image::Exposure< PixelT > const &exposure, double negCenterX, double negCenterY, double negFlux, double posCenterX, double poCenterY, double posFlux) const
lsst::afw::detection::Footprint Footprint
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
find sum of pixels in the image
float VariancePixel
! default type for Masks and MaskedImage Masks