LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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/pex/policy.h"
38 
40 #include "lsst/afw/detection/Psf.h"
42 #include "lsst/afw/table/Source.h"
44 
45 namespace lsst {
46 namespace meas {
47 namespace algorithms {
55  template <typename PixelT>
57  public:
58 
59  typedef std::shared_ptr<PsfCandidate<PixelT> > Ptr;
60  typedef std::shared_ptr<const PsfCandidate<PixelT> > ConstPtr;
61  typedef std::vector<Ptr > PtrList;
62 
64 
71  PTR(afw::table::SourceRecord) const& source,
73  ) :
74  afw::math::SpatialCellImageCandidate(source->getX(), source->getY()),
75  _parentExposure(parentExposure),
76  _offsetImage(),
77  _source(source),
78  _image(nullptr),
79  _amplitude(0.0), _var(1.0)
80  {}
81 
86  PTR(afw::table::SourceRecord) const& source,
87  CONST_PTR(afw::image::Exposure<PixelT>) parentExposure,
88  double xCenter,
89  double yCenter
90  ) :
91  afw::math::SpatialCellImageCandidate(xCenter, yCenter),
92  _parentExposure(parentExposure),
93  _offsetImage(),
94  _source(source),
95  _image(nullptr),
96  _amplitude(0.0), _var(1.0)
97  {}
98 
100  virtual ~PsfCandidate() {};
101 
107  double getCandidateRating() const { return _source->getPsfFlux(); }
108 
111 
113  double getAmplitude() const { return _amplitude; }
114 
116  void setAmplitude(double amplitude) { _amplitude = amplitude; }
117 
119  double getVar() const { return _var; }
120 
122  void setVar(double var) { _var = var; }
123 
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;
128 
130  static int getBorderWidth() { return _border; }
131 
133  static void setBorderWidth(int border) { _border = border; }
134 
138  static void setPixelThreshold(float threshold) { _pixelThreshold = threshold; }
139 
141  static float getPixelThreshold() { return _pixelThreshold; }
142 
144  static void setMaskBlends(bool doMaskBlends) { _doMaskBlends = doMaskBlends; }
145 
147  static bool getMaskBlends() { return _doMaskBlends; }
148 
149  private:
150  CONST_PTR(lsst::afw::image::Exposure<PixelT>) _parentExposure; // the %image that the Sources are found in
151 
152  PTR(afw::image::MaskedImage<PixelT>)
153  offsetImage(
154  PTR(afw::image::MaskedImage<PixelT>) img,
155  std::string const algorithm,
156  unsigned int buffer
157  );
158 
159  PTR(afw::image::MaskedImage<PixelT>)
160  extractImage(unsigned int width, unsigned int height) const;
161 
162  PTR(afw::image::MaskedImage<PixelT>) mutable _offsetImage; // %image offset to put center on a pixel
163  PTR(afw::table::SourceRecord) _source; // the Source itself
164 
165  mutable std::shared_ptr<afw::image::MaskedImage<PixelT>> _image; // cutout image to return (cached)
166  double _amplitude; // best-fit amplitude of current PSF model
167  double _var; // variance to use when fitting this candidate
168  static int _border; // width of border of ignored pixels around _image
169  afw::geom::Point2D _xyCenter;
170  static int _defaultWidth;
171  static float _pixelThreshold;
172  static bool _doMaskBlends;
173  };
174 
180  template <typename PixelT>
181  std::shared_ptr<PsfCandidate<PixelT> >
182  makePsfCandidate(PTR(afw::table::SourceRecord) const& source,
183  PTR(afw::image::Exposure<PixelT>) image
184  )
185  {
186  return std::make_shared< PsfCandidate<PixelT> >(source, image);
187  }
188 
189 }}}
190 
191 #endif
void setAmplitude(double amplitude)
Set the best-fit amplitude.
Definition: PsfCandidate.h:116
std::shared_ptr< PsfCandidate< PixelT > > Ptr
Definition: PsfCandidate.h:59
std::shared_ptr< const PsfCandidate< PixelT > > ConstPtr
Definition: PsfCandidate.h:60
static void setPixelThreshold(float threshold)
Set threshold for rejecting pixels unconnected with the central footprint.
Definition: PsfCandidate.h:138
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:85
double getCandidateRating() const
Return Cell rating.
Definition: PsfCandidate.h:107
std::shared_ptr< afw::image::MaskedImage< PixelT > > _image
Definition: PsfCandidate.h:165
static void setMaskBlends(bool doMaskBlends)
Set whether blends are masked.
Definition: PsfCandidate.h:144
boost::shared_ptr< afw::table::SourceRecord > getSource() const
Return the original Source.
Definition: PsfCandidate.h:110
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:46
static float _pixelThreshold
Threshold for masking pixels unconnected with central footprint.
Definition: PsfCandidate.h:171
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...
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
Represent a collections of footprints associated with image data.
boost::shared_ptr< afw::image::MaskedImage< PixelT > > extractImage(unsigned int width, unsigned int height) const
Extract an image of the candidate.
virtual ~PsfCandidate()
Destructor.
Definition: PsfCandidate.h:100
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
SpatialCellImageCandidate(float const xCenter, float const yCenter)
ctor
Definition: SpatialCell.h:138
static bool getMaskBlends()
Get whether blends are masked.
Definition: PsfCandidate.h:147
double getAmplitude() const
Return the best-fit amplitude.
Definition: PsfCandidate.h:113
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:78
boost::shared_ptr< afw::image::MaskedImage< PixelT > > offsetImage(boost::shared_ptr< afw::image::MaskedImage< PixelT > > img, std::string const algorithm, unsigned int buffer)
boost::shared_ptr< afw::image::MaskedImage< PixelT > > _offsetImage
Definition: PsfCandidate.h:162
void setVar(double var)
Set the variance to use when fitting this object.
Definition: PsfCandidate.h:122
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:182
static bool _doMaskBlends
Mask blends when extracting?
Definition: PsfCandidate.h:172
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
static float getPixelThreshold()
Get threshold for rejecting pixels unconnected with the central footprint.
Definition: PsfCandidate.h:141
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:70
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e...
Definition: SpatialCell.h:132
static int getBorderWidth()
Return the number of pixels being ignored around the candidate image&#39;s edge.
Definition: PsfCandidate.h:130
#define PTR(...)
Definition: base.h:41
Class to ensure constraints for spatial modeling.
Point< double, 2 > Point2D
Definition: Point.h:288
Record class that contains measurements made on a single exposure.
Definition: Source.h:80
boost::shared_ptr< lsst::afw::image::Exposure< PixelT > const > _parentExposure
Definition: PsfCandidate.h:150
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.
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
boost::shared_ptr< afw::table::SourceRecord > _source
Definition: PsfCandidate.h:163
static void setBorderWidth(int border)
Set the number of pixels to ignore around the candidate image&#39;s edge.
Definition: PsfCandidate.h:133
Class stored in SpatialCells for spatial Psf fitting.
Definition: PsfCandidate.h:56
lsst::afw::image::MaskedImage< PixelT > MaskedImageT
Definition: PsfCandidate.h:63
double getVar() const
Return the variance in use when fitting this object.
Definition: PsfCandidate.h:119