LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
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 
39 #include "lsst/geom/Point.h"
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>
58 public:
62 
64 
72  parentExposure
73  )
74  : afw::math::SpatialCellImageCandidate(source->getX(), source->getY()),
75  _parentExposure(parentExposure),
76  _offsetImage(),
77  _source(source),
78  _image(nullptr),
79  _amplitude(0.0),
80  _var(1.0) {}
81 
87  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),
97  _var(1.0) {}
98 
100  virtual ~PsfCandidate(){};
101 
107  double getCandidateRating() const { return _source->getPsfInstFlux(); }
108 
110  PTR(afw::table::SourceRecord) getSource() const { return _source; }
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;
127  getOffsetImage(std::string const algorithm, unsigned int buffer) const;
128 
130  static int getBorderWidth();
131 
133  static void setBorderWidth(int border);
134 
138  static void setPixelThreshold(float threshold);
139 
141  static float getPixelThreshold();
142 
144  static void setMaskBlends(bool doMaskBlends);
145 
147  static bool getMaskBlends();
148 
149 private:
151  _parentExposure; // the %image that the Sources are found in
152 
154  offsetImage(PTR(afw::image::MaskedImage<PixelT>) img, std::string const algorithm, unsigned int buffer);
155 
157  extractImage(unsigned int width, unsigned int height) const;
158 
159  PTR(afw::image::MaskedImage<PixelT>) mutable _offsetImage; // %image offset to put center on a pixel
160  PTR(afw::table::SourceRecord) _source; // the Source itself
161 
162  mutable std::shared_ptr<afw::image::MaskedImage<PixelT>> _image; // cutout image to return (cached)
163  double _amplitude; // best-fit amplitude of current PSF model
164  double _var; // variance to use when fitting this candidate
165  static int _border; // width of border of ignored pixels around _image
166  geom::Point2D _xyCenter;
167  static int _defaultWidth;
168  static float _pixelThreshold;
169  static bool _doMaskBlends;
170 };
171 
177 template <typename PixelT>
179  const & source,
181  image
182  ) {
183  return std::make_shared<PsfCandidate<PixelT>>(source, image);
184 }
185 
186 } // namespace algorithms
187 } // namespace meas
188 } // namespace lsst
189 
190 #endif
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
void setAmplitude(double amplitude)
Set the best-fit amplitude.
Definition: PsfCandidate.h:116
static void setMaskBlends(bool doMaskBlends)
Set whether blends are masked.
std::shared_ptr< PsfCandidate< PixelT > > Ptr
Definition: PsfCandidate.h:59
std::shared_ptr< const PsfCandidate< PixelT > > ConstPtr
Definition: PsfCandidate.h:60
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:72
double getCandidateRating() const
Return Cell rating.
Definition: PsfCandidate.h:107
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
static float getPixelThreshold()
Get threshold for rejecting pixels unconnected with the central footprint.
static void setBorderWidth(int border)
Set the number of pixels to ignore around the candidate image&#39;s edge.
boost::shared_ptr< afw::table::SourceRecord > getSource() const
Return the original Source.
Definition: PsfCandidate.h:110
STL class.
virtual ~PsfCandidate()
Destructor.
Definition: PsfCandidate.h:100
double getVar() const
Return the variance in use when fitting this object.
Definition: PsfCandidate.h:119
double getAmplitude() const
Return the best-fit amplitude.
Definition: PsfCandidate.h:113
A base class for image defects.
SpatialCellImageCandidate(float const xCenter, float const yCenter)
ctor
Definition: SpatialCell.h:129
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...
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:74
static int getBorderWidth()
Return the number of pixels being ignored around the candidate image&#39;s edge.
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
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:178
afw::image::MaskedImage< PixelT > MaskedImageT
Definition: PsfCandidate.h:63
STL class.
Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e...
Definition: SpatialCell.h:126
afw::table::Key< afw::table::Array< ImagePixelT > > 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.
#define PTR(...)
Definition: base.h:41
Record class that contains measurements made on a single exposure.
Definition: Source.h:82
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
static bool getMaskBlends()
Get whether blends are masked.
Class stored in SpatialCells for spatial Psf fitting.
Definition: PsfCandidate.h:57