LSST Applications g034a557a3c+dd8dd8f11d,g0afe43252f+b86e4b8053,g11f7dcd041+017865fdd3,g1cd03abf6b+8446defddb,g1ce3e0751c+f991eae79d,g28da252d5a+ca8a1a9fb3,g2bbee38e9b+b6588ad223,g2bc492864f+b6588ad223,g2cdde0e794+8523d0dbb4,g347aa1857d+b6588ad223,g35bb328faa+b86e4b8053,g3a166c0a6a+b6588ad223,g461a3dce89+b86e4b8053,g52b1c1532d+b86e4b8053,g7f3b0d46df+ad13c1b82d,g80478fca09+f29c5d6c70,g858d7b2824+293f439f82,g8cd86fa7b1+af721d2595,g965a9036f2+293f439f82,g979bb04a14+51ed57f74c,g9ddcbc5298+f24b38b85a,gae0086650b+b86e4b8053,gbb886bcc26+b97e247655,gc28159a63d+b6588ad223,gc30aee3386+a2f0f6cab9,gcaf7e4fdec+293f439f82,gcd45df26be+293f439f82,gcdd4ae20e8+70b5def7e6,gce08ada175+da9c58a417,gcf0d15dbbd+70b5def7e6,gdaeeff99f8+006e14e809,gdbce86181e+6a170ce272,ge3d4d395c2+224150c836,ge5f7162a3a+bb2241c923,ge6cb8fbbf7+d119aed356,ge79ae78c31+b6588ad223,gf048a9a2f4+40ffced2b8,gf0baf85859+b4cca3d10f,w.2024.30
LSST Data Management Base Package
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions
lsst::afw::detection Namespace Reference

Namespaces

namespace  _footprintContinued
 
namespace  _footprintMerge
 
namespace  _heavyFootprintContinued
 
namespace  _peak
 
namespace  detail
 
namespace  multiband
 
namespace  utils
 

Classes

class  Footprint
 Class to describe the properties of a detected object from an image. More...
 
class  FootprintControl
 A Control Object for Footprints, controlling e.g. More...
 
class  FootprintFactory
 
class  FootprintMerge
 
class  FootprintMergeList
 List of Merged Footprints. More...
 
class  FootprintSet
 A set of Footprints, associated with a MaskedImage. More...
 
class  GaussianPsf
 A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purposes. More...
 
class  HeavyFootprint
 A set of pixels in an Image, including those pixels' actual values. More...
 
class  HeavyFootprintCtrl
 A control object for HeavyFootprints. More...
 
class  IdSpan
 run-length code for part of object More...
 
struct  IdSpanCompar
 comparison functor; sort by ID, then by row (y), then by column range start (x0) More...
 
class  InvalidPsfError
 An exception thrown when we have an invalid PSF. More...
 
class  PeakRecord
 Record class that represents a peak in a Footprint. More...
 
class  PeakTable
 Table class for Peaks in Footprints. More...
 
class  Psf
 A polymorphic base class for representing an image's Point Spread Function. More...
 
class  PsfTrampoline
 "Trampoline" for Psf to let it be used as a base class in Python. More...
 
class  Threshold
 A Threshold is used to pass a threshold value to detection algorithms. More...
 

Typedefs

using FootprintIdPixel = std::uint64_t
 Pixel type for FootprintSet::insertIntoImage()
 
using PeakColumnView = afw::table::ColumnViewT<PeakRecord>
 
using PeakCatalog = afw::table::CatalogT<PeakRecord>
 
using ConstPeakCatalog = afw::table::CatalogT<const PeakRecord>
 

Functions

std::ostreamoperator<< (std::ostream &os, Footprint const &rhs)
 Print a Footprint to the stream.
 
std::shared_ptr< FootprintmergeFootprints (Footprint const &footprint1, Footprint const &footprint2)
 Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint.
 
std::vector< lsst::geom::Box2IfootprintToBBoxList (Footprint const &footprint)
 Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor less.
 
std::ostreamoperator<< (std::ostream &os, FootprintSet const &rhs)
 Print a FootprintSet to the stream.
 
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > makeHeavyFootprint (Footprint const &foot, lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const &img, HeavyFootprintCtrl const *ctrl=nullptr)
 Create a HeavyFootprint with footprint defined by the given Footprint and pixel values from the given MaskedImage.
 
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
std::shared_ptr< HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > > mergeHeavyFootprints (HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const &h1, HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const &h2)
 Sum the two given HeavyFootprints h1 and h2, returning a HeavyFootprint with the union footprint, and summed pixels where they overlap.
 
std::ostreamoperator<< (std::ostream &os, PeakRecord const &record)
 
Threshold createThreshold (const double value, const std::string type="value", const bool polarity=true)
 Factory method for creating Threshold objects.
 
void wrapFootprint (WrapperCollection &)
 
void wrapFootprintCtrl (WrapperCollection &)
 
void wrapFootprintMerge (WrapperCollection &)
 
void wrapFootprintSet (WrapperCollection &)
 
void wrapGaussianPsf (WrapperCollection &)
 
void wrapHeavyFootprint (WrapperCollection &)
 
void wrapPeak (WrapperCollection &)
 
void wrapPsf (WrapperCollection &)
 
