31 namespace lsst {
namespace meas {
namespace algorithms {
39 afw::
math::BoundedField(bbox),
40 _throwOnMissing(true),
53 _throwOnMissing(false),
60 auto coord = _coaddWcs->pixelToSky(position);
63 for (ElementVector::const_iterator i = _elements.
begin(); i != _elements.
end(); ++i) {
65 bool inValidArea = i->validPolygon ? i->validPolygon->contains(transformedPosition) :
true;
66 if (
afw::geom::Box2D(i->field->getBBox()).contains(transformedPosition) && inValidArea) {
67 sum += i->weight * i->field->evaluate(transformedPosition);
72 if (_throwOnMissing) {
75 (boost::format(
"No constituent fields to evaluate at point %f, %f")
76 % position.getX() % position.getY()).str()
93 namespace tbl = afw::table;
96 class CoaddBoundedFieldPersistenceKeys1 {
105 static CoaddBoundedFieldPersistenceKeys1
const &
get() {
106 static CoaddBoundedFieldPersistenceKeys1
const instance;
111 CoaddBoundedFieldPersistenceKeys1 (
const CoaddBoundedFieldPersistenceKeys1&) =
delete;
112 CoaddBoundedFieldPersistenceKeys1&
operator=(
const CoaddBoundedFieldPersistenceKeys1&) =
delete;
115 CoaddBoundedFieldPersistenceKeys1 (CoaddBoundedFieldPersistenceKeys1&&) =
delete;
116 CoaddBoundedFieldPersistenceKeys1&
operator=(CoaddBoundedFieldPersistenceKeys1&&) =
delete;
119 CoaddBoundedFieldPersistenceKeys1() :
121 bboxMin(tbl::PointKey<int>::addFields(
122 schema,
"bbox_min",
"lower-left corner of bounding box",
"pixel")),
123 bboxMax(tbl::PointKey<int>::addFields(
124 schema,
"bbox_max",
"upper-right corner of bounding box",
"pixel")),
125 coaddWcs(schema.addField<
int>(
"coaddWcs",
"archive ID of the coadd's WCS")),
127 "whether to throw an exception on missing data")),
128 default_(schema.addField<
double>(
"default",
"default value to use when throwOnMissing is False"))
130 schema.getCitizen().markPersistent();
135 class CoaddBoundedFieldPersistenceKeys2 {
143 static CoaddBoundedFieldPersistenceKeys2
const &
get() {
144 static CoaddBoundedFieldPersistenceKeys2
const instance;
149 CoaddBoundedFieldPersistenceKeys2 (
const CoaddBoundedFieldPersistenceKeys2&) =
delete;
150 CoaddBoundedFieldPersistenceKeys2&
operator=(
const CoaddBoundedFieldPersistenceKeys2&) =
delete;
153 CoaddBoundedFieldPersistenceKeys2 (CoaddBoundedFieldPersistenceKeys2&&) =
delete;
154 CoaddBoundedFieldPersistenceKeys2&
operator=(CoaddBoundedFieldPersistenceKeys2&&) =
delete;
157 CoaddBoundedFieldPersistenceKeys2() :
159 field(schema.addField<
int>(
"field",
"archive ID of the BoundedField to be coadded")),
160 wcs(schema.addField<
int>(
"wcs",
"archive ID of the Wcs associated with this element")),
161 validPolygon(schema.addField<
int>(
"validPolygon",
"archive ID of the Polygon associated with this element")),
162 weight(schema.addField<
double>(
"weight",
"weight value for this element"))
164 schema.getCitizen().markPersistent();
173 virtual PTR(tbl::io::Persistable)
174 read(InputArchive const & archive, CatalogVector const & catalogs)
const {
175 CoaddBoundedFieldPersistenceKeys1
const & keys1 = CoaddBoundedFieldPersistenceKeys1::get();
176 CoaddBoundedFieldPersistenceKeys2
const & keys2 = CoaddBoundedFieldPersistenceKeys2::get();
182 elements.
reserve(catalogs.back().size());
183 for (tbl::BaseCatalog::const_iterator i = catalogs.back().begin(); i != catalogs.back().end(); ++i) {
193 return std::make_shared<CoaddBoundedField>(
197 record1.get(keys1.default_)
207 std::string getCoaddBoundedFieldPersistenceName() {
return "CoaddBoundedField"; }
218 CoaddBoundedFieldPersistenceKeys1
const & keys1 = CoaddBoundedFieldPersistenceKeys1::get();
219 CoaddBoundedFieldPersistenceKeys2
const & keys2 = CoaddBoundedFieldPersistenceKeys2::get();
222 record1->set(keys1.bboxMin,
getBBox().getMin());
223 record1->set(keys1.bboxMax,
getBBox().getMax());
224 record1->set(keys1.coaddWcs, handle.put(_coaddWcs));
225 record1->set(keys1.default_, _default);
226 handle.saveCatalog(cat1);
228 for (ElementVector::const_iterator i = _elements.begin(); i != _elements.end(); ++i) {
230 record2->set(keys2.field, handle.put(i->field));
231 record2->set(keys2.wcs, handle.put(i->wcs));
232 record2->set(keys2.validPolygon, handle.put(i->validPolygon));
233 record2->set(keys2.weight, i->weight);
235 handle.saveCatalog(cat2);
244 if (!rhsCasted)
return false;
246 return (
getBBox() == rhsCasted->getBBox()) && (_default == rhsCasted->_default) &&
247 ((*_coaddWcs) == (*rhsCasted->_coaddWcs)) && (_elements == rhsCasted->_elements);
virtual std::string getPersistenceName() const
virtual std::string getPythonModule() const
tbl::Key< double > weight
#define LSST_ARCHIVE_ASSERT(EXPR)
CoaddBoundedFieldElement Element
virtual void write(OutputArchiveHandle &handle) const
tbl::Key< int > validPolygon
BoundedField & operator=(BoundedField const &)=delete
geom::Box2I getBBox() const
BoundedField(BoundedField const &)=default
virtual double evaluate(afw::geom::Point2D const &position) const
virtual bool operator==(BoundedField const &rhs) const
BoundedFields (of the same sublcass) are equal if their bounding boxes and parameters are equal...
tbl::Key< double > default_
Factory(std::string const &name)
#define LSST_EXCEPT(type,...)
tbl::PointKey< int > bboxMax
tbl::Key< tbl::Flag > throwOnMissing
virtual boost::shared_ptr< afw::math::BoundedField > operator*(double const scale) const
io::OutputArchiveHandle OutputArchiveHandle
CoaddBoundedField(afw::geom::Box2I const &bbox, boost::shared_ptr< afw::geom::SkyWcs const > coaddWcs, ElementVector const &elements)
std::shared_ptr< RecordT > addNew()
tbl::PointKey< int > bboxMin