LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Namespaces | Classes | Typedefs | Functions
lsst::afw::detection Namespace Reference

Namespaces

 _footprintMerge
 
 _peak
 
 detail
 
 multiband
 
 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  HeavyFootprintCtrl
 A control object for HeavyFootprints. More...
 
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  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...
 
class  FootprintFactory
 
class  FootprintMerge
 
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...
 

Typedefs

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

Functions

std::shared_ptr< FootprintmergeFootprints (Footprint const &footprint1, Footprint const &footprint2)
 Merges two Footprints – appends their peaks, and unions their spans, returning a new Footprint. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

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 48 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 }

◆ 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 352 of file Footprint.cc.

352  {
353  using PixelT = std::uint16_t;
354  lsst::geom::Box2I fpBBox = footprint.getBBox();
356  *idImage = 0;
357  int const height = fpBBox.getHeight();
358  lsst::geom::Extent2I shift(fpBBox.getMinX(), fpBBox.getMinY());
359  footprint.getSpans()->setImage(*idImage, static_cast<PixelT>(1), fpBBox, true);
360 
362  /*
363  * Our strategy is to find a row of pixels in the Footprint and interpret it as the first
364  * row of a rectangular set of pixels. We then extend this rectangle upwards as far as it
365  * will go, and define that as a BBox. We clear all those pixels, and repeat until there
366  * are none left. I.e. a Footprint will get cut up like this:
367  *
368  * .555...
369  * 22.3314
370  * 22.331.
371  * .000.1.
372  * (as shown in Footprint_1.py)
373  */
374 
375  int y0 = 0; // the first row with non-zero pixels in it
376  while (y0 < height) {
377  lsst::geom::Box2I bbox; // our next BBox
378  for (int y = y0; y < height; ++y) {
379  // Look for a set pixel in this row
380  image::Image<PixelT>::x_iterator begin = idImage->row_begin(y), end = idImage->row_end(y);
382 
383  if (first != end) { // A pixel is set in this row
385  int const x0 = first - begin;
386  int const x1 = last - begin;
387  int const x_size = 1 + x1 - x0;
388 
389  std::fill(first, last + 1, 0); // clear pixels; we don't want to see them again
390 
391  bbox.include(lsst::geom::Point2I(x0, y)); // the LLC
392  bbox.include(lsst::geom::Point2I(x1, y)); // the LRC; initial guess for URC
393 
394  // we found at least one pixel so extend the BBox upwards
395  for (++y; y < height; ++y) {
396  if (std::find(idImage->at(x0, y), idImage->at(x0, y) + x_size, 0) !=
397  idImage->at(x0, y) + x_size) {
398  break; // some pixels weren't set, so the BBox stops here, (actually in previous row)
399  }
400  std::fill(idImage->at(x0, y), idImage->at(x0, y) + x_size, 0);
401 
402  bbox.include(lsst::geom::Point2I(x1, y)); // the new URC
403  }
404 
405  bbox.shift(shift);
406  bboxes.push_back(bbox);
407  } else {
408  y0 = y + 1;
409  }
410  break;
411  }
412  }
413 
414  return bboxes;
415 }
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
int end
int y
Definition: SpanSet.cc:48
T begin(T... args)
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  {
152  return HeavyFootprint<ImagePixelT, MaskPixelT, VariancePixelT>(foot, img, ctrl);
153 }

◆ 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 327 of file Footprint.cc.