void wrapThreshold (WrapperCollection &)
 
 PYBIND11_MODULE (_detection, mod)
 
void wrapFootprintCtrl (utils::python::WrapperCollection &wrappers)
 
void wrapFootprintMerge (utils::python::WrapperCollection &wrappers)
 
void wrapFootprintSet (utils::python::WrapperCollection &wrappers)
 
void wrapGaussianPsf (utils::python::WrapperCollection &wrappers)
 
void wrapPeak (utils::python::WrapperCollection &wrappers)
 
void wrapPsf (utils::python::WrapperCollection &wrappers)
 
void wrapThreshold (utils::python::WrapperCollection &wrappers)
 
int resolve_alias (const std::vector< int > &aliases, int id)
 Follow a chain of aliases, returning the final resolved value.
 

Typedef Documentation

◆ ConstPeakCatalog

Definition at line 245 of file Peak.h.

◆ FootprintIdPixel

Pixel type for FootprintSet::insertIntoImage()

This is independent of the template parameters for FootprintSet, and including it within FootprintSet makes it difficult for SWIG to interpret the type.

Definition at line 50 of file FootprintSet.h.

◆ PeakCatalog

Definition at line 244 of file Peak.h.

◆ PeakColumnView

Definition at line 243 of file Peak.h.

Function Documentation

◆ createThreshold()

Threshold lsst::afw::detection::createThreshold ( const double value,
const std::string type = "value",
const bool polarity = true )

Factory method for creating Threshold objects.

Parameters
valuevalue of threshold
typestring representation of a ThresholdType. This parameter is optional. Allowed values are: "variance", "value", "stdev", "pixel_stdev"
polarityIf true detect positive objects, false for negative
Returns
desired Threshold

Definition at line 109 of file Threshold.cc.

109 {
110 return Threshold(value, Threshold::parseTypeString(typeStr), polarity);
111}
A Threshold is used to pass a threshold value to detection algorithms.
Definition Threshold.h:43

◆ footprintToBBoxList()

std::vector< lsst::geom::Box2I > lsst::afw::detection::footprintToBBoxList ( Footprint const & footprint)

Return a list of BBoxs, whose union contains exactly the pixels in the footprint, neither more nor less.

Useful in generating sets of meas::algorithms::Defects for the ISR

Parameters
footprintFootprint to turn into bounding box list

Definition at line 366 of file Footprint.cc.

366 {
367 using PixelT = std::uint16_t;
368 lsst::geom::Box2I fpBBox = footprint.getBBox();
370 *idImage = 0;
371 int const height = fpBBox.getHeight();
372 lsst::geom::Extent2I shift(fpBBox.getMinX(), fpBBox.getMinY());
373 footprint.getSpans()->setImage(*idImage, static_cast<PixelT>(1), fpBBox, true);
374
376 /*
377 * Our strategy is to find a row of pixels in the Footprint and interpret it as the first
378 * row of a rectangular set of pixels. We then extend this rectangle upwards as far as it
379 * will go, and define that as a BBox. We clear all those pixels, and repeat until there
380 * are none left. I.e. a Footprint will get cut up like this:
381 *
382 * .555...
383 * 22.3314
384 * 22.331.
385 * .000.1.
386 * (as shown in Footprint_1.py)
387 */
388
389 int y0 = 0; // the first row with non-zero pixels in it
390 while (y0 < height) {
391 lsst::geom::Box2I bbox; // our next BBox
392 for (int y = y0; y < height; ++y) {
393 // Look for a set pixel in this row
394 image::Image<PixelT>::x_iterator begin = idImage->row_begin(y), end = idImage->row_end(y);
396
397 if (first != end) { // A pixel is set in this row
398 image::Image<PixelT>::x_iterator last = std::find(first, end, 0) - 1;
399 int const x0 = first - begin;
400 int const x1 = last - begin;
401 int const x_size = 1 + x1 - x0;
402
403 std::fill(first, last + 1, 0); // clear pixels; we don't want to see them again
404
405 bbox.include(lsst::geom::Point2I(x0, y)); // the LLC
406 bbox.include(lsst::geom::Point2I(x1, y)); // the LRC; initial guess for URC
407
408 // we found at least one pixel so extend the BBox upwards
409 for (++y; y < height; ++y) {
410 if (std::find(idImage->at(x0, y), idImage->at(x0, y) + x_size, 0) !=
411 idImage->at(x0, y) + x_size) {
412 break; // some pixels weren't set, so the BBox stops here, (actually in previous row)
413 }
414 std::fill(idImage->at(x0, y), idImage->at(x0, y) + x_size, 0);
415
416 bbox.include(lsst::geom::Point2I(x1, y)); // the new URC
417 }
418
419 bbox.shift(shift);
420 bboxes.push_back(bbox);
421 } else {
422 y0 = y + 1;
423 }
424 break;
425 }
426 }
427
428 return bboxes;
429}
AmpInfoBoxKey bbox
Definition Amplifier.cc:117
int end
int y
Definition SpanSet.cc:48
A class to represent a 2-dimensional array of pixels.
Definition Image.h:51
An integer coordinate rectangle.
Definition Box.h:55
int getMinY() const noexcept
Definition Box.h:158
int getHeight() const noexcept
Definition Box.h:188
int getMinX() const noexcept
Definition Box.h:157
T fill(T... args)
T find(T... args)
T push_back(T... args)

