LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
39 : _spans(inputSpans), _peaks(
PeakTable::makeMinimalSchema()), _region(region) {}
43 : _spans(inputSpans), _peaks(peakSchema), _region(region) {}
53 p->setPeakValue(height);
60 return a.get(validatedKey) >
b.get(validatedKey);
85 return transform(*srcToTarget, region, doClip);
101 auto transformedSpan =
getSpans()->transformedBy(t);
103 auto newFootprint = std::make_shared<Footprint>(transformedSpan,
getPeaks().getSchema(), region);
110 auto newPeakPosList = t.applyForward(peakPosList);
111 auto newPeakPos = newPeakPosList.cbegin();
113 ++
peak, ++newPeakPos) {
114 newFootprint->addPeak(newPeakPos->getX(), newPeakPos->getY(),
peak->getPeakValue());
117 newFootprint->clipTo(region);
146 auto splitSpanSets =
getSpans()->split();
148 footprintList.
reserve(splitSpanSets.size());
149 for (
auto& spanPtr : splitSpanSets) {
150 auto tmpFootprintPointer = std::make_shared<Footprint>(spanPtr,
getPeaks().getSchema(),
getRegion());
151 tmpFootprintPointer->_peaks =
getPeaks();
154 if (splitSpanSets.size() > 1) {
155 tmpFootprintPointer->removeOrphanPeaks();
159 return footprintList;
170 for (
auto const& selfPeak :
getPeaks()) {
172 for (
auto const& otherPeak :
other.getPeaks()) {
173 if (selfPeak.getI() == otherPeak.getI() && selfPeak.getF() == otherPeak.getF() &&
174 selfPeak.getPeakValue() == otherPeak.getPeakValue()) {
189 std::string getFootprintPersistenceName() {
return "Footprint"; }
191 class LegacyFootprintPersistenceHelper {
198 static LegacyFootprintPersistenceHelper
const& get() {
199 static LegacyFootprintPersistenceHelper instance;
204 LegacyFootprintPersistenceHelper(
const LegacyFootprintPersistenceHelper&) =
delete;
205 LegacyFootprintPersistenceHelper& operator=(
const LegacyFootprintPersistenceHelper&) =
delete;
208 LegacyFootprintPersistenceHelper(LegacyFootprintPersistenceHelper&&) =
delete;
209 LegacyFootprintPersistenceHelper& operator=(LegacyFootprintPersistenceHelper&&) =
delete;
212 LegacyFootprintPersistenceHelper()
215 spanX0(
spanSchema.addField<int>(
"x0",
"First column of span (inclusive)",
"pixel")),
216 spanX1(
spanSchema.addField<int>(
"x1",
"Second column of span (inclusive)",
"pixel")) {}
220 static afw::table::Schema spanSetIdSchema;
221 static int initialize =
true;
222 static table::Key<int> idKey;
224 idKey = spanSetIdSchema.addField<
int>(
"id",
"id of the SpanSet catalog");
243 return loadedFootprint;
252 FootprintFactory registration(getFootprintPersistenceName());
259 auto const keys = spanSetPersistenceHelper();
263 auto record = spanSetCat.
addNew();
277 if (fieldCount == 1) {
279 auto const schemaAndKey = spanSetPersistenceHelper();
280 int persistedSpanSetId = catalog.
front().
get(schemaAndKey.second);
281 loadedSpanSet = std::dynamic_pointer_cast<geom::SpanSet>(archive.
get(persistedSpanSetId));
284 auto const&
keys = LegacyFootprintPersistenceHelper::get();
287 for (
auto const&
val : catalog) {
290 loadedSpanSet = std::make_shared<geom::SpanSet>(
std::move(tempVec));
293 return loadedFootprint;
297 using namespace std::string_literals;
305 mapper.addMapping(oldX,
"f.x"s);
306 mapper.addMapping(oldY,
"f.y"s);
307 mapper.addMapping(oldPeakValue,
"peakValue"s);
309 auto peaks = loadedFootprint.
getPeaks();
311 for (
auto const&
peak : peakCat) {
312 auto newPeak = peaks.addNew();
314 newPeak->setIx(
static_cast<int>(newPeak->getFx()));
315 newPeak->setIy(
static_cast<int>(newPeak->getFy()));
320 auto& peaks = loadedFootprint.
getPeaks();
322 for (
auto const&
peak : peakCat) {
323 peaks.addNew()->assign(
peak);
331 "Cannot merge Footprints with different Schemas");
335 auto unionedSpanSet = footprint1.
getSpans()->union_(*(footprint2.
getSpans()));
338 auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.
getPeaks().
getSchema());
347 mergedFootprint->sortPeaks();
349 return mergedFootprint;
359 footprint.
getSpans()->setImage(*idImage,
static_cast<PixelT>(1), fpBBox,
true);
376 while (y0 < height) {
378 for (
int y = y0;
y != height; ++
y) {
385 int const x0 =
first - begin;
386 int const x1 = last - begin;
394 for (++
y;
y != height; ++
y) {
395 if (
std::find(idImage->at(x0,
y), idImage->at(x1 + 1,
y), 0) != idImage->at(x1 + 1,
y)) {
398 std::fill(idImage->at(x0,
y), idImage->at(x1 + 1,
y), 0);
Record class that represents a peak in a Footprint.
Field< T >::Value get(Key< T > const &key) const
Return the value of a field for the given key.
int getHeight() const noexcept
iterator erase(iterator pos)
Erase the record pointed to by pos, and return an iterator the next record.
An object passed to Persistable::write to allow it to persist itself.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
Defines the fields and offsets for a table.
static afw::table::Schema makeMinimalSchema()
Return a minimal schema for Peak tables and records.
PersistableFactory(std::string const &name)
Constructor for the factory.
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
size_type size() const
Return the number of elements in the catalog.
const char * source()
Source function that allows astChannel to source from a Stream.
std::vector< lsst::geom::Box2I > footprintToBBoxList(Footprint const &footprint)
Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor le...
lsst::afw::detection::Footprint Footprint
ItemVariant const * other
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Reports errors in the logical structure of the program.
A mapping between the keys of two Schemas, used to copy data between them.
A vector of catalogs used by Persistable.
Schema getSchema() const
Return the schema associated with the catalog's table.
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
afw::table::CatalogT< PeakRecord > PeakCatalog
A base class for factory classes used to reconstruct objects from records.
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
_view_t::x_iterator x_iterator
An iterator for traversing the pixels in a row.
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Key< Flag > const & target
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
T emplace_back(T... args)
int getFieldCount() const
The total number of fields.
Reports invalid arguments.
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
reference front() const
Return the first record.
std::shared_ptr< Footprint > mergeFootprints(Footprint const &footprint1, Footprint const &footprint2)
Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint.
An integer coordinate rectangle.
int getMinX() const noexcept
Table class for Peaks in Footprints.
int put(Persistable const *obj, bool permissive=false)
Save an object to the archive and return a unique ID that can be used to retrieve it from an InputArc...
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
A class to represent a 2-dimensional array of pixels.
iterator begin()
Iterator access.
static afw::table::Key< float > getPeakValueKey()
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
Stencil
An enumeration class which describes the shapes.
int getMinY() const noexcept