327  {
328  // Bail out early if the schemas are not the same
329  if (footprint1.getPeaks().getSchema() != footprint2.getPeaks().getSchema()) {
330  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
331  "Cannot merge Footprints with different Schemas");
332  }
333 
334  // Merge the SpanSets
335  auto unionedSpanSet = footprint1.getSpans()->union_(*(footprint2.getSpans()));
336 
337  // Construct merged Footprint
338  auto mergedFootprint = std::make_shared<Footprint>(unionedSpanSet, footprint1.getPeaks().getSchema());
339  // Copy over the peaks from both footprints
340  mergedFootprint->setPeakCatalog(PeakCatalog(footprint1.getPeaks().getTable()));
341  PeakCatalog& peaks = mergedFootprint->getPeaks();
342  peaks.reserve(footprint1.getPeaks().size() + footprint2.getPeaks().size());
343  peaks.insert(peaks.end(), footprint1.getPeaks().begin(), footprint1.getPeaks().end(), true);
344  peaks.insert(peaks.end(), footprint2.getPeaks().begin(), footprint2.getPeaks().end(), true);
345 
346  // Sort the PeaksCatalog according to value
347  mergedFootprint->sortPeaks();
348 
349  return mergedFootprint;
350 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
Definition: Catalog.h:433
afw::table::CatalogT< PeakRecord > PeakCatalog
Definition: Peak.h:244

◆ 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
135  lsst::geom::Box2I bbox(h1.getBBox());
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 }
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
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:327

◆ operator<<()

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 }
std::ostream * os
Definition: Schema.cc:557
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ 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:76
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 76 of file _footprint.cc.

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

◆ 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 84 of file _footprintSet.cc.

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

◆ 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 }

◆ 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 48 of file _psf.cc.

