lsst.meas.algorithms  14.0-7-g23fdbe95+6
CoaddPsf.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #if !defined(LSST_MEAS_ALGORITHMS_COADDPSF_H)
25 #define LSST_MEAS_ALGORITHMS_COADDPSF_H
26 
27 #include <memory>
28 #include "lsst/base.h"
29 #include "lsst/pex/config.h"
31 #include "lsst/afw/image/Wcs.h"
33 #include "lsst/afw/table/types.h"
34 #include "lsst/afw/geom/Box.h"
37 
38 namespace lsst { namespace meas { namespace algorithms {
39 
41 public:
42 
44  "Name of warping kernel; choices: lanczos3,lanczos4,lanczos5,bilinear,nearest");
45  LSST_CONTROL_FIELD(cacheSize, int, "Warping kernel cache size");
46 
47  explicit CoaddPsfControl(std::string _warpingKernelName="lanczos3", int _cacheSize=10000) :
48  warpingKernelName(_warpingKernelName), cacheSize(_cacheSize)
49  {}
50 };
51 
58 class CoaddPsf : public afw::table::io::PersistableFacade<CoaddPsf>, public ImagePsf {
59 public:
60 
76  explicit CoaddPsf(
77  afw::table::ExposureCatalog const & catalog,
78  afw::image::Wcs const & coaddWcs,
79  std::string const & weightFieldName = "weight",
80  std::string const & warpingKernelName="lanczos3",
81  int cacheSize=10000
82  );
83 
99  afw::table::ExposureCatalog const & catalog,
100  afw::image::Wcs const & coaddWcs,
101  CoaddPsfControl const & ctrl,
102  std::string const & weightFieldName = "weight"
103  ) : CoaddPsf(catalog, coaddWcs, weightFieldName, ctrl.warpingKernelName, ctrl.cacheSize) {}
104 
106  virtual PTR(afw::detection::Psf) clone() const;
107 
109  virtual PTR(afw::detection::Psf) resized(int width, int height) const;
116  virtual afw::geom::Point2D getAveragePosition() const { return _averagePosition; }
117 
119  PTR(afw::image::Wcs const) getCoaddWcs() { return _coaddWcs; }
120 
122  int getComponentCount() const;
123 
131  CONST_PTR(afw::detection::Psf) getPsf(int index);
132 
140  CONST_PTR(afw::image::Wcs) getWcs(int index);
141 
149  double getWeight(int index);
150 
158  afw::table::RecordId getId(int index);
159 
167  afw::geom::Box2I getBBox(int index);
168 
176  CONST_PTR(afw::geom::polygon::Polygon) getValidPolygon(int index);
177 
187  virtual bool isPersistable() const { return true; }
188 
189  // Factory used to read CoaddPsf from an InputArchive; defined only in the source file.
190  class Factory;
191 
192 protected:
193 
194  PTR(afw::detection::Psf::Image) doComputeKernelImage(
195  afw::geom::Point2D const & ccdXY,
196  afw::image::Color const & color
197  ) const;
198 
199  virtual afw::geom::Box2I doComputeBBox(
200  afw::geom::Point2D const & position,
201  afw::image::Color const & color
202  ) const;
203 
204  // See afw::table::io::Persistable::getPersistenceName
205  virtual std::string getPersistenceName() const;
206 
207  // See afw::table::io::Persistable::getPythonModule
208  virtual std::string getPythonModule() const;
209 
210  // See afw::table::io::Persistable::write
211  virtual void write(OutputArchiveHandle & handle) const;
212 
213  // Used by persistence only
214  explicit CoaddPsf(
215  afw::table::ExposureCatalog const & catalog,
216  PTR(afw::image::Wcs const) coaddWcs,
218  std::string const & warpingKernelName="lanczos3",
219  int cacheSize=10000
220  );
221 
222 private:
223 
225  CONST_PTR(afw::image::Wcs) _coaddWcs;
226  afw::table::Key<double> _weightKey;
227  afw::geom::Point2D _averagePosition;
228  std::string _warpingKernelName; // could be removed if we could get this from _warpingControl (#2949)
229  CONST_PTR(afw::math::WarpingControl) _warpingControl;
230 };
231 
232 }}} // namespace lsst::meas::algorithms
233 
234 #endif
#define PTR(...)
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
#define CONST_PTR(...)
boost::shared_ptr< afw::image::Wcs const > getCoaddWcs()
Return the Wcs of the coadd (defines the coordinate system of the Psf).
Definition: CoaddPsf.h:119
STL class.
CoaddPsf(afw::table::ExposureCatalog const &catalog, afw::image::Wcs const &coaddWcs, CoaddPsfControl const &ctrl, std::string const &weightFieldName="weight")
Constructor for CoaddPsf.
Definition: CoaddPsf.h:98
CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
Definition: CoaddPsf.h:58
CoaddPsfControl(std::string _warpingKernelName="lanczos3", int _cacheSize=10000)
Definition: CoaddPsf.h:47
virtual bool isPersistable() const
Return true if the CoaddPsf persistable (always true).
Definition: CoaddPsf.h:187
std::string warpingKernelName
"Name of warping kernel; choices: lanczos3,lanczos4,lanczos5,bilinear,nearest" ;
Definition: CoaddPsf.h:44
virtual afw::geom::Point2D getAveragePosition() const
Return the average of the positions of the stars that went into this Psf.
Definition: CoaddPsf.h:116
io::OutputArchiveHandle OutputArchiveHandle
An intermediate base class for Psfs that use an image representation.
Definition: ImagePsf.h:37
tbl::PointKey< double > averagePosition
Definition: CoaddPsf.cc:363
clone
tbl::Key< int > coaddWcs
int cacheSize
"Warping kernel cache size" ;
Definition: CoaddPsf.h:45