LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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>
58  public:
63 
64  typedef std::shared_ptr<PsfCandidate<PixelT> > Ptr;
65  typedef std::shared_ptr<const PsfCandidate<PixelT> > ConstPtr;
66  typedef std::vector<Ptr > PtrList;
67 
69 
76  PTR(afw::table::SourceRecord) const& source,
78  ) :
79  afw::math::SpatialCellMaskedImageCandidate<PixelT>(source->getX(), source->getY()),
80  _parentExposure(parentExposure),
81  _offsetImage(),
82  _source(source),
83  _haveImage(false),
84  _amplitude(0.0), _var(1.0)
85  {}
86 
91  PTR(afw::table::SourceRecord) const& source,
92  CONST_PTR(afw::image::Exposure<PixelT>) parentExposure,
93  double xCenter,
94  double yCenter
95  ) :
96  afw::math::SpatialCellMaskedImageCandidate<PixelT>(xCenter, yCenter),
97  _parentExposure(parentExposure),
98  _offsetImage(),
99  _source(source),
100  _haveImage(false),
101  _amplitude(0.0), _var(1.0)
102  {}
103 
105  virtual ~PsfCandidate() {};
106 
112  double getCandidateRating() const { return _source->getPsfFlux(); }
113 
116 
118  double getAmplitude() const { return _amplitude; }
119 
121  void setAmplitude(double amplitude) { _amplitude = amplitude; }
122 
124  double getVar() const { return _var; }
125 
127  void setVar(double var) { _var = var; }
128 
130  CONST_PTR(afw::image::MaskedImage<PixelT>) getMaskedImage(int width, int height) const;
131  PTR(afw::image::MaskedImage<PixelT>) getOffsetImage(std::string const algorithm,
132  unsigned int buffer) const;
133 
135  static int getBorderWidth() { return _border; }
136 
138  static void setBorderWidth(int border) { _border = border; }
139 
143  static void setPixelThreshold(float threshold) { _pixelThreshold = threshold; }
144 
146  static float getPixelThreshold() { return _pixelThreshold; }
147 
149  static void setMaskBlends(bool doMaskBlends) { _doMaskBlends = doMaskBlends; }
150 
152  static bool getMaskBlends() { return _doMaskBlends; }
153 
154  private:
155  CONST_PTR(lsst::afw::image::Exposure<PixelT>) _parentExposure; // the %image that the Sources are found in
156 
157  PTR(afw::image::MaskedImage<PixelT>)
158  offsetImage(
159  PTR(afw::image::MaskedImage<PixelT>) img,
160  std::string const algorithm,
161  unsigned int buffer
162  );
163 
164  PTR(afw::image::MaskedImage<PixelT>)
165  extractImage(unsigned int width, unsigned int height) const;
166 
167  PTR(afw::image::MaskedImage<PixelT>) mutable _offsetImage; // %image offset to put center on a pixel
168  PTR(afw::table::SourceRecord) _source; // the Source itself
169 
170  bool mutable _haveImage; // do we have an Image to return?
171  double _amplitude; // best-fit amplitude of current PSF model
172  double _var; // variance to use when fitting this candidate
173  static int _border; // width of border of ignored pixels around _image
174  afw::geom::Point2D _xyCenter;
175  static int _defaultWidth;
176  static float _pixelThreshold;
177  static bool _doMaskBlends;
178  };
179 
185  template <typename PixelT>
186  std::shared_ptr<PsfCandidate<PixelT> >
187  makePsfCandidate(PTR(afw::table::SourceRecord) const& source,
188  PTR(afw::image::Exposure<PixelT>) image
189  )
190  {
191  return std::make_shared< PsfCandidate<PixelT> >(source, image);
192  }
193 
194 }}}
195 
196 #endif
void setAmplitude(double amplitude)
Set the best-fit amplitude.
Definition: PsfCandidate.h:121
std::shared_ptr< PsfCandidate< PixelT > > Ptr
Definition: PsfCandidate.h:64
std::shared_ptr< const PsfCandidate< PixelT > > ConstPtr
Definition: PsfCandidate.h:65
static void setPixelThreshold(float threshold)
Definition: PsfCandidate.h:143
PsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > const > parentExposure, double xCenter, double yCenter)
Definition: PsfCandidate.h:90
SpatialCellMaskedImageCandidate(float const xCenter, float const yCenter)
ctor
Definition: SpatialCell.h:195
static void setMaskBlends(bool doMaskBlends)
Set whether blends are masked.
Definition: PsfCandidate.h:149
boost::shared_ptr< afw::table::SourceRecord > getSource() const
Return the original Source.
Definition: PsfCandidate.h:115
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:176
boost::shared_ptr< afw::image::MaskedImage< PixelT > const > getMaskedImage() const
Point< double, 2 > Point2D
Definition: Point.h:288
#define CONST_PTR(...)
Definition: base.h:47
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
virtual ~PsfCandidate()
Destructor.
Definition: PsfCandidate.h:105
static bool getMaskBlends()
Get whether blends are masked.
Definition: PsfCandidate.h:152
double getAmplitude() const
Return the best-fit amplitude.
Definition: PsfCandidate.h:118
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:167
void setVar(double var)
Set the variance to use when fitting this object.
Definition: PsfCandidate.h:127
std::shared_ptr< PsfCandidate< PixelT > > makePsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > > image)
Definition: PsfCandidate.h:187
static bool _doMaskBlends
Mask blends when extracting?
Definition: PsfCandidate.h:177
static float getPixelThreshold()
Get threshold for rejecting pixels unconnected with the central footprint.
Definition: PsfCandidate.h:146
PsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > const > parentExposure)
Definition: PsfCandidate.h:75
static int getBorderWidth()
Return the number of pixels being ignored around the candidate image&#39;s edge.
Definition: PsfCandidate.h:135
#define PTR(...)
Definition: base.h:41
Class to ensure constraints for spatial modeling.
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:155
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. The returned image has been offset to put the ce...
boost::shared_ptr< afw::table::SourceRecord > _source
Definition: PsfCandidate.h:168
static void setBorderWidth(int border)
Set the number of pixels to ignore around the candidate image&#39;s edge.
Definition: PsfCandidate.h:138
Class stored in SpatialCells for spatial Psf fitting.
Definition: PsfCandidate.h:56
lsst::afw::image::MaskedImage< PixelT > MaskedImageT
Definition: PsfCandidate.h:68
double getVar() const
Return the variance in use when fitting this object.
Definition: PsfCandidate.h:124