LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
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
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.
#define PTR(...)
Definition: base.h:41
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:76
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:85
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