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 {
86 table::Key<table::Array<std::uint8_t>>
frameSet;
90 bbox(table::
Box2IKey::addFields(schema,
"bbox",
"bounding box",
"pixel")),
91 frameSet(schema.addField<table::Array<
std::uint8_t>>(
92 "frameSet",
"FrameSet contained in the Transform",
"", 0)) {}
94 PersistenceHelper(table::Schema
const& s)
98 class TransformBoundedFieldFactory :
public table::io::PersistableFactory {
101 : afw::table::io::PersistableFactory(name) {}
104 CatalogVector
const& catalogs)
const override {
107 table::BaseRecord
const& record = catalogs.front().front();
108 PersistenceHelper
const keys(record.getSchema());
109 auto bbox = record.get(keys.bbox);
113 return std::make_shared<TransformBoundedField>(
bbox, *
transform);
117 std::string getTransformBoundedFieldPersistenceName() {
return "TransformBoundedField"; }
119 TransformBoundedFieldFactory registration(getTransformBoundedFieldPersistenceName());
124 return getTransformBoundedFieldPersistenceName();
130 PersistenceHelper
const keys;
133 record->set(keys.bbox,
getBBox());
141 auto newTransform =
Transform(newMapping);
142 return std::make_shared<TransformBoundedField>(
getBBox(), newTransform);
147 if (!rhsCasted)
return false;
149 return getBBox() == rhsCasted->getBBox() &&
153 std::string TransformBoundedField::toString()
const {
155 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.
BoxKey< geom::Box2I > Box2IKey
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.