lsst.meas.algorithms  13.0-24-g22030a45+4
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 PTR(afw::detection::Psf) KernelPsf::resized(int width, int height) const {
31  return std::make_shared<KernelPsf>(*_kernel->resized(width, height), _averagePosition); }
32 
33 afw::geom::Point2D KernelPsf::getAveragePosition() const { return _averagePosition; }
34 
35 namespace {
36 
37 KernelPsfFactory<> registration("KernelPsf");
38 
39 } // anonymous
40 
42  static KernelPsfPersistenceHelper instance;
43  return instance;
44 }
45 
46 KernelPsfPersistenceHelper::KernelPsfPersistenceHelper() :
47  schema(),
48  kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
49  averagePosition(afw::table::PointKey<double>::addFields(
50  schema, "averagePosition", "average position of stars used to make the PSF", "pixel"
51  ))
52 {
53  schema.getCitizen().markPersistent();
54 }
55 
56 bool KernelPsf::isPersistable() const { return _kernel->isPersistable(); }
57 
58 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
59 
60 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
61 
62 void KernelPsf::write(OutputArchiveHandle & handle) const {
64  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
65  PTR(afw::table::BaseRecord) record = catalog.addNew();
66  record->set(keys.kernel, handle.put(_kernel));
67  record->set(keys.averagePosition, _averagePosition);
68  handle.saveCatalog(catalog);
69 }
70 
71 }}} // namespace lsst::meas::algorithms
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:28
virtual std::string getPythonModule() const
Definition: KernelPsf.cc:60
virtual boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const
Return a clone with specified kernel dimensions.
Definition: KernelPsf.cc:30
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
static KernelPsfPersistenceHelper const & get()
Definition: KernelPsf.cc:41
virtual void write(OutputArchiveHandle &handle) const
Definition: KernelPsf.cc:62
tbl::Schema schema
virtual bool isPersistable() const
Whether this object is persistable; just delegates to the kernel.
Definition: KernelPsf.cc:56
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:363
A PersistableFactory for KernelPsf and its subclasses.
virtual std::string getPersistenceName() const
Definition: KernelPsf.cc:58
virtual afw::geom::Point2D getAveragePosition() const
Return average position of stars; used as default position.
Definition: KernelPsf.cc:33