◆ makeHeavyFootprint()

template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > lsst::afw::detection::makeHeavyFootprint ( Footprint const & foot,
lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > const & img,
HeavyFootprintCtrl const * ctrl = nullptr )

Create a HeavyFootprint with footprint defined by the given Footprint and pixel values from the given MaskedImage.

Definition at line 148 of file HeavyFootprint.h.

151 {
153}
A set of pixels in an Image, including those pixels' actual values.

◆ mergeFootprints()

std::shared_ptr< Footprint > lsst::afw::detection::mergeFootprints ( Footprint const & footprint1,
Footprint const & footprint2 )

Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint.

Region is not preserved, and is set to an empty lsst::geom::Box2I object.

Definition at line 341 of file Footprint.cc.

341 {
342 // Bail out early if the schemas are not the same
343 if (footprint1.getPeaks().getSchema() != footprint2.getPeaks().getSchema()) {
345 "Cannot merge Footprints with different Schemas");
346 }
347
348 // Merge the SpanSets
349 auto unionedSpanSet = footprint1.getSpans()->union_(*(footprint2.getSpans()));
350
351 // Construct merged Footprint
352 auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.getPeaks().getSchema());
353 // Copy over the peaks from both footprints
354 mergedFootprint->setPeakCatalog(PeakCatalog(footprint1.getPeaks().getTable()));
355 PeakCatalog& peaks = mergedFootprint->getPeaks();
356 peaks.reserve(footprint1.getPeaks().size() + footprint2.getPeaks().size());
357 peaks.insert(peaks.end(), footprint1.getPeaks().begin(), footprint1.getPeaks().end(), true);
358 peaks.insert(peaks.end(), footprint2.getPeaks().begin(), footprint2.getPeaks().end(), true);
359
360 // Sort the PeaksCatalog according to value
361 mergedFootprint->sortPeaks();
362
363 return mergedFootprint;
364}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
Reports invalid arguments.
Definition Runtime.h:66

◆ mergeHeavyFootprints()

template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
std::shared_ptr< HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > > lsst::afw::detection::mergeHeavyFootprints ( HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const & h1,
HeavyFootprint< ImagePixelT, MaskPixelT, VariancePixelT > const & h2 )

Sum the two given HeavyFootprints h1 and h2, returning a HeavyFootprint with the union footprint, and summed pixels where they overlap.

The peak list is the union of the two inputs.

Definition at line 128 of file HeavyFootprint.cc.

130 {
131 // Merge the Footprints (by merging the Spans)
133
134 // Find the union bounding-box
136 bbox.include(h2.getBBox());
137
138 // Create union-bb-sized images and insert the heavies
141 h1.insert(im1);
142 h2.insert(im2);
143 // Add the pixels
144 im1 += im2;
145
146 // Build new HeavyFootprint from the merged spans and summed pixels.
147 return std::make_shared<HeavyFootprint<ImagePixelT, MaskPixelT, VariancePixelT>>(*foot, im1);
148}
lsst::geom::Box2I getBBox() const
Return the Footprint's bounding box.
Definition Footprint.h:208
void insert(lsst::afw::image::MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage) const
Replace all the pixels in the image with the values in the HeavyFootprint.
A class to manipulate images, masks, and variance as a single object.
Definition MaskedImage.h:74
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.
Definition Footprint.cc:341

◆ operator<<() [1/3]

std::ostream & lsst::afw::detection::operator<< ( std::ostream & os,
Footprint const & rhs )

Print a Footprint to the stream.

Parameters
osStream to print to.
rhsFootprint to print.

Definition at line 443 of file Footprint.cc.

443 {
444 os << rhs.getPeaks().size() << " peaks, area=" << rhs.getArea() << ", centroid=" << rhs.getCentroid();
445 return os;
446}
std::ostream * os
Definition Schema.cc:557

◆ operator<<() [2/3]

std::ostream & lsst::afw::detection::operator<< ( std::ostream & os,
FootprintSet const & rhs )

Print a FootprintSet to the stream.

Parameters
osStream to print to.
rhsFootprintSet to print.

◆ operator<<() [3/3]

std::ostream & lsst::afw::detection::operator<< ( std::ostream & os,
PeakRecord const & record )

Definition at line 91 of file Peak.cc.

91 {
92 return os << (boost::format("%d: (%d,%d) (%.3f,%.3f)") % record.getId() % record.getIx() %
93 record.getIy() % record.getFx() % record.getFy());
94}

◆ PYBIND11_MODULE()

lsst::afw::detection::PYBIND11_MODULE ( _detection ,
mod  )

Definition at line 47 of file _detection.cc.

