28 #include "ndarray/eigen.h" 45 "To EndPoint of transform must have 1 axis but has " +
55 ndarray::Array<double const, 1>
const& y)
const {
56 if (x.getSize<0>() != y.getSize<0>()) {
63 int const nPoints = x.getSize<0>();
64 ndarray::Array<double, 2, 2> xy = ndarray::allocate(ndarray::makeVector(2, nPoints));
65 for (
int col = 0; col < nPoints; ++col) {
70 auto res2D = _transform.
getFrameSet()->applyForward(xy);
73 auto resShape = ndarray::makeVector(nPoints);
74 auto resStrides = ndarray::makeVector(1);
75 return ndarray::external(res2D.getData(), resShape, resStrides, res2D);
82 struct PersistenceHelper {
87 table::Key<table::Array<std::uint8_t>>
frameSet;
91 bboxMin(table::PointKey<int>::addFields(schema,
"bbox_min",
"lower-left corner of bounding box",
93 bboxMax(table::PointKey<int>::addFields(schema,
"bbox_max",
94 "upper-right corner of bounding box",
"pixel")),
95 frameSet(schema.addField<table::Array<
std::uint8_t>>(
96 "frameSet",
"FrameSet contained in the Transform",
"", 0)) {}
98 PersistenceHelper(table::Schema
const& s)
102 class TransformBoundedFieldFactory :
public table::io::PersistableFactory {
105 : afw::table::io::PersistableFactory(name) {}
108 CatalogVector
const& catalogs)
const override {
111 table::BaseRecord
const& record = catalogs.front().front();
112 PersistenceHelper
const keys(record.getSchema());
114 geom::Box2I bbox(record.get(keys.bboxMin), record.get(keys.bboxMax),
false);
118 return std::make_shared<TransformBoundedField>(bbox, *
transform);
122 std::string getTransformBoundedFieldPersistenceName() {
return "TransformBoundedField"; }
124 TransformBoundedFieldFactory registration(getTransformBoundedFieldPersistenceName());
129 return getTransformBoundedFieldPersistenceName();
135 PersistenceHelper
const keys;
138 record->set(keys.bboxMin,
getBBox().getMin());
139 record->set(keys.bboxMax,
getBBox().getMax());
147 auto newTransform =
Transform(newMapping);
148 return std::make_shared<TransformBoundedField>(
getBBox(), newTransform);
153 if (!rhsCasted)
return false;
155 return getBBox() == rhsCasted->getBBox() &&
159 std::string TransformBoundedField::toString()
const {
161 os <<
"TransformBoundedField (containing " << _transform.getFrameSet()->getNFrame() <<
" frames)";
table::Key< std::string > name
An object passed to Persistable::write to allow it to persist itself.
A custom container class for records, based on std::vector.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
def scale(algorithm, min, max=None, frame=None)
An integer coordinate rectangle.
geom::Box2I getBBox() const
Return the bounding box that defines the region where the field is valid.
A base class for image defects.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
#define LSST_EXCEPT(type,...)
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.
table::Key< int > transform
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.