LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
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 
17  afw::geom::Point2D const & position, afw::image::Color const& color
18 ) const {
19  return _kernel->getBBox();
20 }
21 
23  ImagePsf(!kernel.isSpatiallyVarying()), _kernel(kernel.clone()), _averagePosition(averagePosition) {}
24 
26  ImagePsf(!kernel->isSpatiallyVarying()), _kernel(kernel), _averagePosition(averagePosition) {}
27 
28 PTR(afw::detection::Psf) KernelPsf::clone() const { return std::make_shared<KernelPsf>(*this); }
29 
31 
32 namespace {
33 
34 KernelPsfFactory<> registration("KernelPsf");
35 
36 } // anonymous
37 
39  static KernelPsfPersistenceHelper instance;
40  return instance;
41 }
42 
44  schema(),
45  kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
46  averagePosition(afw::table::PointKey<double>::addFields(
47  schema, "averagePosition", "average position of stars used to make the PSF", "pixel"
48  ))
49 {
51 }
52 
53 bool KernelPsf::isPersistable() const { return _kernel->isPersistable(); }
54 
55 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
56 
57 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
58 
59 void KernelPsf::write(OutputArchiveHandle & handle) const {
61  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
62  PTR(afw::table::BaseRecord) record = catalog.addNew();
63  record->set(keys.kernel, handle.put(_kernel));
64  record->set(keys.averagePosition, _averagePosition);
65  handle.saveCatalog(catalog);
66 }
67 
68 }}} // namespace lsst::meas::algorithms
boost::shared_ptr< afw::math::Kernel > _kernel
Definition: KernelPsf.h:95
A read-only singleton struct containing the schema and key used in persistence for KernelPsf...
geom::Extent2I const getDimensions() const
Return the Kernel&#39;s dimensions (width, height)
Definition: Kernel.h:223
A Psf defined by a Kernel.
Definition: KernelPsf.h:33
An object passed to Persistable::write to allow it to persist itself.
A custom container class for records, based on std::vector.
Definition: Catalog.h:95
afw::table::Schema schema
Definition: GaussianPsf.cc:41
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
static KernelPsfPersistenceHelper const & get()
Definition: KernelPsf.cc:38
An integer coordinate rectangle.
Definition: Box.h:53
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
boost::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:470
afwMath::LinearCombinationKernel const & _kernel
virtual bool isPersistable() const
Whether this object is persistable; just delegates to the kernel.
Definition: KernelPsf.cc:53
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:94
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
void markPersistent(void)
Mark a Citizen as persistent and not destroyed until process end.
Definition: Citizen.cc:254
virtual afw::geom::Point2D getAveragePosition() const
Return average position of stars; used as default position.
Definition: KernelPsf.cc:30
virtual afw::geom::Box2I doComputeBBox(afw::geom::Point2D const &position, afw::image::Color const &color) const
These virtual member functions are private, not protected, because we only want derived classes to im...
Definition: KernelPsf.cc:16
afw::geom::Point2D _averagePosition
Definition: KernelPsf.h:96
Base class for all records.
Definition: BaseRecord.h:27
#define PTR(...)
Definition: base.h:41
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Definition: KernelPsf.cc:57
Utilities for persisting KernelPsf and subclasses thereof.
Point< double, 2 > Point2D
Definition: Point.h:288
int put(Persistable const *obj, bool permissive=false)
Save a nested Persistable to the same archive.
An intermediate base class for Psfs that use an image representation.
Definition: ImagePsf.h:37
tbl::PointKey< double > averagePosition
Definition: CoaddPsf.cc:352
A PersistableFactory for KernelPsf and its subclasses.
Describe the colour of a source.
Definition: Color.h:27
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:68
Kernels are used for convolution with MaskedImages and (eventually) Images.
Definition: Kernel.h:131
daf::base::Citizen & getCitizen()
Get the Citizen corresponding to this Schema (SchemaImpl is what inherits from Citizen).
Definition: Schema.h:293
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
Definition: KernelPsf.cc:59
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
Definition: KernelPsf.cc:55