47 {
48 WrapperCollection wrappers(mod, "lsst.afw.detection");
49 wrapPsf(wrappers);
50 wrapFootprintCtrl(wrappers);
51 wrapFootprint(wrappers);
52 wrapThreshold(wrappers);
53 wrapFootprintSet(wrappers);
54 wrapFootprintMerge(wrappers);
55 wrapPeak(wrappers);
56 wrapGaussianPsf(wrappers);
57 wrapHeavyFootprint(wrappers);
58 wrappers.finish();
59}
void wrapPsf(WrapperCollection &)
void wrapThreshold(WrapperCollection &)
void wrapFootprintCtrl(WrapperCollection &)
void wrapFootprint(WrapperCollection &)
Definition _footprint.cc:77
void wrapGaussianPsf(WrapperCollection &)
void wrapFootprintSet(WrapperCollection &)
void wrapHeavyFootprint(WrapperCollection &)
void wrapPeak(WrapperCollection &)
void wrapFootprintMerge(WrapperCollection &)

◆ resolve_alias()

int lsst::afw::detection::resolve_alias ( const std::vector< int > & aliases,
int id )

Follow a chain of aliases, returning the final resolved value.

Definition at line 96 of file CR.cc.

97 { /* alias to look up */
98 int resolved = id; /* resolved alias */
99
100 while (id != aliases[id]) {
101 resolved = id = aliases[id];
102 }
103
104 return (resolved);
105}
int id
Definition CR.cc:143

◆ wrapFootprint()

void lsst::afw::detection::wrapFootprint ( WrapperCollection & wrappers)

Definition at line 77 of file _footprint.cc.

77 {
78 wrappers.addInheritanceDependency("lsst.afw.table.io");
79 wrappers.addSignatureDependency("lsst.afw.geom");
80 wrappers.addSignatureDependency("lsst.afw.table");
81
82 wrappers.wrapType(
83 py::class_<Footprint, std::shared_ptr<Footprint>>(wrappers.module, "Footprint"),
84 [](auto &mod, auto &cls) {
85 cls.def(py::init<std::shared_ptr<geom::SpanSet>, lsst::geom::Box2I const &>(), "inputSpans"_a,
86 "region"_a = lsst::geom::Box2I());
87
88 cls.def(py::init<std::shared_ptr<geom::SpanSet>, afw::table::Schema const &,
89 lsst::geom::Box2I const &>(),
90 "inputSpans"_a, "peakSchema"_a, "region"_a = lsst::geom::Box2I());
91 cls.def(py::init<Footprint const &>());
92 cls.def(py::init<>());
93
94 table::io::python::addPersistableMethods<Footprint>(cls);
95
96 cls.def("getSpans", &Footprint::getSpans);
97 cls.def("setSpans", &Footprint::setSpans);
98 cls.def("getPeaks", (PeakCatalog & (Footprint::*)()) & Footprint::getPeaks,
99 py::return_value_policy::reference_internal);
100 cls.def("addPeak", &Footprint::addPeak);
101 cls.def("sortPeaks", &Footprint::sortPeaks, "key"_a = afw::table::Key<float>());
102 cls.def("setPeakSchema", &Footprint::setPeakSchema);
103 cls.def("setPeakCatalog", &Footprint::setPeakCatalog, "otherPeaks"_a);
104 cls.def("getArea", &Footprint::getArea);
105 cls.def("getCentroid", &Footprint::getCentroid);
106 cls.def("getShape", &Footprint::getShape);
107 cls.def("shift", (void (Footprint::*)(int, int)) & Footprint::shift);
108 cls.def("shift", (void (Footprint::*)(lsst::geom::ExtentI const &)) & Footprint::shift);
109 cls.def("getBBox", &Footprint::getBBox);
110 cls.def("getRegion", &Footprint::getRegion);
111 cls.def("setRegion", &Footprint::setRegion);
112 cls.def("clipTo", &Footprint::clipTo);
113 cls.def("contains", &Footprint::contains);
114 cls.def("transform",
115 (std::shared_ptr<Footprint>(Footprint::*)(std::shared_ptr<geom::SkyWcs>,
116 std::shared_ptr<geom::SkyWcs>,
117 lsst::geom::Box2I const &, bool) const) &
118 Footprint::transform,
119 "source"_a, "target"_a, "region"_a, "doClip"_a = true);
120 cls.def("transform",
121 (std::shared_ptr<Footprint>(Footprint::*)(lsst::geom::LinearTransform const &,
122 lsst::geom::Box2I const &, bool) const) &
123 Footprint::transform);
124 cls.def("transform",
125 (std::shared_ptr<Footprint>(Footprint::*)(lsst::geom::AffineTransform const &,
126 lsst::geom::Box2I const &, bool) const) &
127 Footprint::transform);
128 cls.def("transform",
129 (std::shared_ptr<Footprint>(Footprint::*)(geom::TransformPoint2ToPoint2 const &,
130 lsst::geom::Box2I const &, bool) const) &
131 Footprint::transform);
132 cls.def("dilate", (void (Footprint::*)(int, geom::Stencil)) & Footprint::dilate, "r"_a,
133 "stencil"_a = geom::Stencil::CIRCLE);
134 cls.def("dilate", (void (Footprint::*)(geom::SpanSet const &)) & Footprint::dilate);
135 cls.def("erode", (void (Footprint::*)(int, geom::Stencil)) & Footprint::erode, "r"_a,
136 "stencil"_a = geom::Stencil::CIRCLE);
137 cls.def("erode", (void (Footprint::*)(geom::SpanSet const &)) & Footprint::erode);
138 cls.def("removeOrphanPeaks", &Footprint::removeOrphanPeaks);
139 cls.def("updatePeakSignificance",
140 py::overload_cast<double>(&Footprint::updatePeakSignificance));
141 cls.def("updatePeakSignificance", py::overload_cast<image::Image<float> const &, int>(
142 &Footprint::updatePeakSignificance));
143 cls.def("isContiguous", &Footprint::isContiguous);
144 cls.def("isHeavy", &Footprint::isHeavy);
145 cls.def("assign", (Footprint & (Footprint::*)(Footprint const &)) & Footprint::operator=);
146
147 cls.def("split", [](Footprint const &self) -> py::list {
148 /* This is a work around for pybind not properly
149 * handling converting a vector of unique pointers
150 * to python lists of shared pointers */
151 py::list l;
152 for (auto &ptr : self.split()) {
153 l.append(py::cast(std::shared_ptr<Footprint>(std::move(ptr))));
154 }
155 return l;
156 });
157
158 cls.def_property("spans", &Footprint::getSpans, &Footprint::setSpans);
159 cls.def_property_readonly("peaks", (PeakCatalog & (Footprint::*)()) & Footprint::getPeaks,
160 py::return_value_policy::reference_internal);
161
162 cls.def("__contains__", [](Footprint const &self, lsst::geom::Point2I const &point) -> bool {
163 return self.contains(point);
164 });
165 cls.def(
166 "__eq__",
167 [](Footprint const &self, Footprint const &other) -> bool { return self == other; },
168 py::is_operator());
169 utils::python::addOutputOp(cls, "__repr__");
170 });
171
172 declareMaskFromFootprintList<lsst::afw::image::MaskPixel>(wrappers);
173
174 wrappers.wrap([](auto &mod) {
175 mod.def("mergeFootprints", &mergeFootprints);
176 mod.def("footprintToBBoxList", &footprintToBBoxList);
177 });
178}
Class to describe the properties of a detected object from an image.
Definition Footprint.h:63

