lsst.meas.algorithms  13.0-13-gf5c99ad+4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KernelPsf.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
5 
6 namespace lsst { namespace meas { namespace algorithms {
7 
8 PTR(afw::detection::Psf::Image) KernelPsf::doComputeKernelImage(
9  afw::geom::Point2D const & position, afw::image::Color const& color
10 ) const {
11  PTR(Psf::Image) im = std::make_shared<Psf::Image>(_kernel->getDimensions());
12  _kernel->computeImage(*im, true, position.getX(), position.getY());
13  return im;
14 }
15 
16 afw::geom::Box2I KernelPsf::doComputeBBox(
17  afw::geom::Point2D const & position, afw::image::Color const& color
18 ) const {
19  return _kernel->getBBox();
20 }
21 
22 KernelPsf::KernelPsf(afw::math::Kernel const & kernel, afw::geom::Point2D const & averagePosition) :
23  ImagePsf(!kernel.isSpatiallyVarying()), _kernel(kernel.clone()), _averagePosition(averagePosition) {}
24 
25 KernelPsf::KernelPsf(PTR(afw::math::Kernel) kernel, afw::geom::Point2D const & averagePosition) :
26  ImagePsf(!kernel->isSpatiallyVarying()), _kernel(kernel), _averagePosition(averagePosition) {}
27 
28 PTR(afw::detection::Psf) KernelPsf::clone() const { return std::make_shared<KernelPsf>(*this); }
29 
30 afw::geom::Point2D KernelPsf::getAveragePosition() const { return _averagePosition; }
31 
32 namespace {
33 
34 KernelPsfFactory<> registration("KernelPsf");
35 
36 } // anonymous
37 
39  static KernelPsfPersistenceHelper instance;
40  return instance;
41 }
42 
43 KernelPsfPersistenceHelper::KernelPsfPersistenceHelper() :
44  schema(),
45  kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
46  averagePosition(afw::table::PointKey<double>::addFields(
47  schema, "averagePosition", "average position of stars used to make the PSF", "pixel"
48  ))
49 {
50  schema.getCitizen().markPersistent();
51 }
52 
53 bool KernelPsf::isPersistable() const { return _kernel->isPersistable(); }
54 
55 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
56 
57 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
58 
59 void KernelPsf::write(OutputArchiveHandle & handle) const {
61  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
62  PTR(afw::table::BaseRecord) record = catalog.addNew();
63  record->set(keys.kernel, handle.put(_kernel));
64  record->set(keys.averagePosition, _averagePosition);
65  handle.saveCatalog(catalog);
66 }
67 
68 }}} // namespace lsst::meas::algorithms
A read-only singleton struct containing the schema and key used in persistence for KernelPsf...
A Psf defined by a Kernel.
Definition: KernelPsf.h:33
static KernelPsfPersistenceHelper const & get()
Definition: KernelPsf.cc:38
afwMath::LinearCombinationKernel const & _kernel
virtual bool isPersistable() const
Whether this object is persistable; just delegates to the kernel.
Definition: KernelPsf.cc:53
KernelPsf(afw::math::Kernel const &kernel, afw::geom::Point2D const &averagePosition=afw::geom::Point2D())
Construct a KernelPsf with a clone of the given kernel.
Definition: KernelPsf.cc:22
tbl::Schema schema
virtual afw::geom::Point2D getAveragePosition() const
Return average position of stars; used as default position.
Definition: KernelPsf.cc:30
virtual std::string getPythonModule() const
Definition: KernelPsf.cc:57
Utilities for persisting KernelPsf and subclasses thereof.
An intermediate base class for Psfs that use an image representation.
Definition: ImagePsf.h:37
tbl::PointKey< double > averagePosition
Definition: CoaddPsf.cc:352
A PersistableFactory for KernelPsf and its subclasses.
virtual void write(OutputArchiveHandle &handle) const
Definition: KernelPsf.cc:59
virtual std::string getPersistenceName() const
Definition: KernelPsf.cc:55