2 #if !defined(LSST_MEAS_ALGORITHMS_PSFCANDIDATE_H) 3 #define LSST_MEAS_ALGORITHMS_PSFCANDIDATE_H 37 #include "lsst/pex/policy.h" 39 #include "lsst/afw/image/Exposure.h" 40 #include "lsst/afw/detection/Psf.h" 41 #include "lsst/afw/detection/FootprintSet.h" 42 #include "lsst/afw/table/Source.h" 43 #include "lsst/afw/math/SpatialCell.h" 47 namespace algorithms {
55 template <
typename PixelT>
56 class PsfCandidate :
public lsst::afw::math::SpatialCellImageCandidate {
59 typedef std::shared_ptr<PsfCandidate<PixelT> >
Ptr;
60 typedef std::shared_ptr<const PsfCandidate<PixelT> >
ConstPtr;
71 PTR(afw::table::SourceRecord)
const& source,
72 CONST_PTR(afw::image::Exposure<PixelT>) parentExposure
74 afw::math::SpatialCellImageCandidate(source->getX(), source->getY()),
75 _parentExposure(parentExposure),
79 _amplitude(0.0), _var(1.0)
86 PTR(afw::table::SourceRecord)
const& source,
87 CONST_PTR(afw::image::Exposure<PixelT>) parentExposure,
91 afw::math::SpatialCellImageCandidate(xCenter, yCenter),
92 _parentExposure(parentExposure),
96 _amplitude(0.0), _var(1.0)
110 PTR(afw::table::SourceRecord)
getSource()
const {
return _source; }
124 CONST_PTR(afw::image::MaskedImage<PixelT>)
getMaskedImage()
const;
125 CONST_PTR(afw::image::MaskedImage<PixelT>)
getMaskedImage(
int width,
int height)
const;
126 PTR(afw::image::MaskedImage<PixelT>)
getOffsetImage(std::string
const algorithm,
127 unsigned int buffer)
const;
144 static void setMaskBlends(
bool doMaskBlends) { _doMaskBlends = doMaskBlends; }
150 CONST_PTR(lsst::afw::image::Exposure<PixelT>) _parentExposure;
152 PTR(afw::image::MaskedImage<PixelT>)
154 PTR(afw::image::MaskedImage<PixelT>) img,
155 std::string
const algorithm,
159 PTR(afw::image::MaskedImage<PixelT>)
160 extractImage(
unsigned int width,
unsigned int height)
const;
162 PTR(afw::image::MaskedImage<PixelT>)
mutable _offsetImage;
163 PTR(afw::table::SourceRecord) _source;
165 mutable std::shared_ptr<afw::image::MaskedImage<PixelT>> _image;
169 afw::geom::Point2D _xyCenter;
170 static int _defaultWidth;
171 static float _pixelThreshold;
172 static bool _doMaskBlends;
180 template <
typename PixelT>
181 std::shared_ptr<PsfCandidate<PixelT> >
183 PTR(afw::image::Exposure<PixelT>)
image 186 return std::make_shared< PsfCandidate<PixelT> >(source, image);
PsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > const > parentExposure)
Construct a PsfCandidate from a specified source and image.
boost::shared_ptr< afw::image::MaskedImage< PixelT > > getOffsetImage(std::string const algorithm, unsigned int buffer) const
Return an offset version of the image of the source.
void setAmplitude(double amplitude)
Set the best-fit amplitude.
std::shared_ptr< PsfCandidate< PixelT > > Ptr
std::shared_ptr< const PsfCandidate< PixelT > > ConstPtr
static void setPixelThreshold(float threshold)
Set threshold for rejecting pixels unconnected with the central footprint.
boost::shared_ptr< afw::image::MaskedImage< PixelT > const > getMaskedImage() const
Return the image at the position of the Source, without any sub-pixel shifts to put the centre of the...
static void setMaskBlends(bool doMaskBlends)
Set whether blends are masked.
double getCandidateRating() const
Return Cell rating.
PsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > const > parentExposure, double xCenter, double yCenter)
Construct a PsfCandidate from a specified source, image and xyCenter.
boost::shared_ptr< afw::table::SourceRecord > getSource() const
Return the original Source.
virtual ~PsfCandidate()
Destructor.
double getVar() const
Return the variance in use when fitting this object.
double getAmplitude() const
Return the best-fit amplitude.
static bool getMaskBlends()
Get whether blends are masked.
void setVar(double var)
Set the variance to use when fitting this object.
std::shared_ptr< PsfCandidate< PixelT > > makePsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > > image)
Return a PsfCandidate of the right sort.
static float getPixelThreshold()
Get threshold for rejecting pixels unconnected with the central footprint.
static int getBorderWidth()
Return the number of pixels being ignored around the candidate image's edge.
std::vector< Ptr > PtrList
static void setBorderWidth(int border)
Set the number of pixels to ignore around the candidate image's edge.
Class stored in SpatialCells for spatial Psf fitting.
lsst::afw::image::MaskedImage< PixelT > MaskedImageT