24 #include "boost/make_shared.hpp"
34 namespace lsst {
namespace afw {
namespace detection {
40 struct GaussianPsfPersistenceHelper :
private boost::noncopyable {
45 static GaussianPsfPersistenceHelper
const &
get() {
46 static GaussianPsfPersistenceHelper instance;
51 GaussianPsfPersistenceHelper() :
54 afw::table::PointKey<int>::addFields(
57 "width/height of realization of Psf",
"pixels"
60 sigma(
schema.addField<double>(
"sigma",
"radius of Gaussian",
"pixels"))
62 schema.getCitizen().markPersistent();
66 class GaussianPsfFactory :
public afw::table::io::PersistableFactory {
69 virtual PTR(afw::table::io::Persistable)
70 read(InputArchive const & archive, CatalogVector const & catalogs)
const {
71 static GaussianPsfPersistenceHelper
const & keys = GaussianPsfPersistenceHelper::get();
74 afw::table::BaseRecord
const & record = catalogs.front().front();
76 return boost::make_shared<GaussianPsf>(
77 record.get(keys.dimensions.getX()),
78 record.get(keys.dimensions.getY()),
79 record.get(keys.sigma)
83 GaussianPsfFactory(std::string
const &
name) : afw::table::io::PersistableFactory(name) {}
87 GaussianPsfFactory registration(
"GaussianPsf");
90 if (dimensions.getX() % 2 == 0 || dimensions.getY() % 2 == 2) {
92 pex::exceptions::InvalidParameterError,
93 "GaussianPsf dimensions must be odd"
101 Psf(true), _dimensions(width, height),
_sigma(sigma)
107 Psf(true), _dimensions(dimensions),
_sigma(sigma)
113 return boost::make_shared<GaussianPsf>(_dimensions,
_sigma);
121 static GaussianPsfPersistenceHelper
const & keys = GaussianPsfPersistenceHelper::get();
124 (*record)[keys.dimensions.getX()] =
_dimensions.getX();
125 (*record)[keys.dimensions.getY()] =
_dimensions.getY();
137 for (
int yIndex = 0,
y = r->getY0(); yIndex < _dimensions.getY(); ++yIndex, ++
y) {
138 Image::Array::Reference
row = array[yIndex];
139 for (
int xIndex = 0,
x = r->getX0(); xIndex < _dimensions.getX(); ++xIndex, ++
x) {
150 return 1.0 - std::exp(-0.5*radius*radius/(
_sigma*
_sigma));
An ellipse core with quadrupole moments as parameters.
geom::Extent2I _dimensions
table::Key< std::string > name
Eigen matrix objects that present a view into an ndarray::Array.
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
An object passed to Persistable::write to allow it to persist itself.
A custom container class for records, based on std::vector.
afw::table::Schema schema
GaussianPsf(int width, int height, double sigma)
Constructor for a GaussianPsf.
virtual geom::ellipses::Quadrupole doComputeShape(geom::Point2D const &position, image::Color const &color) const
Point< double, 2 > Point2D
EigenView< Element, ND::value, RMC::value, XprKind, Rows, Cols > asEigen() const
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
afw::table::Key< double > sigma
table::Key< table::Array< Kernel::Pixel > > image
afw::table::PointKey< int > dimensions
void ImageT ImageT int float saturatedPixelValue int const width
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
void ImageT ImageT int float saturatedPixelValue int const height
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
#define LSST_EXCEPT(type,...)
A multidimensional strided array.
double getSigma() const
Return the radius of the Gaussian.
Base class for all records.
boost::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
A polymorphic base class for representing an image's Point Spread Function.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purp...
virtual double doComputeApertureFlux(double radius, geom::Point2D const &position, image::Color const &color) const