LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.45
LSSTDataManagementBasePackage
KernelPsf.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 #include "lsst/geom/Box.h"
7 
8 namespace lsst {
9 namespace afw {
10 namespace table {
11 namespace io {
12 
15 
16 } // namespace io
17 } // namespace table
18 } // namespace afw
19 namespace meas {
20 namespace algorithms {
21 
23 KernelPsf::doComputeKernelImage(geom::Point2D const& position, afw::image::Color const& color) const {
24  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 
29 geom::Box2I KernelPsf::doComputeBBox(geom::Point2D const& position, afw::image::Color const& color) const {
30  return _kernel->getBBox();
31 }
32 
33 KernelPsf::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 
41 PTR(afw::detection::Psf) KernelPsf::clone() const { return std::make_shared<KernelPsf>(*this); }
42 
43 PTR(afw::detection::Psf) KernelPsf::resized(int width, int height) const {
44  return std::make_shared<KernelPsf>(*_kernel->resized(width, height), _averagePosition);
45 }
46 
47 geom::Point2D KernelPsf::getAveragePosition() const { return _averagePosition; }
48 
49 namespace {
50 
51 KernelPsfFactory<> registration("KernelPsf");
52 
53 } // namespace
54 
56  static KernelPsfPersistenceHelper instance;
57  return instance;
58 }
59 
60 KernelPsfPersistenceHelper::KernelPsfPersistenceHelper()
61  : schema(),
62  kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
64  schema, "averagePosition", "average position of stars used to make the PSF", "pixel")) {}
65 
66 bool KernelPsf::isPersistable() const noexcept { return _kernel->isPersistable(); }
67 
68 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
69 
70 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
71 
74  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
75  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
A read-only singleton struct containing the schema and key used in persistence for KernelPsf...
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
Dynamically cast a shared_ptr.
Definition: Persistable.cc:18
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...
An object passed to Persistable::write to allow it to persist itself.
boost::shared_ptr< afw::detection::Psf > resized(int width, int height) const override
Return a clone with specified kernel dimensions.
Definition: KernelPsf.cc:43
STL class.
A base class for image defects.
A FunctorKey used to get or set a lsst::geom::Point from an (x,y) pair of int or double Keys...
Definition: aggregates.h:49
void write(OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
Definition: KernelPsf.cc:72
table::Schema schema
Definition: Amplifier.cc:115
static KernelPsfPersistenceHelper const & get()
Definition: KernelPsf.cc:55
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
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
afw::table::PointKey< double > averagePosition
Definition: CoaddPsf.cc:340
Base class for all records.
Definition: BaseRecord.h:31
boost::shared_ptr< afw::detection::Psf > clone() const override
Polymorphic deep copy.
Definition: KernelPsf.cc:41
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.
bool isPersistable() const noexcept override
Whether this object is persistable; just delegates to the kernel.
Definition: KernelPsf.cc:66
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Definition: KernelPsf.cc:68
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:75
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
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:111
An integer coordinate rectangle.
Definition: Box.h:55
image::Image< Pixel > Image
Image type returned by computeImage.
Definition: Psf.h:83
geom::Point2D getAveragePosition() const override
Return average position of stars; used as default position.
Definition: KernelPsf.cc:47
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Definition: Catalog.h:485
#define PTR(...)
Definition: base.h:41