◆ wrapFootprintCtrl() [1/2]

void lsst::afw::detection::wrapFootprintCtrl ( utils::python::WrapperCollection & wrappers)

Definition at line 39 of file _footprintCtrl.cc.

39 {
40 wrappers.wrapType(py::class_<FootprintControl>(wrappers.module, "FootprintControl"),
41 [](auto& mod, auto& cls) {
42 cls.def(py::init<>());
43 cls.def(py::init<bool, bool>(), "circular"_a, "isotropic"_a = false);
44 cls.def(py::init<bool, bool, bool, bool>(), "left"_a, "right"_a, "up"_a, "down"_a);
45
46 cls.def("growCircular", &FootprintControl::growCircular);
47 cls.def("growIsotropic", &FootprintControl::growIsotropic);
48 cls.def("growLeft", &FootprintControl::growLeft);
49 cls.def("growRight", &FootprintControl::growRight);
50 cls.def("growUp", &FootprintControl::growUp);
51 cls.def("growDown", &FootprintControl::growDown);
52
53 cls.def("isCircular", &FootprintControl::isCircular);
54 cls.def("isIsotropic", &FootprintControl::isIsotropic);
55 cls.def("isLeft", &FootprintControl::isLeft);
56 cls.def("isRight", &FootprintControl::isRight);
57 cls.def("isUp", &FootprintControl::isUp);
58 cls.def("isDown", &FootprintControl::isDown);
59 });
60
61 auto clsHeavyFootprintCtrl = wrappers.wrapType(
62 py::class_<HeavyFootprintCtrl>(wrappers.module, "HeavyFootprintCtrl"), [](auto& mod, auto& cls) {
63 cls.def(py::init<HeavyFootprintCtrl::ModifySource>(),
64 "modifySource"_a = HeavyFootprintCtrl::ModifySource::NONE);
65
66 cls.def("getModifySource", &HeavyFootprintCtrl::getModifySource);
67 cls.def("setModifySource", &HeavyFootprintCtrl::setModifySource);
68 cls.def("getImageVal", &HeavyFootprintCtrl::getImageVal);
69 cls.def("setImageVal", &HeavyFootprintCtrl::setImageVal);
70 cls.def("getMaskVal", &HeavyFootprintCtrl::getMaskVal);
71 cls.def("setMaskVal", &HeavyFootprintCtrl::setMaskVal);
72 cls.def("getVarianceVal", &HeavyFootprintCtrl::getVarianceVal);
73 cls.def("setVarianceVal", &HeavyFootprintCtrl::setVarianceVal);
74 });
75
76 wrappers.wrapType(py::enum_<HeavyFootprintCtrl::ModifySource>(clsHeavyFootprintCtrl, "ModifySource"),
77 [](auto& mod, auto& enm) {
78 enm.value("NONE", HeavyFootprintCtrl::ModifySource::NONE);
79 enm.value("SET", HeavyFootprintCtrl::ModifySource::SET);
80 enm.export_values();
81 });
82}

◆ wrapFootprintCtrl() [2/2]

void lsst::afw::detection::wrapFootprintCtrl ( WrapperCollection & )

◆ wrapFootprintMerge() [1/2]

void lsst::afw::detection::wrapFootprintMerge ( utils::python::WrapperCollection & wrappers)

Definition at line 38 of file _footprintMerge.cc.

