41template std::shared_ptr<meas::algorithms::DoubleGaussianPsf>
54struct DoubleGaussianPsfPersistenceHelper {
61 static DoubleGaussianPsfPersistenceHelper
const& get() {
62 static DoubleGaussianPsfPersistenceHelper instance;
67 DoubleGaussianPsfPersistenceHelper(
const DoubleGaussianPsfPersistenceHelper&) =
delete;
68 DoubleGaussianPsfPersistenceHelper& operator=(
const DoubleGaussianPsfPersistenceHelper&) =
delete;
71 DoubleGaussianPsfPersistenceHelper(DoubleGaussianPsfPersistenceHelper&&) =
delete;
72 DoubleGaussianPsfPersistenceHelper& operator=(DoubleGaussianPsfPersistenceHelper&&) =
delete;
75 DoubleGaussianPsfPersistenceHelper()
77 dimensions(
afw::table::PointKey<int>::addFields(schema,
"dimensions",
"width/height of kernel",
79 sigma1(schema.addField<double>(
"sigma1",
"radius of inner Gaussian",
"pixel")),
80 sigma2(schema.addField<double>(
"sigma2",
"radius of outer Gaussian",
"pixel")),
81 b(schema.addField<double>(
"b",
"central amplitude of outer Gaussian (inner amplitude == 1)")) {}
86 virtual std::shared_ptr<afw::table::io::Persistable>
87 read(InputArchive
const& archive, CatalogVector
const& catalogs)
const {
88 static DoubleGaussianPsfPersistenceHelper
const&
keys = DoubleGaussianPsfPersistenceHelper::get();
94 record.get(
keys.dimensions.getX()), record.get(
keys.dimensions.getY()),
95 record.get(
keys.sigma1), record.get(
keys.sigma2), record.get(
keys.b));
98 DoubleGaussianPsfFactory(std::string
const& name) :
afw::table::io::PersistableFactory(name) {}
103std::shared_ptr<afw::math::Kernel>
104makeDoubleGaussianKernel(
int width,
int height,
double sigma1,
double& sigma2,
double b) {
105 if (b == 0.0 && sigma2 == 0.0) {
108 if (sigma1 <= 0 || sigma2 <= 0) {
110 (boost::format(
"sigma may not be 0: %g, %g") % sigma1 % sigma2).str());
117std::string getDoubleGaussianPsfPersistenceName() {
return "DoubleGaussianPsf"; }
119DoubleGaussianPsfFactory registration(getDoubleGaussianPsfPersistenceName());
124 :
KernelPsf(makeDoubleGaussianKernel(width, height, sigma1, sigma2, b)),
141 static DoubleGaussianPsfPersistenceHelper
const& keys = DoubleGaussianPsfPersistenceHelper::get();
144 (*record).set(keys.dimensions.getX(),
getKernel()->getWidth());
145 (*record).set(keys.dimensions.getY(),
getKernel()->getHeight());
148 (*record).set(keys.b,
getB());
149 handle.saveCatalog(catalog);
#define LSST_EXCEPT(type,...)
#define LSST_ARCHIVE_ASSERT(EXPR)
std::shared_ptr< RecordT > addNew()
static std::shared_ptr< T > dynamicCast(std::shared_ptr< Persistable > const &ptr)
io::OutputArchiveHandle OutputArchiveHandle
std::string getPersistenceName() const override
void write(OutputArchiveHandle &handle) const override
double getSigma1() const
Return the radius of the inner Gaussian.
DoubleGaussianPsf(int width, int height, double sigma1, double sigma2=0.0, double b=0.0)
Constructor for a DoubleGaussianPsf.
double getSigma2() const
Return the radius of the outer Gaussian.
std::shared_ptr< afw::detection::Psf > clone() const override
Polymorphic deep copy. Usually unnecessary, as Psfs are immutable.
double getB() const
Return the ratio of Gaussian peak amplitudes: outer/inner.
std::shared_ptr< afw::detection::Psf > resized(int width, int height) const override
Return a clone with specified kernel dimensions.
KernelPsf(afw::math::Kernel const &kernel, geom::Point2D const &averagePosition=geom::Point2D())
Construct a KernelPsf with a clone of the given kernel.
std::shared_ptr< afw::math::Kernel const > getKernel() const
Return the Kernel used to define this Psf.
CatalogT< BaseRecord > BaseCatalog
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override