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.
table::Key< std::string > name
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
Eigen matrix objects that present a view into an ndarray::Array.
An object passed to Persistable::write to allow it to persist itself.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A custom container class for records, based on std::vector.
virtual geom::ellipses::Quadrupole doComputeShape(geom::Point2D const &position, image::Color const &color) const
EigenView< Element, ND::value, RMC::value, XprKind, Rows, Cols > asEigen() const
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
boost::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
double getSigma() const
Return the radius of the Gaussian.
afw::table::Key< double > sigma
table::Key< table::Array< Kernel::Pixel > > image
afw::table::PointKey< int > dimensions
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
GaussianPsf(int width, int height, double sigma)
Constructor for a GaussianPsf.
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
geom::Extent2I _dimensions
#define LSST_EXCEPT(type,...)
virtual double doComputeApertureFlux(double radius, geom::Point2D const &position, image::Color const &color) const
A multidimensional strided array.
Base class for all records.
Point< double, 2 > Point2D
A polymorphic base class for representing an image's Point Spread Function.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purp...