38 {
39 wrappers.addSignatureDependency("lsst.afw.table");
40
41 wrappers.wrapType(
42 py::class_<FootprintMergeList>(wrappers.module, "FootprintMergeList"), [](auto &mod, auto &cls) {
43 cls.def(py::init<afw::table::Schema &, std::vector<std::string> const &,
44 afw::table::Schema const &>(),
45 "sourceSchema"_a, "filterList"_a, "initialPeakSchema"_a);
46 cls.def(py::init<afw::table::Schema &, std::vector<std::string> const &>(), "sourceSchema"_a,
47 "filterList"_a);
48
49 cls.def("getPeakSchema", &FootprintMergeList::getPeakSchema);
50 cls.def("addCatalog", &FootprintMergeList::addCatalog, "sourceTable"_a, "inputCat"_a,
51 "filter"_a, "minNewPeakDist"_a = -1., "doMerge"_a = true, "maxSamePeakDist"_a = -1.);
52 cls.def("clearCatalog", &FootprintMergeList::clearCatalog);
53 cls.def("getFinalSources", &FootprintMergeList::getFinalSources, "outputCat"_a);
54 });
55}

◆ wrapFootprintMerge() [2/2]

void lsst::afw::detection::wrapFootprintMerge ( WrapperCollection & )

◆ wrapFootprintSet() [1/2]

void lsst::afw::detection::wrapFootprintSet ( utils::python::WrapperCollection & wrappers)

Definition at line 86 of file _footprintSet.cc.

86 {
87 wrappers.addSignatureDependency("lsst.afw.image");
88 wrappers.addSignatureDependency("lsst.afw.table");
89
90 wrappers.wrapType(
91 py::class_<FootprintSet, std::shared_ptr<FootprintSet>>(wrappers.module, "FootprintSet"),
92 [](auto &mod, auto &cls) {
93 declareTemplatedMembers<std::uint16_t>(cls);
94 declareTemplatedMembers<int>(cls);
95 declareTemplatedMembers<float>(cls);
96 declareTemplatedMembers<double>(cls);
97
98 cls.def(py::init<image::Mask<image::MaskPixel> const &, Threshold const &, int const>(),
99 "img"_a, "threshold"_a, "npixMin"_a = 1);
100
101 cls.def(py::init<lsst::geom::Box2I>(), "region"_a);
102 cls.def(py::init<FootprintSet const &>(), "set"_a);
103 cls.def(py::init<FootprintSet const &, int, FootprintControl const &>(), "set"_a, "rGrow"_a,
104 "ctrl"_a);
105 cls.def(py::init<FootprintSet const &, int, bool>(), "set"_a, "rGrow"_a, "isotropic"_a);
106 cls.def(py::init<FootprintSet const &, FootprintSet const &, bool>(), "footprints1"_a,
107 "footprints2"_a, "includePeaks"_a);
108
109 cls.def("swap", &FootprintSet::swap);
110 // setFootprints takes shared_ptr<FootprintList> and getFootprints returns it,
111 // but pybind11 can't handle that type, so use a custom getter and setter
112 cls.def("setFootprints", [](FootprintSet &self, FootprintSet::FootprintList footList) {
113 self.setFootprints(std::make_shared<FootprintSet::FootprintList>(std::move(footList)));
114 });
115 cls.def("getFootprints", [](FootprintSet &self) { return *(self.getFootprints()); });
116 cls.def("makeSources", &FootprintSet::makeSources);
117 cls.def("setRegion", &FootprintSet::setRegion);
118 cls.def("getRegion", &FootprintSet::getRegion);
119 cls.def("insertIntoImage", &FootprintSet::insertIntoImage);
120 cls.def("setMask", (void (FootprintSet::*)(image::Mask<lsst::afw::image::MaskPixel> *,
121 std::string const &)) &
122 FootprintSet::setMask<lsst::afw::image::MaskPixel>);
123 cls.def("setMask",
124 (void (FootprintSet::*)(std::shared_ptr<image::Mask<lsst::afw::image::MaskPixel>>,
125 std::string const &)) &
126 FootprintSet::setMask<lsst::afw::image::MaskPixel>);
127 cls.def("merge", &FootprintSet::merge, "rhs"_a, "tGrow"_a = 0, "rGrow"_a = 0,
128 "isotropic"_a = true);
129 utils::python::addOutputOp(cls, "__repr__");
130 });
131}
A set of Footprints, associated with a MaskedImage.
STL namespace.
g2d::python::Image< bool > Mask
Definition test_image.cc:16

◆ wrapFootprintSet() [2/2]

void lsst::afw::detection::wrapFootprintSet ( WrapperCollection & )

◆ wrapGaussianPsf() [1/2]

void lsst::afw::detection::wrapGaussianPsf ( utils::python::WrapperCollection & wrappers)

Definition at line 38 of file _gaussianPsf.cc.

