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
PsfCandidate.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 #if !defined(LSST_MEAS_ALGORITHMS_PSFCANDIDATE_H)
3 #define LSST_MEAS_ALGORITHMS_PSFCANDIDATE_H
4 
5 /*
6  * LSST Data Management System
7  * Copyright 2008, 2009, 2010 LSST Corporation.
8  *
9  * This product includes software developed by the
10  * LSST Project (http://www.lsst.org/).
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the LSST License Statement and
23  * the GNU General Public License along with this program. If not,
24  * see <http://www.lsstcorp.org/LegalNotices/>.
25  */
26 
34 #include <memory>
35 #include <vector>
36 
37 #include "lsst/geom/Point.h"
39 #include "lsst/afw/detection/Psf.h"
41 #include "lsst/afw/table/Source.h"
43 
44 namespace lsst {
45 namespace meas {
46 namespace algorithms {
54 template <typename PixelT>
56 public:
60 
62 
70  parentExposure
71  )
72  : afw::math::SpatialCellImageCandidate(source->getX(), source->getY()),
73  _parentExposure(parentExposure),
74  _offsetImage(),
75  _source(source),
76  _image(nullptr),
77  _amplitude(0.0),
78  _var(1.0) {}
79 
85  parentExposure,
86  double xCenter,
87  double yCenter
88  )
89  : afw::math::SpatialCellImageCandidate(xCenter, yCenter),
90  _parentExposure(parentExposure),
91  _offsetImage(),
92  _source(source),
93  _image(nullptr),
94  _amplitude(0.0),
95  _var(1.0) {}
96 
98  virtual ~PsfCandidate(){};
99 
105  double getCandidateRating() const { return _source->getPsfInstFlux(); }
106 
108  PTR(afw::table::SourceRecord) getSource() const { return _source; }
109 
111  double getAmplitude() const { return _amplitude; }
112 
114  void setAmplitude(double amplitude) { _amplitude = amplitude; }
115 
117  double getVar() const { return _var; }
118 
120  void setVar(double var) { _var = var; }
121 
123  CONST_PTR(afw::image::MaskedImage<PixelT>) getMaskedImage(int width, int height) const;
125  getOffsetImage(std::string const algorithm, unsigned int buffer) const;
126 
128  static int getBorderWidth();
129 
131  static void setBorderWidth(int border);
132 
136  static void setPixelThreshold(float threshold);
137 
139  static float getPixelThreshold();
140 
142  static void setMaskBlends(bool doMaskBlends);
143 
145  static bool getMaskBlends();
146 
147 private:
149  _parentExposure; // the %image that the Sources are found in
150 
152  offsetImage(PTR(afw::image::MaskedImage<PixelT>) img, std::string const algorithm, unsigned int buffer);
153 
155  extractImage(unsigned int width, unsigned int height) const;
156 
157  PTR(afw::image::MaskedImage<PixelT>) mutable _offsetImage; // %image offset to put center on a pixel
158  PTR(afw::table::SourceRecord) _source; // the Source itself
159 
160  mutable std::shared_ptr<afw::image::MaskedImage<PixelT>> _image; // cutout image to return (cached)
161  double _amplitude; // best-fit amplitude of current PSF model
162  double _var; // variance to use when fitting this candidate
163  static int _border; // width of border of ignored pixels around _image
164  geom::Point2D _xyCenter;
165  static int _defaultWidth;
166  static float _pixelThreshold;
167  static bool _doMaskBlends;
168 };
169 
175 template <typename PixelT>
177  const & source,
179  image
180  ) {
181  return std::make_shared<PsfCandidate<PixelT>>(source, image);
182 }
183 
184 } // namespace algorithms
185 } // namespace meas
186 } // namespace lsst
187 
188 #endif
lsst::meas::algorithms::PsfCandidate::getMaskBlends
static bool getMaskBlends()
Get whether blends are masked.
Definition: PsfCandidate.cc:323
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::meas::algorithms::PsfCandidate::setVar
void setVar(double var)
Set the variance to use when fitting this object.
Definition: PsfCandidate.h:120
lsst::meas::algorithms::PsfCandidate::setMaskBlends
static void setMaskBlends(bool doMaskBlends)
Set whether blends are masked.
Definition: PsfCandidate.cc:318
std::string
STL class.
std::shared_ptr
STL class.
Psf.h
lsst::afw::table::SourceRecord
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
lsst::afw::image::Exposure
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
lsst::afw::math::SpatialCellImageCandidate::SpatialCellImageCandidate
SpatialCellImageCandidate(float const xCenter, float const yCenter)
ctor
Definition: SpatialCell.h:129
lsst::meas::algorithms::PsfCandidate::PsfCandidate
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.
Definition: PsfCandidate.h:68
std::vector
STL class.
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::meas::algorithms::PsfCandidate::~PsfCandidate
virtual ~PsfCandidate()
Destructor.
Definition: PsfCandidate.h:98
PTR
#define PTR(...)
Definition: base.h:41
lsst::meas::algorithms::PsfCandidate::getCandidateRating
double getCandidateRating() const
Return Cell rating.
Definition: PsfCandidate.h:105
lsst::meas::algorithms::PsfCandidate::PsfCandidate
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.
Definition: PsfCandidate.h:83
Point.h
lsst::afw::image::MaskedImage< PixelT >
lsst::meas::algorithms::PsfCandidate::setAmplitude
void setAmplitude(double amplitude)
Set the best-fit amplitude.
Definition: PsfCandidate.h:114
ast::detail::source
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
lsst::meas::algorithms::PsfCandidate::MaskedImageT
afw::image::MaskedImage< PixelT > MaskedImageT
Definition: PsfCandidate.h:61
image
afw::table::Key< afw::table::Array< ImagePixelT > > image
Definition: HeavyFootprint.cc:216
lsst::meas::algorithms::PsfCandidate::getAmplitude
double getAmplitude() const
Return the best-fit amplitude.
Definition: PsfCandidate.h:111
lsst::meas::algorithms::PsfCandidate::getBorderWidth
static int getBorderWidth()
Return the number of pixels being ignored around the candidate image's edge.
Definition: PsfCandidate.cc:298
lsst::meas::algorithms::PsfCandidate::setBorderWidth
static void setBorderWidth(int border)
Set the number of pixels to ignore around the candidate image's edge.
Definition: PsfCandidate.cc:303
lsst::afw::math::SpatialCellImageCandidate
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e....
Definition: SpatialCell.h:126
lsst::meas::algorithms::PsfCandidate::PtrList
std::vector< Ptr > PtrList
Definition: PsfCandidate.h:59
SpatialCell.h
lsst::meas::algorithms::PsfCandidate::getVar
double getVar() const
Return the variance in use when fitting this object.
Definition: PsfCandidate.h:117
FootprintSet.h
lsst::meas::algorithms::makePsfCandidate
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.
Definition: PsfCandidate.h:176
CONST_PTR
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
Source.h
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::meas::algorithms::PsfCandidate::ConstPtr
std::shared_ptr< const PsfCandidate< PixelT > > ConstPtr
Definition: PsfCandidate.h:58
lsst::meas::algorithms::PsfCandidate::getMaskedImage
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...
Definition: PsfCandidate.cc:291
lsst::meas::algorithms::PsfCandidate::getOffsetImage
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.
Definition: PsfCandidate.cc:334
lsst::meas::algorithms::PsfCandidate::getPixelThreshold
static float getPixelThreshold()
Get threshold for rejecting pixels unconnected with the central footprint.
Definition: PsfCandidate.cc:313
lsst::meas::algorithms::PsfCandidate
Class stored in SpatialCells for spatial Psf fitting.
Definition: PsfCandidate.h:55
lsst::geom::Point< double, 2 >
lsst::meas::algorithms::PsfCandidate::setPixelThreshold
static void setPixelThreshold(float threshold)
Set threshold for rejecting pixels unconnected with the central footprint.
Definition: PsfCandidate.cc:308
Exposure.h
lsst::meas::algorithms::PsfCandidate::getSource
boost::shared_ptr< afw::table::SourceRecord > getSource() const
Return the original Source.
Definition: PsfCandidate.h:108
lsst::meas::algorithms::PsfCandidate::Ptr
std::shared_ptr< PsfCandidate< PixelT > > Ptr
Definition: PsfCandidate.h:57