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)")) {
43 schema.getCitizen().markPersistent();
48 struct DoubleGaussianFunction2PersistenceHelper {
54 static DoubleGaussianFunction2PersistenceHelper
const&
get() {
55 static DoubleGaussianFunction2PersistenceHelper instance;
60 DoubleGaussianFunction2PersistenceHelper(
const DoubleGaussianFunction2PersistenceHelper&) =
delete;
61 DoubleGaussianFunction2PersistenceHelper& operator=(
const DoubleGaussianFunction2PersistenceHelper&) =
65 DoubleGaussianFunction2PersistenceHelper(DoubleGaussianFunction2PersistenceHelper&&) =
delete;
66 DoubleGaussianFunction2PersistenceHelper& operator=(DoubleGaussianFunction2PersistenceHelper&&) =
delete;
69 DoubleGaussianFunction2PersistenceHelper()
71 sigma1(schema.addField<
double>(
"sigma1",
"sigma of first Gaussian")),
72 sigma2(schema.addField<
double>(
"sigma2",
"sigma of second Gaussian")),
73 ampl2(schema.addField<
double>(
"ampl2",
"peak of second Gaussian relative to peak of first")) {
74 schema.getCitizen().markPersistent();
79 struct PolynomialFunction2PersistenceHelper {
83 explicit PolynomialFunction2PersistenceHelper(
int nCoefficients)
85 coefficients(schema.addField<table::Array<double> >(
87 "polynomial coefficients, ordered (x,y) [0,0; 1,0; 0,1; 2,0; 1,1; 0,2; ...]",
90 explicit PolynomialFunction2PersistenceHelper(table::Schema
const& schema_)
95 struct Chebyshev1Function2PersistenceHelper :
public PolynomialFunction2PersistenceHelper {
96 table::PointKey<double>
min;
97 table::PointKey<double>
max;
99 explicit Chebyshev1Function2PersistenceHelper(
int nCoefficients)
100 : PolynomialFunction2PersistenceHelper(nCoefficients),
101 min(table::PointKey<double>::addFields(
schema,
"min",
"minimum point for function's bbox",
103 max(table::PointKey<double>::addFields(
schema,
"max",
"maximum point for function's bbox",
106 explicit Chebyshev1Function2PersistenceHelper(table::Schema
const& schema_)
107 : PolynomialFunction2PersistenceHelper(schema_),
min(
schema[
"min"]),
max(
schema[
"max"]) {}
110 template <
typename ReturnT>
111 class GaussianFunction2Factory :
public table::io::PersistableFactory {
114 CatalogVector
const& catalogs)
const override {
117 GaussianFunction2PersistenceHelper
const&
keys = GaussianFunction2PersistenceHelper::get();
119 table::BaseRecord
const& record = catalogs.front().front();
120 return std::make_shared<GaussianFunction2<ReturnT> >(record.get(keys.sigma1), record.get(keys.sigma2),
121 record.get(keys.angle));
124 GaussianFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
127 template <
typename ReturnT>
128 class DoubleGaussianFunction2Factory :
public table::io::PersistableFactory {
131 CatalogVector
const& catalogs)
const override {
134 DoubleGaussianFunction2PersistenceHelper
const&
keys =
135 DoubleGaussianFunction2PersistenceHelper::get();
137 table::BaseRecord
const& record = catalogs.front().front();
138 return std::make_shared<DoubleGaussianFunction2<ReturnT> >(
139 record.get(keys.sigma1), record.get(keys.sigma2), record.get(keys.ampl2));
142 DoubleGaussianFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
145 template <
typename ReturnT>
146 class PolynomialFunction2Factory :
public table::io::PersistableFactory {
149 CatalogVector
const& catalogs)
const override {
152 PolynomialFunction2PersistenceHelper
const keys(catalogs.front().getSchema());
153 return std::make_shared<PolynomialFunction2<ReturnT> >(
154 keys.coefficients.extractVector(catalogs.front().front()));
157 PolynomialFunction2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
160 template <
typename ReturnT>
161 class Chebyshev1Function2Factory :
public table::io::PersistableFactory {
164 CatalogVector
const& catalogs)
const override {
167 Chebyshev1Function2PersistenceHelper
keys(catalogs.front().getSchema());
168 table::BaseRecord
const& record = catalogs.front().front();
170 return std::make_shared<Chebyshev1Function2<ReturnT> >(
keys.coefficients.extractVector(record),
bbox);
173 Chebyshev1Function2Factory(
std::string const&
name) : table::io::PersistableFactory(name) {}
176 GaussianFunction2Factory<float> registrationGaussian2F(
"GaussianFunction2F");
177 GaussianFunction2Factory<double> registrationGaussian2D(
"GaussianFunction2D");
179 DoubleGaussianFunction2Factory<float> registrationDoubleGaussian2F(
"DoubleGaussianFunction2F");
180 DoubleGaussianFunction2Factory<double> registrationDoubleGaussian2D(
"DoubleGaussianFunction2D");
182 PolynomialFunction2Factory<float> registrationPoly2F(
"PolynomialFunction2F");
183 PolynomialFunction2Factory<double> registrationPoly2D(
"PolynomialFunction2D");
185 Chebyshev1Function2Factory<float> registrationCheb2F(
"Chebyshev1Function2F");
186 Chebyshev1Function2Factory<double> registrationCheb2D(
"Chebyshev1Function2D");
188 template <
typename T>
191 struct Suffix<float> {
195 struct Suffix<double> {
201 template <
typename ReturnT>
203 return "GaussianFunction2" + Suffix<ReturnT>::get();
206 template <
typename ReturnT>
208 return "DoubleGaussianFunction2" + Suffix<ReturnT>::get();
211 template <
typename ReturnT>
213 return "PolynomialFunction2" + Suffix<ReturnT>::get();
216 template <
typename ReturnT>
218 return "Chebyshev1Function2" + Suffix<ReturnT>::get();
221 template <
typename ReturnT>
223 GaussianFunction2PersistenceHelper
const&
keys = GaussianFunction2PersistenceHelper::get();
226 record->set(keys.sigma1, this->getParameters()[0]);
227 record->set(keys.sigma2, this->getParameters()[1]);
228 record->set(keys.angle, this->getParameters()[2]);
232 template <
typename ReturnT>
234 DoubleGaussianFunction2PersistenceHelper
const&
keys = DoubleGaussianFunction2PersistenceHelper::get();
237 record->set(keys.sigma1, this->getParameters()[0]);
238 record->set(keys.sigma2, this->getParameters()[1]);
239 record->set(keys.ampl2, this->getParameters()[2]);
243 template <
typename ReturnT>
245 PolynomialFunction2PersistenceHelper
const keys(this->getNParameters());
247 keys.coefficients.assignVector(*catalog.
addNew(), this->getParameters());
251 template <
typename ReturnT>
253 Chebyshev1Function2PersistenceHelper
const keys(this->getNParameters());
256 keys.coefficients.assignVector(*record, this->getParameters());
258 record->set(keys.min, bbox.
getMin());
259 record->set(keys.max, bbox.
getMax());
264 #define INSTANTIATE(TYPE) \ 265 template class IntegerDeltaFunction1<TYPE>; \ 266 template class IntegerDeltaFunction2<TYPE>; \ 267 template class GaussianFunction1<TYPE>; \ 268 template class GaussianFunction2<TYPE>; \ 269 template class DoubleGaussianFunction2<TYPE>; \ 270 template class PolynomialFunction1<TYPE>; \ 271 template class PolynomialFunction2<TYPE>; \ 272 template class Chebyshev1Function1<TYPE>; \ 273 template class Chebyshev1Function2<TYPE>; \ 274 template class LanczosFunction1<TYPE>; \ 275 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.
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.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
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.