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 :
private boost::noncopyable {
105 static CoaddBoundedFieldPersistenceKeys1
const &
get() {
106 static CoaddBoundedFieldPersistenceKeys1
const instance;
111 CoaddBoundedFieldPersistenceKeys1() :
113 bboxMin(tbl::PointKey<int>::addFields(
114 schema,
"bbox_min",
"lower-left corner of bounding box",
"pixels")),
115 bboxMax(tbl::PointKey<int>::addFields(
116 schema,
"bbox_max",
"upper-right corner of bounding box",
"pixels")),
117 coaddWcs(
schema.addField<int>(
"coaddWcs",
"archive ID of the coadd's WCS")),
119 "whether to throw an exception on missing data")),
120 default_(
schema.addField<double>(
"default",
"default value to use when throwOnMissing is False"))
122 schema.getCitizen().markPersistent();
127 class CoaddBoundedFieldPersistenceKeys2 :
private boost::noncopyable {
135 static CoaddBoundedFieldPersistenceKeys2
const &
get() {
136 static CoaddBoundedFieldPersistenceKeys2
const instance;
141 CoaddBoundedFieldPersistenceKeys2() :
143 field(
schema.addField<int>(
"field",
"archive ID of the BoundedField to be coadded")),
144 wcs(
schema.addField<int>(
"wcs",
"archive ID of the Wcs associated with this element")),
145 validPolygon(
schema.addField<int>(
"validPolygon",
"archive ID of the Polygon associated with this element")),
146 weight(
schema.addField<double>(
"weight",
"weight value for this element"))
148 schema.getCitizen().markPersistent();
157 virtual PTR(tbl::io::Persistable)
158 read(InputArchive const & archive, CatalogVector const & catalogs)
const {
159 CoaddBoundedFieldPersistenceKeys1
const & keys1 = CoaddBoundedFieldPersistenceKeys1::get();
160 CoaddBoundedFieldPersistenceKeys2
const & keys2 = CoaddBoundedFieldPersistenceKeys2::get();
166 elements.reserve(catalogs.back().size());
167 for (tbl::BaseCatalog::const_iterator i = catalogs.back().begin(); i != catalogs.back().end(); ++i) {
177 return boost::make_shared<CoaddBoundedField>(
181 record1.get(keys1.default_)
185 Factory(std::string
const &
name) : tbl::io::PersistableFactory(name) {}
191 std::string getCoaddBoundedFieldPersistenceName() {
return "CoaddBoundedField"; }
193 CoaddBoundedField::Factory registration(getCoaddBoundedFieldPersistenceName());
202 CoaddBoundedFieldPersistenceKeys1
const & keys1 = CoaddBoundedFieldPersistenceKeys1::get();
203 CoaddBoundedFieldPersistenceKeys2
const & keys2 = CoaddBoundedFieldPersistenceKeys2::get();
206 record1->set(keys1.bboxMin,
getBBox().getMin());
207 record1->set(keys1.bboxMax,
getBBox().getMax());
209 record1->set(keys1.default_,
_default);
212 for (ElementVector::const_iterator i =
_elements.begin(); i !=
_elements.end(); ++i) {
214 record2->set(keys2.field, handle.
put(i->field));
215 record2->set(keys2.wcs, handle.
put(i->wcs));
216 record2->set(keys2.validPolygon, handle.
put(i->validPolygon));
217 record2->set(keys2.weight, i->weight);
223 throw LSST_EXCEPT(pex::exceptions::NotFoundError,
"Scaling of CoaddBoundedField is not implemented");
table::Key< std::string > name
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
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.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
int put(Persistable const *obj, bool permissive=false)
Save a nested Persistable to the same archive.
A custom container class for records, based on std::vector.
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.
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
boost::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
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_
geom::Box2I getBBox() const
virtual std::string getPersistenceName() const
Return the unique name used to persist this object and look up its factory.
Factory(std::string const &name)
#define LSST_EXCEPT(type,...)
tbl::PointKey< int > bboxMax
Base class for all records.
tbl::Key< tbl::Flag > throwOnMissing
An abstract base class for 2-d functions defined on an integer bounding boxes.
A floating-point coordinate rectangle geometry.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
tbl::PointKey< int > bboxMin