48 namespace algorithms {
 
   54 struct DoubleGaussianPsfPersistenceHelper {
 
   59     afw::table::Key<double> 
b;
 
   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)")) {}
 
   84 class DoubleGaussianPsfFactory : 
public afw::table::io::PersistableFactory {
 
   86     virtual PTR(afw::table::io::Persistable)
 
   87             read(InputArchive 
const& archive, CatalogVector 
const& catalogs)
 const {
 
   88         static DoubleGaussianPsfPersistenceHelper 
const& 
keys = DoubleGaussianPsfPersistenceHelper::get();
 
   91         afw::table::BaseRecord 
const& record = catalogs.front().front();
 
   93         return std::make_shared<DoubleGaussianPsf>(
 
   94                 record.get(
keys.dimensions.getX()), record.get(
keys.dimensions.getY()),
 
   95                 record.get(
keys.sigma1), record.get(
keys.sigma2), record.get(
keys.b));
 
  103 PTR(afw::math::Kernel)
 
  104 makeDoubleGaussianKernel(
int width, 
int height, 
double sigma1, 
double& 
sigma2, 
double b) {
 
  105     if (
b == 0.0 && 
sigma2 == 0.0) {
 
  112     afw::math::DoubleGaussianFunction2<double> dg(
sigma1, 
sigma2, 
b);
 
  113     PTR(afw::math::Kernel) kernel(
new afw::math::AnalyticKernel(width, height, dg));
 
  117 std::string getDoubleGaussianPsfPersistenceName() { 
return "DoubleGaussianPsf"; }
 
  119 DoubleGaussianPsfFactory registration(getDoubleGaussianPsfPersistenceName());
 
  123 DoubleGaussianPsf::DoubleGaussianPsf(
int width, 
int height, 
double sigma1, 
double sigma2, 
double b)
 
  130     return std::make_shared<DoubleGaussianPsf>(
getKernel()->getWidth(), 
getKernel()->getHeight(), _sigma1,
 
  135     return std::make_shared<DoubleGaussianPsf>(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());
 
  158 namespace detection {