48  {
49  wrappers.addInheritanceDependency("lsst.afw.typehandling");
50  wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
51  wrappers.addSignatureDependency("lsst.afw.image");
52  wrappers.addSignatureDependency("lsst.afw.fits");
53 
54  auto clsPsf = wrappers.wrapType(
55  py::class_<Psf, PySharedPtr<Psf>, typehandling::Storable, PsfTrampoline<>>(
56  wrappers.module, "Psf"
57  ),
58  [](auto& mod, auto& cls) {
59  table::io::python::addPersistableMethods<Psf>(cls);
60  cls.def(py::init<bool, size_t>(), "isFixed"_a=false, "capacity"_a=100); // Constructor for pure-Python subclasses
61  cls.def("clone", &Psf::clone);
62  cls.def("resized", &Psf::resized, "width"_a, "height"_a);
63 
64  // Position-required overloads. Can (likely) remove overload_cast<> once deprecation period for
65  // default position argument ends.
66  cls.def("computeImage",
67  py::overload_cast<lsst::geom::Point2D, image::Color, Psf::ImageOwnerEnum>(&Psf::computeImage, py::const_),
68  "position"_a,
69  "color"_a = image::Color(),
70  "owner"_a = Psf::ImageOwnerEnum::COPY
71  );
72  cls.def("computeKernelImage",
73  py::overload_cast<lsst::geom::Point2D, image::Color, Psf::ImageOwnerEnum>(&Psf::computeKernelImage, py::const_),
74  "position"_a,
75  "color"_a = image::Color(),
76  "owner"_a = Psf::ImageOwnerEnum::COPY
77  );
78  cls.def("computePeak",
79  py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computePeak, py::const_),
80  "position"_a,
81  "color"_a = image::Color()
82  );
83  cls.def("computeApertureFlux",
84  py::overload_cast<double, lsst::geom::Point2D, image::Color>(&Psf::computeApertureFlux, py::const_),
85  "radius"_a,
86  "position"_a,
87  "color"_a = image::Color()
88  );
89  cls.def("computeShape",
90  py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeShape, py::const_),
91  "position"_a,
92  "color"_a = image::Color()
93  );
94  cls.def("computeBBox",
95  py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeBBox, py::const_),
96  "position"_a,
97  "color"_a = image::Color()
98  );
99  cls.def("computeImageBBox",
100  py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeImageBBox, py::const_),
101  "position"_a,
102  "color"_a = image::Color()
103  );
104  cls.def("computeKernelBBox",
105  py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::computeKernelBBox, py::const_),
106  "position"_a,
107  "color"_a = image::Color()
108  );
109  cls.def("getLocalKernel",
110  py::overload_cast<lsst::geom::Point2D, image::Color>(&Psf::getLocalKernel, py::const_),
111  "position"_a,
112  "color"_a = image::Color()
113  );
114 
115  // Deprecated default position argument overloads.
116  cls.def("computeImage",
117  [](const Psf& psf) {
118  py::gil_scoped_acquire gil;
119  auto warnings = py::module::import("warnings");
120  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
121  warnings.attr("warn")(
122  "Default position argument overload is deprecated and will be "
123  "removed in version 24.0. Please explicitly specify a position.",
124  "category"_a=FutureWarning
125  );
126  return psf.computeImage();
127  }
128  );
129  cls.def("computeKernelImage",
130  [](const Psf& psf) {
131  py::gil_scoped_acquire gil;
132  auto warnings = py::module::import("warnings");
133  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
134  warnings.attr("warn")(
135  "Default position argument overload is deprecated and will be "
136  "removed in version 24.0. Please explicitly specify a position.",
137  "category"_a=FutureWarning
138  );
139  return psf.computeKernelImage();
140  }
141  );
142  cls.def("computePeak",
143  [](const Psf& psf) {
144  py::gil_scoped_acquire gil;
145  auto warnings = py::module::import("warnings");
146  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
147  warnings.attr("warn")(
148  "Default position argument overload is deprecated and will be "
149  "removed in version 24.0. Please explicitly specify a position.",
150  "category"_a=FutureWarning
151  );
152  return psf.computePeak();
153  }
154  );
155  cls.def("computeApertureFlux",
156  [](const Psf& psf, double radius) {
157  py::gil_scoped_acquire gil;
158  auto warnings = py::module::import("warnings");
159  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
160  warnings.attr("warn")(
161  "Default position argument overload is deprecated and will be "
162  "removed in version 24.0. Please explicitly specify a position.",
163  "category"_a=FutureWarning
164  );
165  return psf.computeApertureFlux(radius);
166  },
167  "radius"_a
168  );
169  cls.def("computeShape",
170  [](const Psf& psf) {
171  py::gil_scoped_acquire gil;
172  auto warnings = py::module::import("warnings");
173  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
174  warnings.attr("warn")(
175  "Default position argument overload is deprecated and will be "
176  "removed in version 24.0. Please explicitly specify a position.",
177  "category"_a=FutureWarning
178  );
179  return psf.computeShape();
180  }
181  );
182  cls.def("computeBBox",
183  [](const Psf& psf) {
184  py::gil_scoped_acquire gil;
185  auto warnings = py::module::import("warnings");
186  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
187  warnings.attr("warn")(
188  "Default position argument overload is deprecated and will be "
189  "removed in version 24.0. Please explicitly specify a position.",
190  "category"_a=FutureWarning
191  );
192  return psf.computeBBox();
193  }
194  );
195  cls.def("computeImageBBox",
196  [](const Psf& psf) {
197  py::gil_scoped_acquire gil;
198  auto warnings = py::module::import("warnings");
199  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
200  warnings.attr("warn")(
201  "Default position argument overload is deprecated and will be "
202  "removed in version 24.0. Please explicitly specify a position.",
203  "category"_a=FutureWarning
204  );
205  return psf.computeImageBBox();
206  }
207  );
208  cls.def("computeKernelBBox",
209  [](const Psf& psf) {
210  py::gil_scoped_acquire gil;
211  auto warnings = py::module::import("warnings");
212  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
213  warnings.attr("warn")(
214  "Default position argument overload is deprecated and will be "
215  "removed in version 24.0. Please explicitly specify a position.",
216  "category"_a=FutureWarning
217  );
218  return psf.computeKernelBBox();
219  }
220  );
221  cls.def("getLocalKernel",
222  [](const Psf& psf) {
223  py::gil_scoped_acquire gil;
224  auto warnings = py::module::import("warnings");
225  auto FutureWarning = py::handle(PyEval_GetBuiltins())["FutureWarning"];
226  warnings.attr("warn")(
227  "Default position argument overload is deprecated and will be "
228  "removed in version 24.0. Please explicitly specify a position.",
229  "category"_a=FutureWarning
230  );
231  return psf.getLocalKernel();
232  }
233  );
234  // End deprecated default position argument overloads.
235 
236  cls.def("getAverageColor", &Psf::getAverageColor);
237  cls.def("getAveragePosition", &Psf::getAveragePosition);
238  cls.def_static("recenterKernelImage", &Psf::recenterKernelImage, "im"_a, "position"_a,
239  "warpAlgorithm"_a = "lanczos5", "warpBuffer"_a = 5);
240  cls.def("getCacheCapacity", &Psf::getCacheCapacity);
241  cls.def("setCacheCapacity", &Psf::setCacheCapacity);
242  }
243  );
244 
245  wrappers.wrapType(py::enum_<Psf::ImageOwnerEnum>(clsPsf, "ImageOwnerEnum"), [](auto& mod, auto& enm) {
246  enm.value("COPY", Psf::ImageOwnerEnum::COPY);
247  enm.value("INTERNAL", Psf::ImageOwnerEnum::INTERNAL);
248  enm.export_values();
249  });
250 }
Key< int > psf
Definition: Exposure.cc:65

