LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
KernelPsf.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 #include "lsst/geom/Box.h"
4 #include "lsst/afw/table/io/Persistable.cc"
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  schema.getCitizen().markPersistent();
66 }
67 
68 bool KernelPsf::isPersistable() const noexcept { return _kernel->isPersistable(); }
69 
70 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
71 
72 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
73 
76  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
77  PTR(afw::table::BaseRecord) record = catalog.addNew();
78  record->set(keys.kernel, handle.put(_kernel));
79  record->set(keys.averagePosition, _averagePosition);
80  handle.saveCatalog(catalog);
81 }
82 
83 } // namespace algorithms
84 } // namespace meas
85 } // 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
Point< double, 2 > Point2D
Definition: Point.h:324
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:74
#define PTR(...)
Definition: base.h:41
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:72
table::Schema schema
Definition: Camera.cc:161
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:68
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:70
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:112
image::Image< Pixel > Image
Image type returned by computeImage.
Definition: Psf.h:84
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:472