lsst.meas.algorithms  16.0-7-ge62bbd2a+3
KernelPsf.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 #include "lsst/geom/Box.h"
6 
7 namespace lsst {
8 namespace meas {
9 namespace algorithms {
10 
12 KernelPsf::doComputeKernelImage(geom::Point2D const& position, afw::image::Color const& color) const {
13  PTR(Psf::Image) im = std::make_shared<Psf::Image>(_kernel->getDimensions());
14  _kernel->computeImage(*im, true, position.getX(), position.getY());
15  return im;
16 }
17 
18 geom::Box2I KernelPsf::doComputeBBox(geom::Point2D const& position, afw::image::Color const& color) const {
19  return _kernel->getBBox();
20 }
21 
23  : ImagePsf(!kernel.isSpatiallyVarying()),
24  _kernel(kernel.clone()),
25  _averagePosition(averagePosition) {}
26 
28  : ImagePsf(!kernel->isSpatiallyVarying()), _kernel(kernel), _averagePosition(averagePosition) {}
29 
30 PTR(afw::detection::Psf) KernelPsf::clone() const { return std::make_shared<KernelPsf>(*this); }
31 
32 PTR(afw::detection::Psf) KernelPsf::resized(int width, int height) const {
33  return std::make_shared<KernelPsf>(*_kernel->resized(width, height), _averagePosition);
34 }
35 
36 geom::Point2D KernelPsf::getAveragePosition() const { return _averagePosition; }
37 
38 namespace {
39 
40 KernelPsfFactory<> registration("KernelPsf");
41 
42 } // namespace
43 
45  static KernelPsfPersistenceHelper instance;
46  return instance;
47 }
48 
49 KernelPsfPersistenceHelper::KernelPsfPersistenceHelper()
50  : schema(),
51  kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
53  schema, "averagePosition", "average position of stars used to make the PSF", "pixel")) {
54  schema.getCitizen().markPersistent();
55 }
56 
57 bool KernelPsf::isPersistable() const noexcept { return _kernel->isPersistable(); }
58 
59 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
60 
61 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
62 
65  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
66  PTR(afw::table::BaseRecord) record = catalog.addNew();
67  record->set(keys.kernel, handle.put(_kernel));
68  record->set(keys.averagePosition, _averagePosition);
69  handle.saveCatalog(catalog);
70 }
71 
72 } // namespace algorithms
73 } // namespace meas
74 } // namespace lsst
A read-only singleton struct containing the schema and key used in persistence for KernelPsf...
virtual boost::shared_ptr< afw::detection::Psf > clone() const
Polymorphic deep copy.
Definition: KernelPsf.cc:30
virtual std::string getPythonModule() const
Definition: KernelPsf.cc:61
#define PTR(...)
Point< double, 2 > Point2D
STL class.
virtual geom::Point2D getAveragePosition() const
Return average position of stars; used as default position.
Definition: KernelPsf.cc:36
afw::table::Schema schema
afw::table::PointKey< double > averagePosition
Definition: CoaddPsf.cc:329
virtual boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const
Return a clone with specified kernel dimensions.
Definition: KernelPsf.cc:32
def keys(self)
static KernelPsfPersistenceHelper const & get()
Definition: KernelPsf.cc:44
virtual void write(OutputArchiveHandle &handle) const
Definition: KernelPsf.cc:63
io::OutputArchiveHandle OutputArchiveHandle
Utilities for persisting KernelPsf and subclasses thereof.
An intermediate base class for Psfs that use an image representation.
Definition: ImagePsf.h:40
A PersistableFactory for KernelPsf and its subclasses.
virtual bool isPersistable() const noexcept override
Whether this object is persistable; just delegates to the kernel.
Definition: KernelPsf.cc:57
virtual std::string getPersistenceName() const
Definition: KernelPsf.cc:59
KernelPsf(afw::math::Kernel const &kernel, geom::Point2D const &averagePosition=geom::Point2D())
Construct a KernelPsf with a clone of the given kernel.
Definition: KernelPsf.cc:22
image::Image< Pixel > Image
std::shared_ptr< BaseRecord > addNew()