17struct GaussianFunction2PersistenceHelper {
23 static GaussianFunction2PersistenceHelper
const& get() {
24 static GaussianFunction2PersistenceHelper instance;
29 GaussianFunction2PersistenceHelper(
const GaussianFunction2PersistenceHelper&) =
delete;
30 GaussianFunction2PersistenceHelper& operator=(
const GaussianFunction2PersistenceHelper&) =
delete;
33 GaussianFunction2PersistenceHelper(GaussianFunction2PersistenceHelper&&) =
delete;
34 GaussianFunction2PersistenceHelper& operator=(GaussianFunction2PersistenceHelper&&) =
delete;
37 GaussianFunction2PersistenceHelper()
39 sigma1(
schema.addField<double>(
"sigma1",
"sigma along axis 1")),
40 sigma2(
schema.addField<double>(
"sigma2",
"sigma along axis 2")),
41 angle(
schema.addField<double>(
"angle",
"angle of axis 1 in rad (along x=0, y=pi/2)")) {}
45struct DoubleGaussianFunction2PersistenceHelper {
51 static DoubleGaussianFunction2PersistenceHelper
const& get() {
52 static DoubleGaussianFunction2PersistenceHelper instance;
57 DoubleGaussianFunction2PersistenceHelper(
const DoubleGaussianFunction2PersistenceHelper&) =
delete;
58 DoubleGaussianFunction2PersistenceHelper& operator=(
const DoubleGaussianFunction2PersistenceHelper&) =
62 DoubleGaussianFunction2PersistenceHelper(DoubleGaussianFunction2PersistenceHelper&&) =
delete;
63 DoubleGaussianFunction2PersistenceHelper& operator=(DoubleGaussianFunction2PersistenceHelper&&) =
delete;
66 DoubleGaussianFunction2PersistenceHelper()
68 sigma1(
schema.addField<double>(
"sigma1",
"sigma of first Gaussian")),
69 sigma2(
schema.addField<double>(
"sigma2",
"sigma of second Gaussian")),
70 ampl2(
schema.addField<double>(
"ampl2",
"peak of second Gaussian relative to peak of first")) {}
74struct PolynomialFunction2PersistenceHelper {
78 explicit PolynomialFunction2PersistenceHelper(
int nCoefficients)
82 "polynomial coefficients, ordered (x,y) [0,0; 1,0; 0,1; 2,0; 1,1; 0,2; ...]",
85 explicit PolynomialFunction2PersistenceHelper(table::Schema
const& schema_)
90struct Chebyshev1Function2PersistenceHelper :
public PolynomialFunction2PersistenceHelper {
91 table::PointKey<double>
min;
92 table::PointKey<double>
max;
94 explicit Chebyshev1Function2PersistenceHelper(
int nCoefficients)
95 : PolynomialFunction2PersistenceHelper(nCoefficients),
96 min(table::PointKey<double>::addFields(
schema,
"min",
"minimum point for function's bbox",
98 max(table::PointKey<double>::addFields(
schema,
"max",
"maximum point for function's bbox",
101 explicit Chebyshev1Function2PersistenceHelper(table::Schema
const& schema_)
102 : PolynomialFunction2PersistenceHelper(schema_),
min(
schema[
"min"]),
max(
schema[
"max"]) {}
105template <
typename ReturnT>
106class GaussianFunction2Factory :
public table::io::PersistableFactory {
109 CatalogVector
const& catalogs)
const override {
112 GaussianFunction2PersistenceHelper
const&
keys = GaussianFunction2PersistenceHelper::get();
114 table::BaseRecord
const& record = catalogs.front().front();
115 return std::make_shared<GaussianFunction2<ReturnT> >(record.get(
keys.sigma1), record.get(
keys.sigma2),
116 record.get(
keys.angle));
122template <
typename ReturnT>
123class DoubleGaussianFunction2Factory :
public table::io::PersistableFactory {
126 CatalogVector
const& catalogs)
const override {
129 DoubleGaussianFunction2PersistenceHelper
const&
keys =
130 DoubleGaussianFunction2PersistenceHelper::get();
132 table::BaseRecord
const& record = catalogs.front().front();
133 return std::make_shared<DoubleGaussianFunction2<ReturnT> >(
134 record.get(
keys.sigma1), record.get(
keys.sigma2), record.get(
keys.ampl2));
137 DoubleGaussianFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(
name) {}
140template <
typename ReturnT>
141class PolynomialFunction2Factory :
public table::io::PersistableFactory {
144 CatalogVector
const& catalogs)
const override {
147 PolynomialFunction2PersistenceHelper
const keys(catalogs.front().getSchema());
148 return std::make_shared<PolynomialFunction2<ReturnT> >(
149 keys.coefficients.extractVector(catalogs.front().front()));
152 PolynomialFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(
name) {}
155template <
typename ReturnT>
156class Chebyshev1Function2Factory :
public table::io::PersistableFactory {
159 CatalogVector
const& catalogs)
const override {
162 Chebyshev1Function2PersistenceHelper
keys(catalogs.front().getSchema());
163 table::BaseRecord
const& record = catalogs.front().front();
165 return std::make_shared<Chebyshev1Function2<ReturnT> >(
keys.coefficients.extractVector(record),
bbox);
168 Chebyshev1Function2Factory(
std::string const&
name) : table::io::PersistableFactory(
name) {}
171GaussianFunction2Factory<float> registrationGaussian2F(
"GaussianFunction2F");
172GaussianFunction2Factory<double> registrationGaussian2D(
"GaussianFunction2D");
174DoubleGaussianFunction2Factory<float> registrationDoubleGaussian2F(
"DoubleGaussianFunction2F");
175DoubleGaussianFunction2Factory<double> registrationDoubleGaussian2D(
"DoubleGaussianFunction2D");
177PolynomialFunction2Factory<float> registrationPoly2F(
"PolynomialFunction2F");
178PolynomialFunction2Factory<double> registrationPoly2D(
"PolynomialFunction2D");
180Chebyshev1Function2Factory<float> registrationCheb2F(
"Chebyshev1Function2F");
181Chebyshev1Function2Factory<double> registrationCheb2D(
"Chebyshev1Function2D");
186struct Suffix<float> {
190struct Suffix<double> {
196template <
typename ReturnT>
198 return "GaussianFunction2" + Suffix<ReturnT>::get();
201template <
typename ReturnT>
203 return "DoubleGaussianFunction2" + Suffix<ReturnT>::get();
206template <
typename ReturnT>
208 return "PolynomialFunction2" + Suffix<ReturnT>::get();
211template <
typename ReturnT>
213 return "Chebyshev1Function2" + Suffix<ReturnT>::get();
216template <
typename ReturnT>
218 GaussianFunction2PersistenceHelper
const& keys = GaussianFunction2PersistenceHelper::get();
221 record->set(keys.sigma1, this->getParameters()[0]);
222 record->set(keys.sigma2, this->getParameters()[1]);
223 record->set(keys.angle, this->getParameters()[2]);
227template <
typename ReturnT>
229 DoubleGaussianFunction2PersistenceHelper
const& keys = DoubleGaussianFunction2PersistenceHelper::get();
232 record->set(keys.sigma1, this->getParameters()[0]);
233 record->set(keys.sigma2, this->getParameters()[1]);
234 record->set(keys.ampl2, this->getParameters()[2]);
238template <
typename ReturnT>
240 PolynomialFunction2PersistenceHelper
const keys(this->getNParameters());
242 keys.coefficients.assignVector(*catalog.addNew(), this->getParameters());
246template <
typename ReturnT>
248 Chebyshev1Function2PersistenceHelper
const keys(this->getNParameters());
251 keys.coefficients.assignVector(*record, this->getParameters());
253 record->set(keys.min,
bbox.getMin());
254 record->set(keys.max,
bbox.getMax());
259#define INSTANTIATE(TYPE) \
260 template class IntegerDeltaFunction1<TYPE>; \
261 template class IntegerDeltaFunction2<TYPE>; \
262 template class GaussianFunction1<TYPE>; \
263 template class GaussianFunction2<TYPE>; \
264 template class DoubleGaussianFunction2<TYPE>; \
265 template class PolynomialFunction1<TYPE>; \
266 template class PolynomialFunction2<TYPE>; \
267 template class Chebyshev1Function1<TYPE>; \
268 template class Chebyshev1Function2<TYPE>; \
269 template class LanczosFunction1<TYPE>; \
270 template class LanczosFunction2<TYPE>;
table::Key< std::string > name
ndarray::Array< double const, 2, 2 > coefficients
#define INSTANTIATE(FROMSYS, TOSYS)
table::Key< double > angle
table::Key< double > ampl2
table::Key< double > sigma2
table::Key< double > sigma1
#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.
void write(afw::table::io::OutputArchiveHandle &handle) const override
Write the object to one or more catalogs.
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.
std::string getPersistenceName() const override
Return the unique name used to persist this object and look up its factory.
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.
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
A floating-point coordinate rectangle geometry.
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override