LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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 <vector>
35 
36 #include "boost/make_shared.hpp"
37 
38 #include "lsst/pex/policy.h"
39 
41 #include "lsst/afw/detection/Psf.h"
43 #include "lsst/afw/table/Source.h"
45 
46 namespace lsst {
47 namespace meas {
48 namespace algorithms {
56  template <typename PixelT>
59  public:
64 
65  typedef boost::shared_ptr<PsfCandidate<PixelT> > Ptr;
66  typedef boost::shared_ptr<const PsfCandidate<PixelT> > ConstPtr;
67  typedef std::vector<Ptr > PtrList;
68 
70 
77  PTR(afw::table::SourceRecord) const& source,
79  ) :
80  afw::math::SpatialCellMaskedImageCandidate<PixelT>(source->getX(), source->getY()),
81  _parentExposure(parentExposure),
82  _offsetImage(),
83  _source(source),
84  _haveImage(false),
85  _amplitude(0.0), _var(1.0)
86  {}
87 
92  PTR(afw::table::SourceRecord) const& source,
93  CONST_PTR(afw::image::Exposure<PixelT>) parentExposure,
94  double xCenter,
95  double yCenter
96  ) :
97  afw::math::SpatialCellMaskedImageCandidate<PixelT>(xCenter, yCenter),
98  _parentExposure(parentExposure),
99  _offsetImage(),
100  _source(source),
101  _haveImage(false),
102  _amplitude(0.0), _var(1.0)
103  {}
104 
106  virtual ~PsfCandidate() {};
107 
113  double getCandidateRating() const { return _source->getPsfFlux(); }
114 
117 
119  double getAmplitude() const { return _amplitude; }
120 
122  void setAmplitude(double amplitude) { _amplitude = amplitude; }
123 
125  double getVar() const { return _var; }
126 
128  void setVar(double var) { _var = var; }
129 
131  CONST_PTR(afw::image::MaskedImage<PixelT>) getMaskedImage(int width, int height) const;
132  PTR(afw::image::MaskedImage<PixelT>) getOffsetImage(std::string const algorithm,
133  unsigned int buffer) const;
134 
136  static int getBorderWidth() { return _border; }
137 
139  static void setBorderWidth(int border) { _border = border; }
140 
144  static void setPixelThreshold(float threshold) { _pixelThreshold = threshold; }
145 
147  static float getPixelThreshold() { return _pixelThreshold; }
148 
150  static void setMaskBlends(bool doMaskBlends) { _doMaskBlends = doMaskBlends; }
151 
153  static bool getMaskBlends() { return _doMaskBlends; }
154 
155  private:
156  CONST_PTR(lsst::afw::image::Exposure<PixelT>) _parentExposure; // the %image that the Sources are found in
157 
158  PTR(afw::image::MaskedImage<PixelT>)
159  offsetImage(
160  PTR(afw::image::MaskedImage<PixelT>) img,
161  std::string const algorithm,
162  unsigned int buffer
163  );
164 
165  PTR(afw::image::MaskedImage<PixelT>)
166  extractImage(unsigned int width, unsigned int height) const;
167 
168  PTR(afw::image::MaskedImage<PixelT>) mutable _offsetImage; // %image offset to put center on a pixel
169  PTR(afw::table::SourceRecord) _source; // the Source itself
170 
171  bool mutable _haveImage; // do we have an Image to return?
172  double _amplitude; // best-fit amplitude of current PSF model
173  double _var; // variance to use when fitting this candidate
174  static int _border; // width of border of ignored pixels around _image
175  afw::geom::Point2D _xyCenter;
176  static int _defaultWidth;
177  static float _pixelThreshold;
178  static bool _doMaskBlends;
179  };
180 
186  template <typename PixelT>
187  boost::shared_ptr<PsfCandidate<PixelT> >
188  makePsfCandidate(PTR(afw::table::SourceRecord) const& source,
189  PTR(afw::image::Exposure<PixelT>) image
190  )
191  {
192  return boost::make_shared< PsfCandidate<PixelT> >(source, image);
193  }
194 
195 }}}
196 
197 #endif
void setAmplitude(double amplitude)
Set the best-fit amplitude.
Definition: PsfCandidate.h:122
static void setPixelThreshold(float threshold)
Definition: PsfCandidate.h:144
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:91
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:150
boost::shared_ptr< afw::table::SourceRecord > getSource() const
Return the original Source.
Definition: PsfCandidate.h:116
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:48
static float _pixelThreshold
Threshold for masking pixels unconnected with central footprint.
Definition: PsfCandidate.h:177
boost::shared_ptr< PsfCandidate< PixelT > > makePsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > > image)
Definition: PsfCandidate.h:188
boost::shared_ptr< afw::image::MaskedImage< PixelT > const > getMaskedImage() const
#define PTR(...)
Definition: base.h:41
Point< double, 2 > Point2D
Definition: Point.h:286
boost::shared_ptr< PsfCandidate< PixelT > > Ptr
Definition: PsfCandidate.h:65
boost::shared_ptr< const PsfCandidate< PixelT > > ConstPtr
Definition: PsfCandidate.h:66
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:106
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
static bool getMaskBlends()
Get whether blends are masked.
Definition: PsfCandidate.h:153
double getAmplitude() const
Return the best-fit amplitude.
Definition: PsfCandidate.h:119
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:77
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:168
void setVar(double var)
Set the variance to use when fitting this object.
Definition: PsfCandidate.h:128
static bool _doMaskBlends
Mask blends when extracting?
Definition: PsfCandidate.h:178
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:147
PsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > const > parentExposure)
Definition: PsfCandidate.h:76
static int getBorderWidth()
Return the number of pixels being ignored around the candidate image&#39;s edge.
Definition: PsfCandidate.h:136
#define CONST_PTR(...)
Definition: base.h:47
Class to ensure constraints for spatial modeling.
Record class that contains measurements made on a single exposure.
Definition: Source.h:81
boost::shared_ptr< lsst::afw::image::Exposure< PixelT > const > _parentExposure
Definition: PsfCandidate.h:156
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:169
static void setBorderWidth(int border)
Set the number of pixels to ignore around the candidate image&#39;s edge.
Definition: PsfCandidate.h:139
Class stored in SpatialCells for spatial Psf fitting.
Definition: PsfCandidate.h:57
lsst::afw::image::MaskedImage< PixelT > MaskedImageT
Definition: PsfCandidate.h:69
double getVar() const
Return the variance in use when fitting this object.
Definition: PsfCandidate.h:125