◆ wrapPsf() [2/2]

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

◆ wrapThreshold() [1/2]

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

Definition at line 38 of file _threshold.cc.

38  {
39  auto clsThreshold = wrappers.wrapType(
40  py::class_<Threshold, std::shared_ptr<Threshold>>(wrappers.module, "Threshold"),
41  [](auto& mod, auto& cls) {
42  cls.def(py::init<double const, typename Threshold::ThresholdType const, bool const,
43  double const>(),
44  "value"_a, "type"_a = Threshold::VALUE, "polarity"_a = true,
45  "includeMultiplier"_a = 1.0);
46 
47  cls.def("getType", &Threshold::getType);
48  cls.def_static("parseTypeString", Threshold::parseTypeString);
49  cls.def_static("getTypeString", Threshold::getTypeString);
50  cls.def("getValue", (double (Threshold::*)(const double) const) & Threshold::getValue,
51  "param"_a = -1);
52  //
53  // template<typename ImageT>
54  // double getValue(ImageT const& image) const;
55  //
56  cls.def("getPolarity", &Threshold::getPolarity);
57  cls.def("setPolarity", &Threshold::setPolarity);
58  cls.def("getIncludeMultiplier", &Threshold::getIncludeMultiplier);
59  cls.def("setIncludeMultiplier", &Threshold::setIncludeMultiplier);
60  });
61 
62  wrappers.wrapType(py::enum_<Threshold::ThresholdType>(clsThreshold, "ThresholdType"),
63  [](auto& mod, auto& enm) {
64  enm.value("VALUE", Threshold::ThresholdType::VALUE);
65  enm.value("BITMASK", Threshold::ThresholdType::BITMASK);
66  enm.value("STDEV", Threshold::ThresholdType::STDEV);
67  enm.value("VARIANCE", Threshold::ThresholdType::VARIANCE);
68  enm.value("PIXEL_STDEV", Threshold::ThresholdType::PIXEL_STDEV);
69  enm.export_values();
70  });
71 
72  wrappers.wrap([](auto& mod) {
73  mod.def("createThreshold", createThreshold, "value"_a, "type"_a = "value", "polarity"_a = true);
74  });
75 }
Threshold createThreshold(const double value, const std::string type="value", const bool polarity=true)
Factory method for creating Threshold objects.
Definition: Threshold.cc:109
@ STDEV
estimate sample standard deviation
Definition: Statistics.h:67
@ VARIANCE
estimate sample variance
Definition: Statistics.h:68

◆ wrapThreshold() [2/2]

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