38 {
39 wrappers.wrapType(
40 py::class_<GaussianPsf, std::shared_ptr<GaussianPsf>, Psf>(wrappers.module, "GaussianPsf"),
41 [](auto& mod, auto& cls) {
42 table::io::python::addPersistableMethods<GaussianPsf>(cls);
43
44 cls.def(py::init<int, int, double>(), "width"_a, "height"_a, "sigma"_a);
45 cls.def(py::init<lsst::geom::Extent2I const&, double>(), "dimensions"_a, "sigma"_a);
46
47 cls.def("clone", &GaussianPsf::clone);
48 cls.def("resized", &GaussianPsf::resized, "width"_a, "height"_a);
49 cls.def("getDimensions", &GaussianPsf::getDimensions);
50 cls.def("getSigma", &GaussianPsf::getSigma);
51 cls.def("isPersistable", &GaussianPsf::isPersistable);
52 });
53}
A circularly symmetric Gaussian Psf class with no spatial variation, intended mostly for testing purp...
Definition GaussianPsf.h:42
A polymorphic base class for representing an image's Point Spread Function.
Definition Psf.h:82

◆ wrapGaussianPsf() [2/2]

void lsst::afw::detection::wrapGaussianPsf ( WrapperCollection & )

◆ wrapHeavyFootprint()

void lsst::afw::detection::wrapHeavyFootprint ( WrapperCollection & wrappers)

Definition at line 88 of file _heavyFootprint.cc.

88 {
89 wrappers.addSignatureDependency("lsst.afw.image");
90
91 declareHeavyFootprint<int>(wrappers, "I");
92 declareHeavyFootprint<std::uint16_t>(wrappers, "U");
93 declareHeavyFootprint<float>(wrappers, "F");
94 declareHeavyFootprint<double>(wrappers, "D");
95}

◆ wrapPeak() [1/2]

void lsst::afw::detection::wrapPeak ( utils::python::WrapperCollection & wrappers)

Definition at line 101 of file _peak.cc.

101 {
102 wrappers.addInheritanceDependency("lsst.afw.table");
103
104 auto clsPeakRecord = wrappers.wrapType(PyPeakRecord(wrappers.module, "PeakRecord"),
105 [](auto &mod, auto &cls) { declarePeakRecord(cls); });
106 auto clsPeakTable = wrappers.wrapType(PyPeakTable(wrappers.module, "PeakTable"),
107 [](auto &mod, auto &cls) { declarePeakTable(cls); });
108
109 auto clsPeakColumnView = table::python::declareColumnView<PeakRecord>(wrappers, "Peak");
110 auto clsPeakCatalog = table::python::declareCatalog<PeakRecord>(wrappers, "Peak");
111
112 clsPeakRecord.attr("Table") = clsPeakTable;
113 clsPeakRecord.attr("ColumnView") = clsPeakColumnView;
114 clsPeakRecord.attr("Catalog") = clsPeakCatalog;
115 clsPeakTable.attr("Record") = clsPeakRecord;
116 clsPeakTable.attr("ColumnView") = clsPeakColumnView;
117 clsPeakTable.attr("Catalog") = clsPeakCatalog;
118 clsPeakCatalog.attr("Record") = clsPeakRecord;
119 clsPeakCatalog.attr("Table") = clsPeakTable;
120 clsPeakCatalog.attr("ColumnView") = clsPeakColumnView;
121}

◆ wrapPeak() [2/2]

void lsst::afw::detection::wrapPeak ( WrapperCollection & )

◆ wrapPsf() [1/2]

void lsst::afw::detection::wrapPsf ( utils::python::WrapperCollection & wrappers)

Definition at line 50 of file _psf.cc.

50 {
51 wrappers.addInheritanceDependency("lsst.afw.typehandling");
52 wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
53 wrappers.addSignatureDependency("lsst.afw.image");
54 wrappers.addSignatureDependency("lsst.afw.fits");
55
56 auto cls = wrappers.wrapException<InvalidPsfError, pex::exceptions::InvalidParameterError>("InvalidPsfError",
57 "InvalidParameterError");
58 cls.def(py::init<std::string const &>());
59
60 auto clsPsf = wrappers.wrapType(
61 py::class_<Psf, PySharedPtr<Psf>, typehandling::Storable, PsfTrampoline<>>(
62 wrappers.module, "Psf"
63 ),
64 [](auto& mod, auto& cls) {
65 table::io::python::addPersistableMethods<Psf>(cls);
66 cls.def(py::init<bool, size_t>(), "isFixed"_a=false, "capacity"_a=100); // Constructor for pure-Python subclasses
67 cls.def("clone", &Psf::clone);
68 cls.def("resized", &Psf::resized, "width"_a, "height"_a);
69
70 cls.def("computeImage",
71 &Psf::computeImage,
72 "position"_a,
73 "color"_a = image::Color(),
74 "owner"_a = Psf::ImageOwnerEnum::COPY
75 );
76 cls.def("computeKernelImage",
77 &Psf::computeKernelImage,
78 "position"_a,
79 "color"_a = image::Color(),
80 "owner"_a = Psf::ImageOwnerEnum::COPY
81 );
82 cls.def("computePeak",
83 &Psf::computePeak,
84 "position"_a,
85 "color"_a = image::Color()
86 );
87 cls.def("computeApertureFlux",
88 &Psf::computeApertureFlux,
89 "radius"_a,
90 "position"_a,
91 "color"_a = image::Color()
92 );
93 cls.def("computeShape",
94 &Psf::computeShape,
95 "position"_a,
96 "color"_a = image::Color()
97 );
98 cls.def("computeBBox",
99 &Psf::computeBBox,
100 "position"_a,
101 "color"_a = image::Color()
102 );
103 cls.def("computeImageBBox",
104 &Psf::computeImageBBox,
105 "position"_a,
106 "color"_a = image::Color()
107 );
108 cls.def("computeKernelBBox",
109 &Psf::computeKernelBBox,
110 "position"_a,
111 "color"_a = image::Color()
112 );
113 cls.def("getLocalKernel",
114 &Psf::getLocalKernel,
115 "position"_a,
116 "color"_a = image::Color()
117 );
118
119 cls.def("getAverageColor", &Psf::getAverageColor);
120 cls.def("getAveragePosition", &Psf::getAveragePosition);
121 cls.def_static("recenterKernelImage", &Psf::recenterKernelImage, "im"_a, "position"_a,
122 "warpAlgorithm"_a = "lanczos5", "warpBuffer"_a = 5);
123 cls.def("getCacheCapacity", &Psf::getCacheCapacity);
124 cls.def("setCacheCapacity", &Psf::setCacheCapacity);
125 }
126 );
127
128 wrappers.wrapType(py::enum_<Psf::ImageOwnerEnum>(clsPsf, "ImageOwnerEnum"), [](auto& mod, auto& enm) {
129 enm.value("COPY", Psf::ImageOwnerEnum::COPY);
130 enm.value("INTERNAL", Psf::ImageOwnerEnum::INTERNAL);
131 enm.export_values();
132 });
133}
An exception thrown when we have an invalid PSF.
Definition Psf.h:52
"Trampoline" for Psf to let it be used as a base class in Python.
Definition python.h:50
Describe the colour of a source.
Definition Color.h:25
Interface supporting iteration over heterogenous containers.
Definition Storable.h:58

