18 struct GaussianFunction2PersistenceHelper {
24 static GaussianFunction2PersistenceHelper
const&
get() {
25 static GaussianFunction2PersistenceHelper instance;
30 GaussianFunction2PersistenceHelper(
const GaussianFunction2PersistenceHelper&) =
delete;
31 GaussianFunction2PersistenceHelper& operator=(
const GaussianFunction2PersistenceHelper&) =
delete;
34 GaussianFunction2PersistenceHelper(GaussianFunction2PersistenceHelper&&) =
delete;
35 GaussianFunction2PersistenceHelper& operator=(GaussianFunction2PersistenceHelper&&) =
delete;
38 GaussianFunction2PersistenceHelper()
40 sigma1(schema.addField<
double>(
"sigma1",
"sigma along axis 1")),
41 sigma2(schema.addField<
double>(
"sigma2",
"sigma along axis 2")),
42 angle(schema.addField<
double>(
"angle",
"angle of axis 1 in rad (along x=0, y=pi/2)")) {}
46 struct DoubleGaussianFunction2PersistenceHelper {
52 static DoubleGaussianFunction2PersistenceHelper
const&
get() {
53 static DoubleGaussianFunction2PersistenceHelper instance;
58 DoubleGaussianFunction2PersistenceHelper(
const DoubleGaussianFunction2PersistenceHelper&) =
delete;
59 DoubleGaussianFunction2PersistenceHelper& operator=(
const DoubleGaussianFunction2PersistenceHelper&) =
63 DoubleGaussianFunction2PersistenceHelper(DoubleGaussianFunction2PersistenceHelper&&) =
delete;
64 DoubleGaussianFunction2PersistenceHelper& operator=(DoubleGaussianFunction2PersistenceHelper&&) =
delete;
67 DoubleGaussianFunction2PersistenceHelper()
69 sigma1(schema.addField<
double>(
"sigma1",
"sigma of first Gaussian")),
70 sigma2(schema.addField<
double>(
"sigma2",
"sigma of second Gaussian")),
71 ampl2(schema.addField<
double>(
"ampl2",
"peak of second Gaussian relative to peak of first")) {}
75 struct PolynomialFunction2PersistenceHelper {
79 explicit PolynomialFunction2PersistenceHelper(
int nCoefficients)
81 coefficients(schema.addField<table::Array<double> >(
83 "polynomial coefficients, ordered (x,y) [0,0; 1,0; 0,1; 2,0; 1,1; 0,2; ...]",
86 explicit PolynomialFunction2PersistenceHelper(table::Schema
const& schema_)
91 struct Chebyshev1Function2PersistenceHelper :
public PolynomialFunction2PersistenceHelper {
92 table::PointKey<double>
min;
93 table::PointKey<double>
max;
95 explicit Chebyshev1Function2PersistenceHelper(
int nCoefficients)
96 : PolynomialFunction2PersistenceHelper(nCoefficients),
97 min(table::PointKey<double>::addFields(
schema,
"min",
"minimum point for function's bbox",
99 max(table::PointKey<double>::addFields(
schema,
"max",
"maximum point for function's bbox",
102 explicit Chebyshev1Function2PersistenceHelper(table::Schema
const& schema_)
103 : PolynomialFunction2PersistenceHelper(schema_),
min(
schema[
"min"]),
max(
schema[
"max"]) {}
106 template <
typename ReturnT>
107 class GaussianFunction2Factory :
public table::io::PersistableFactory {
110 CatalogVector
const& catalogs)
const override {
113 GaussianFunction2PersistenceHelper
const&
keys = GaussianFunction2PersistenceHelper::get();
115 table::BaseRecord
const& record = catalogs.front().front();
116 return std::make_shared<GaussianFunction2<ReturnT> >(record.get(keys.sigma1), record.get(keys.sigma2),
117 record.get(keys.angle));
120 GaussianFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
123 template <
typename ReturnT>
124 class DoubleGaussianFunction2Factory :
public table::io::PersistableFactory {
127 CatalogVector
const& catalogs)
const override {
130 DoubleGaussianFunction2PersistenceHelper
const&
keys =
131 DoubleGaussianFunction2PersistenceHelper::get();
133 table::BaseRecord
const& record = catalogs.front().front();
134 return std::make_shared<DoubleGaussianFunction2<ReturnT> >(
135 record.get(keys.sigma1), record.get(keys.sigma2), record.get(keys.ampl2));
138 DoubleGaussianFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
141 template <
typename ReturnT>
142 class PolynomialFunction2Factory :
public table::io::PersistableFactory {
145 CatalogVector
const& catalogs)
const override {
148 PolynomialFunction2PersistenceHelper
const keys(catalogs.front().getSchema());
149 return std::make_shared<PolynomialFunction2<ReturnT> >(
150 keys.coefficients.extractVector(catalogs.front().front()));
153 PolynomialFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
156 template <
typename ReturnT>
157 class Chebyshev1Function2Factory :
public table::io::PersistableFactory {
160 CatalogVector
const& catalogs)
const override {
163 Chebyshev1Function2PersistenceHelper
keys(catalogs.front().getSchema());
164 table::BaseRecord
const& record = catalogs.front().front();
166 return std::make_shared<Chebyshev1Function2<ReturnT> >(
keys.coefficients.extractVector(record),
bbox);
169 Chebyshev1Function2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
172 GaussianFunction2Factory<float> registrationGaussian2F(
"GaussianFunction2F");
173 GaussianFunction2Factory<double> registrationGaussian2D(
"GaussianFunction2D");
175 DoubleGaussianFunction2Factory<float> registrationDoubleGaussian2F(
"DoubleGaussianFunction2F");
176 DoubleGaussianFunction2Factory<double> registrationDoubleGaussian2D(
"DoubleGaussianFunction2D");
178 PolynomialFunction2Factory<float> registrationPoly2F(
"PolynomialFunction2F");
179 PolynomialFunction2Factory<double> registrationPoly2D(
"PolynomialFunction2D");
181 Chebyshev1Function2Factory<float> registrationCheb2F(
"Chebyshev1Function2F");
182 Chebyshev1Function2Factory<double> registrationCheb2D(
"Chebyshev1Function2D");
184 template <
typename T>
187 struct Suffix<float> {
191 struct Suffix<double> {
197 template <
typename ReturnT>
199 return "GaussianFunction2" + Suffix<ReturnT>::get();
202 template <
typename ReturnT>
204 return "DoubleGaussianFunction2" + Suffix<ReturnT>::get();
207 template <
typename ReturnT>
209 return "PolynomialFunction2" + Suffix<ReturnT>::get();
212 template <
typename ReturnT>
214 return "Chebyshev1Function2" + Suffix<ReturnT>::get();
217 template <
typename ReturnT>
219 GaussianFunction2PersistenceHelper
const&
keys = GaussianFunction2PersistenceHelper::get();
222 record->set(keys.sigma1, this->getParameters()[0]);
223 record->set(keys.sigma2, this->getParameters()[1]);
224 record->set(keys.angle, this->getParameters()[2]);
228 template <
typename ReturnT>
230 DoubleGaussianFunction2PersistenceHelper
const&
keys = DoubleGaussianFunction2PersistenceHelper::get();
233 record->set(keys.sigma1, this->getParameters()[0]);
234 record->set(keys.sigma2, this->getParameters()[1]);
235 record->set(keys.ampl2, this->getParameters()[2]);
239 template <
typename ReturnT>
241 PolynomialFunction2PersistenceHelper
const keys(this->getNParameters());
243 keys.coefficients.assignVector(*catalog.
addNew(), this->getParameters());
247 template <
typename ReturnT>
249 Chebyshev1Function2PersistenceHelper
const keys(this->getNParameters());
252 keys.coefficients.assignVector(*record, this->getParameters());
254 record->set(keys.min, bbox.
getMin());
255 record->set(keys.max, bbox.
getMax());
260 #define INSTANTIATE(TYPE) \ 261 template class IntegerDeltaFunction1<TYPE>; \ 262 template class IntegerDeltaFunction2<TYPE>; \ 263 template class GaussianFunction1<TYPE>; \ 264 template class GaussianFunction2<TYPE>; \ 265 template class DoubleGaussianFunction2<TYPE>; \ 266 template class PolynomialFunction1<TYPE>; \ 267 template class PolynomialFunction2<TYPE>; \ 268 template class Chebyshev1Function1<TYPE>; \ 269 template class Chebyshev1Function2<TYPE>; \ 270 template class LanczosFunction1<TYPE>; \ 271 template class LanczosFunction2<TYPE>;
void write(afw::table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
A floating-point coordinate rectangle geometry.
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.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
void write(afw::table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
table::Key< double > angle
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
Point2D const getMin() const noexcept
table::Key< double > sigma2
void write(afw::table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
#define INSTANTIATE(TYPE)
A base class for image defects.
table::PointKey< double > min
table::PointKey< double > max
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
Point2D const getMax() const noexcept
table::Key< table::Array< double > > coefficients
table::Key< double > ampl2
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
void write(afw::table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
table::Key< double > sigma1
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.