LSST Applications g06d8191974+de063e15a7,g180d380827+d0b6459378,g2079a07aa2+86d27d4dc4,g2305ad1205+f1ae3263cc,g29320951ab+5752d78b6e,g2bbee38e9b+85cf0a37e7,g337abbeb29+85cf0a37e7,g33d1c0ed96+85cf0a37e7,g3a166c0a6a+85cf0a37e7,g3ddfee87b4+b5254b9343,g48712c4677+9ea88d309d,g487adcacf7+05f7dba17f,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+48904e3942,g64a986408d+de063e15a7,g858d7b2824+de063e15a7,g864b0138d7+33ab2bc355,g8a8a8dda67+585e252eca,g99cad8db69+4508353287,g9c22b2923f+53520f316c,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+ccb7f83a87,gc120e1dc64+6caf640b9b,gc28159a63d+85cf0a37e7,gc3e9b769f7+548c5e05a3,gcf0d15dbbd+b5254b9343,gdaeeff99f8+f9a426f77a,ge6526c86ff+515b6c9330,ge79ae78c31+85cf0a37e7,gee10cc3b42+585e252eca,gff1a9f87cc+de063e15a7,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
KernelPsf.cc
Go to the documentation of this file.
1// -*- LSST-C++ -*-
2
3#include "lsst/geom/Box.h"
7
8namespace lsst {
9namespace afw {
10namespace table {
11namespace io {
12
15
16} // namespace io
17} // namespace table
18} // namespace afw
19namespace meas {
20namespace algorithms {
21
23KernelPsf::doComputeKernelImage(geom::Point2D const& position, afw::image::Color const& color) const {
24 std::shared_ptr<Psf::Image> im = std::make_shared<Psf::Image>(_kernel->getDimensions());
25 _kernel->computeImage(*im, true, position.getX(), position.getY());
26 return im;
27}
28
29geom::Box2I KernelPsf::doComputeBBox(geom::Point2D const& position, afw::image::Color const& color) const {
30 return _kernel->getBBox();
31}
32
33KernelPsf::KernelPsf(afw::math::Kernel const& kernel, geom::Point2D const& averagePosition)
34 : ImagePsf(!kernel.isSpatiallyVarying()),
35 _kernel(kernel.clone()),
36 _averagePosition(averagePosition) {}
37
39 : ImagePsf(!kernel->isSpatiallyVarying()), _kernel(kernel), _averagePosition(averagePosition) {}
40
41std::shared_ptr<afw::detection::Psf> KernelPsf::clone() const { return std::make_shared<KernelPsf>(*this); }
42
44 return std::make_shared<KernelPsf>(*_kernel->resized(width, height), _averagePosition);
45}
46
47geom::Point2D KernelPsf::getAveragePosition() const { return _averagePosition; }
48
49namespace {
50
51KernelPsfFactory<> registration("KernelPsf");
52
53} // namespace
54
56 static KernelPsfPersistenceHelper instance;
57 return instance;
58}
59
60KernelPsfPersistenceHelper::KernelPsfPersistenceHelper()
61 : schema(),
62 kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
63 averagePosition(afw::table::PointKey<double>::addFields(
64 schema, "averagePosition", "average position of stars used to make the PSF", "pixel")) {}
65
66bool KernelPsf::isPersistable() const noexcept { return _kernel->isPersistable(); }
67
68std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
69
70std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
71
74 afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
75 std::shared_ptr<afw::table::BaseRecord> record = catalog.addNew();
76 record->set(keys.kernel, handle.put(_kernel));
77 record->set(keys.averagePosition, _averagePosition);
78 handle.saveCatalog(catalog);
79}
80
81} // namespace algorithms
82} // namespace meas
83} // namespace lsst
Utilities for persisting KernelPsf and subclasses thereof.
Describe the colour of a source.
Definition Color.h:25
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition Kernel.h:110
lsst::geom::Extent2I const getDimensions() const
Return the Kernel's dimensions (width, height)
Definition Kernel.h:212
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Compute an image (pixellized representation of the kernel) in place.
Definition Kernel.cc:76
lsst::geom::Box2I getBBox() const
return parent bounding box, with XY0 = -center
Definition Kernel.h:239
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
An integer coordinate rectangle.
Definition Box.h:55
An intermediate base class for Psfs that use an image representation.
Definition ImagePsf.h:40
A PersistableFactory for KernelPsf and its subclasses.
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:33
bool isPersistable() const noexcept override
Whether this object is persistable; just delegates to the kernel.
Definition KernelPsf.cc:66
std::shared_ptr< afw::detection::Psf > clone() const override
Polymorphic deep copy.
Definition KernelPsf.cc:41
std::shared_ptr< afw::detection::Psf > resized(int width, int height) const override
Return a clone with specified kernel dimensions.
Definition KernelPsf.cc:43
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition KernelPsf.cc:68
std::string getPythonModule() const override
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition KernelPsf.cc:70
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition KernelPsf.cc:72
geom::Point2D getAveragePosition() const override
Return average position of stars; used as default position.
Definition KernelPsf.cc:47
afw::table::PointKey< double > averagePosition
Definition CoaddPsf.cc:353
A read-only singleton struct containing the schema and key used in persistence for KernelPsf.
static KernelPsfPersistenceHelper const & get()
Definition KernelPsf.cc:55