lsst.meas.algorithms  13.0-23-gb99accf8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
32 #include "lsst/afw/table/Exposure.h"
33 #include "lsst/afw/table/types.h"
34 #include "lsst/afw/geom/Box.h"
35 #include "lsst/afw/geom/polygon/Polygon.h"
36 #include "lsst/afw/math/warpExposure.h"
37 
38 namespace lsst { namespace meas { namespace algorithms {
39 
41 public:
42 
43  LSST_CONTROL_FIELD(warpingKernelName, std::string,
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,
217  afw::geom::Point2D const & averagePosition,
218  std::string const & warpingKernelName="lanczos3",
219  int cacheSize=10000
220  );
221 
222 private:
223 
224  afw::table::ExposureCatalog _catalog;
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
virtual bool isPersistable() const
Return true if the CoaddPsf persistable (always true).
Definition: CoaddPsf.h:187
afw::geom::Box2I getBBox(int index)
Get the bounding box (in component image Pixel coordinates) of the component image at index...
Definition: CoaddPsf.cc:333
double getWeight(int index)
Get the weight of the component image at index.
Definition: CoaddPsf.cc:319
boost::shared_ptr< afw::image::Wcs const > getWcs(int index)
Get the Wcs of the component image at index.
Definition: CoaddPsf.cc:305
CoaddPsf(afw::table::ExposureCatalog const &catalog, afw::image::Wcs const &coaddWcs, std::string const &weightFieldName="weight", std::string const &warpingKernelName="lanczos3", int cacheSize=10000)
Main constructors for CoaddPsf.
Definition: CoaddPsf.cc:142
boost::shared_ptr< afw::detection::Psf::Image > doComputeKernelImage(afw::geom::Point2D const &ccdXY, afw::image::Color const &color) const
Definition: CoaddPsf.cc:252
tbl::Key< int > cacheSize
Definition: CoaddPsf.cc:355
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
afw::table::RecordId getId(int index)
Get the exposure ID of the component image at index.
Definition: CoaddPsf.cc:326
virtual std::string getPersistenceName() const
Definition: CoaddPsf.cc:441
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
int getComponentCount() const
Return the number of component Psfs in this CoaddPsf.
Definition: CoaddPsf.cc:294
CoaddPsfControl(std::string _warpingKernelName="lanczos3", int _cacheSize=10000)
Definition: CoaddPsf.h:47
std::string warpingKernelName
&quot;Name of warping kernel; choices: lanczos3,lanczos4,lanczos5,bilinear,nearest&quot; ;
Definition: CoaddPsf.h:44
tbl::Key< std::string > warpingKernelName
Definition: CoaddPsf.cc:357
virtual afw::geom::Box2I doComputeBBox(afw::geom::Point2D const &position, afw::image::Color const &color) const
Definition: CoaddPsf.cc:228
An intermediate base class for Psfs that use an image representation.
Definition: ImagePsf.h:37
virtual void write(OutputArchiveHandle &handle) const
Definition: CoaddPsf.cc:445
tbl::PointKey< double > averagePosition
Definition: CoaddPsf.cc:356
virtual std::string getPythonModule() const
Definition: CoaddPsf.cc:443
virtual boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const
Return a clone with specified kernel dimensions.
Definition: CoaddPsf.cc:180
virtual afw::geom::Point2D getAveragePosition() const
Return the average of the positions of the stars that went into this Psf.
Definition: CoaddPsf.h:116
boost::shared_ptr< afw::detection::Psf const > getPsf(int index)
Get the Psf of the component image at index.
Definition: CoaddPsf.cc:298
boost::shared_ptr< afw::geom::polygon::Polygon const > getValidPolygon(int index)
Get the validPolygon (in component image Pixel coordinates) of the component image at index...
Definition: CoaddPsf.cc:312
tbl::Key< int > coaddWcs
int cacheSize
&quot;Warping kernel cache size&quot; ;
Definition: CoaddPsf.h:45
virtual boost::shared_ptr< afw::detection::Psf > clone() const
Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.
Definition: CoaddPsf.cc:176