LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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 = boost::make_shared<Psf::Image>(_kernel->getDimensions());
12  _kernel->computeImage(*im, true, position.getX(), position.getY());
13  return im;
14 }
15 
17  ImagePsf(!kernel.isSpatiallyVarying()), _kernel(kernel.clone()), _averagePosition(averagePosition) {}
18 
20  ImagePsf(!kernel->isSpatiallyVarying()), _kernel(kernel), _averagePosition(averagePosition) {}
21 
22 PTR(afw::detection::Psf) KernelPsf::clone() const { return boost::make_shared<KernelPsf>(*this); }
23 
25 
26 namespace {
27 
28 KernelPsfFactory<> registration("KernelPsf");
29 
30 } // anonymous
31 
33  static KernelPsfPersistenceHelper instance;
34  return instance;
35 }
36 
38  schema(),
39  kernel(schema.addField<int>("kernel", "archive ID of nested kernel object")),
40  averagePosition(afw::table::PointKey<double>::addFields(
41  schema, "averagePosition", "average position of stars used to make the PSF", "pixels"
42  ))
43 {
45 }
46 
47 bool KernelPsf::isPersistable() const { return _kernel->isPersistable(); }
48 
49 std::string KernelPsf::getPersistenceName() const { return "KernelPsf"; }
50 
51 std::string KernelPsf::getPythonModule() const { return "lsst.meas.algorithms"; }
52 
53 void KernelPsf::write(OutputArchiveHandle & handle) const {
55  afw::table::BaseCatalog catalog = handle.makeCatalog(keys.schema);
56  PTR(afw::table::BaseRecord) record = catalog.addNew();
57  record->set(keys.kernel, handle.put(_kernel));
58  record->set(keys.averagePosition, _averagePosition);
59  handle.saveCatalog(catalog);
60 }
61 
62 }}} // namespace lsst::meas::algorithms
boost::shared_ptr< afw::math::Kernel > _kernel
Definition: KernelPsf.h:90
A read-only singleton struct containing the schema and key used in persistence for KernelPsf...
#define PTR(...)
Definition: base.h:41
A Psf defined by a Kernel.
Definition: KernelPsf.h:33
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
An object passed to Persistable::write to allow it to persist itself.
int put(Persistable const *obj, bool permissive=false)
Save a nested Persistable to the same archive.
A custom container class for records, based on std::vector.
Definition: Catalog.h:94
daf::base::Citizen & getCitizen()
Get the Citizen corresponding to this Schema (SchemaImpl is what inherits from Citizen).
Definition: Schema.h:283
static KernelPsfPersistenceHelper const & get()
Definition: KernelPsf.cc:32
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:469
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
void markPersistent(void)
Mark a Citizen as persistent and not destroyed until process end.
Definition: Citizen.cc:253
afwMath::LinearCombinationKernel const & _kernel
virtual bool isPersistable() const
Whether this object is persistable; just delegates to the kernel.
Definition: KernelPsf.cc:47
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:16
geom::Extent2I const getDimensions() const
Return the Kernel&#39;s dimensions (width, height)
Definition: Kernel.h:226
tbl::Schema schema
virtual afw::geom::Point2D getAveragePosition() const
Return average position of stars; used as default position.
Definition: KernelPsf.cc:24
afw::geom::Point2D _averagePosition
Definition: KernelPsf.h:91
Base class for all records.
Definition: BaseRecord.h:27
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:51
Point< double, 2 > Point2D
Definition: Point.h:286
An intermediate base class for Psfs that use an image representation.
Definition: ImagePsf.h:37
tbl::PointKey< double > averagePosition
Definition: CoaddPsf.cc:319
A PersistableFactory for KernelPsf and its subclasses.
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:134
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
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
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
Definition: KernelPsf.cc:49