◆ wrapPsf() [2/2]

void lsst::afw::detection::wrapPsf ( WrapperCollection & )

◆ wrapThreshold() [1/2]

void lsst::afw::detection::wrapThreshold ( utils::python::WrapperCollection & wrappers)

Definition at line 41 of file _threshold.cc.

41 {
42 auto clsThreshold = wrappers.wrapType(
43 py::class_<Threshold, std::shared_ptr<Threshold>>(wrappers.module, "Threshold"),
44 [](auto& mod, auto& cls) {
45 cls.def(py::init<double const, typename Threshold::ThresholdType const, bool const,
46 double const>(),
47 "value"_a, "type"_a = Threshold::VALUE, "polarity"_a = true,
48 "includeMultiplier"_a = 1.0);
49
50 cls.def("getType", &Threshold::getType);
51 cls.def_static("parseTypeString", Threshold::parseTypeString);
52 cls.def_static("getTypeString", Threshold::getTypeString);
53 cls.def("getValue", (double (Threshold::*)(const double) const) & Threshold::getValue,
54 "param"_a = -1);
55 //
56 // template<typename ImageT>
57 // double getValue(ImageT const& image) const;
58 //
59 cls.def("getPolarity", &Threshold::getPolarity);
60 cls.def("setPolarity", &Threshold::setPolarity);
61 cls.def("getIncludeMultiplier", &Threshold::getIncludeMultiplier);
62 cls.def("setIncludeMultiplier", &Threshold::setIncludeMultiplier);
63 // Different str/repr so that the latter can be used to create a Threshold.
64 cls.def("__str__", [](Threshold const& self) {
65 std::ostringstream os;
66 std::string polarity = (self.getPolarity() == true) ? "positive" : "negative";
67 os << py::cast(self.getType()).attr("name").cast<std::string>() << std::setprecision(8)
68 << " value=" << self.getValue(1.0) << " (" << polarity << ")";
69 if (self.getIncludeMultiplier() != 1.0) {
70 os << " multiplier=" << self.getIncludeMultiplier();
71 }
72 return os.str();
73 });
74 cls.def("__repr__", [](Threshold const& self) {
76 os << std::setprecision(16) << "Threshold(value=" << self.getValue(1.0)
77 << ", type=" << py::cast(self.getType()).attr("name").cast<std::string>()
78 << ", polarity=" << self.getPolarity()
79 << ", includeMultiplier=" << self.getIncludeMultiplier() << ")";
80 return os.str();
81 });
82 });
83
84 wrappers.wrapType(py::enum_<Threshold::ThresholdType>(clsThreshold, "ThresholdType"),
85 [](auto& mod, auto& enm) {
86 enm.value("VALUE", Threshold::ThresholdType::VALUE);
87 enm.value("BITMASK", Threshold::ThresholdType::BITMASK);
88 enm.value("STDEV", Threshold::ThresholdType::STDEV);
89 enm.value("VARIANCE", Threshold::ThresholdType::VARIANCE);
90 enm.value("PIXEL_STDEV", Threshold::ThresholdType::PIXEL_STDEV);
91 enm.export_values();
92 });
93
94 wrappers.wrap([](auto& mod) {
95 mod.def("createThreshold", createThreshold, "value"_a, "type"_a = "value", "polarity"_a = true);
96 });
97}
T setprecision(T... args)

◆ wrapThreshold() [2/2]

void lsst::afw::detection::wrapThreshold ( WrapperCollection & )