31 namespace lsst {
namespace meas {
namespace algorithms {
39 afw::math::BoundedField(bbox),
40 _throwOnMissing(true),
52 afw::math::BoundedField(bbox),
53 _throwOnMissing(false),
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);
74 pex::exceptions::DomainError,
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_)
201 Factory(std::string
const &
name) : tbl::io::PersistableFactory(name) {}
207 std::string getCoaddBoundedFieldPersistenceName() {
return "CoaddBoundedField"; }
209 CoaddBoundedField::Factory registration(getCoaddBoundedFieldPersistenceName());
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());
225 record1->set(keys1.default_,
_default);
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);
239 throw LSST_EXCEPT(pex::exceptions::NotFoundError,
"Scaling of CoaddBoundedField is not implemented");
table::PointKey< int > bboxMax
int put(Persistable const *obj, bool permissive=false)
Save a nested Persistable to the same archive.
table::Key< std::string > name
boost::shared_ptr< afw::image::Wcs const > _coaddWcs
tbl::Key< double > weight
std::vector< Element > ElementVector
An object passed to Persistable::write to allow it to persist itself.
A custom container class for records, based on std::vector.
afw::table::Schema schema
virtual void write(OutputArchiveHandle &handle) const
Write the object to one or more catalogs.
CoaddBoundedFieldElement Element
virtual boost::shared_ptr< tbl::io::Persistable > read(InputArchive const &archive, CatalogVector const &catalogs) const
virtual double evaluate(afw::geom::Point2D const &position) const
virtual std::string getPythonModule() const
Return the fully-qualified Python module that should be imported to guarantee that its factory is reg...
Implementation of the WCS standard for a any projection.
geom::Box2I getBBox() const
An integer coordinate rectangle.
tbl::Key< int > validPolygon
CoaddBoundedField(afw::geom::Box2I const &bbox, boost::shared_ptr< afw::image::Wcs const > coaddWcs, ElementVector const &elements)
tbl::Key< double > default_
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
table::PointKey< int > bboxMin
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
Factory(std::string const &name)
#define LSST_EXCEPT(type,...)
Base class for all records.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
tbl::Key< tbl::Flag > throwOnMissing
boost::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
An abstract base class for 2-d functions defined on an integer bounding boxes.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
A floating-point coordinate rectangle geometry.