lsst::afw::geom::ellipses Namespace Reference

_axes

_ellipse

detail

## Classes

class  Axes
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,b,theta). More...

class  BaseCore
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size. More...

class  ConformalShear
A logarithmic complex ellipticity with magnitude $$|e| = \ln (a/b)$$. More...

class  Distortion
A complex ellipticity with magnitude $$|e| = \frac{a^2 - b^2}{a^2 + b^2}$$. More...

class  Ellipse
An ellipse defined by an arbitrary BaseCore and a center point. More...

class  Parametric
A functor that returns points on the boundary of the ellipse as a function of a parameter that runs between 0 and 2 pi (but is not angle). More...

class  PixelRegion
A pixelized region containing all pixels whose centers are within an Ellipse. More...

An ellipse core with quadrupole moments as parameters. More...

class  Separable
An ellipse core with a complex ellipticity and radius parameterization. More...

The radius defined as the 4th root of the determinant of the quadrupole matrix. More...

The radius defined as $$\sqrt{0.5(I_{xx} + I_{yy})}$$. More...

The natural logarithm of the DeterminantRadius. More...

The natural logarithm of the TraceRadius. More...

class  ReducedShear
A complex ellipticity with magnitude $$|e| = \frac{a-b}{a+b}$$. More...

class  EllipseMatplotlibInterface

class  EllipseHorizontalLineIntersection

## Functions

def Ellipse_plot (self, axes=None, scale=1.0, show=True, rescale=True, **kwds)

void wrapAxes (lsst::utils::python::WrapperCollection &wrappers)

void wrapBaseCore (lsst::utils::python::WrapperCollection &wrappers)

void wrapConformalShear (lsst::utils::python::WrapperCollection &wrappers)

void wrapDistortion (lsst::utils::python::WrapperCollection &wrappers)

void wrapEllipse (lsst::utils::python::WrapperCollection &wrappers)

void wrapPixelRegion (lsst::utils::python::WrapperCollection &)

void wrapEllipticityBase (lsst::utils::python::WrapperCollection &)

void wrapReducedShear (lsst::utils::python::WrapperCollection &)

void wrapSeparable (lsst::utils::python::WrapperCollection &)

PYBIND11_MODULE (_ellipses, mod)

template<typename Ellipticity_ , typename Radius_ >
void declareSeparable (lsst::utils::python::WrapperCollection &wrappers, const std::string &suffix)

## Variables

dictionary Separable

## Typedef Documentation

Definition at line 57 of file ellipses.h.

Definition at line 59 of file ellipses.h.

Definition at line 60 of file ellipses.h.

Definition at line 58 of file ellipses.h.

Definition at line 52 of file ellipses.h.

Definition at line 54 of file ellipses.h.

Definition at line 55 of file ellipses.h.

Definition at line 53 of file ellipses.h.

Definition at line 62 of file ellipses.h.

Definition at line 64 of file ellipses.h.

Definition at line 65 of file ellipses.h.

Definition at line 63 of file ellipses.h.

## ◆ declareSeparable()

template<typename Ellipticity_ , typename Radius_ >
 void lsst::afw::geom::ellipses::declareSeparable ( lsst::utils::python::WrapperCollection & wrappers, const std::string & suffix )

Definition at line 43 of file _separable.cc.

43  {
44  using Class = Separable<Ellipticity_, Radius_>;
45  wrappers.wrapType(
46  py::class_<Class, std::shared_ptr<Class>, BaseCore>(wrappers.module,
47  ("Separable" + suffix).c_str()),
48  [](auto &mod, auto &cls) {
49  cls.def(py::init<double, double, double, bool>(), "e1"_a = 0.0, "e2"_a = 0.0,
51  cls.def(py::init<Class const &>());
52  cls.def(py::init<BaseCore const &>());
53
54  cls.def("getE1", &Class::getE1);
55  cls.def("setE1", &Class::setE1);
56  cls.def("getE2", &Class::getE2);
57  cls.def("setE2", &Class::setE2);
61  cls.def("getEllipticity", (Ellipticity_ const &(Class::*)() const) & Class::getEllipticity);
62  cls.def("clone", &Class::clone);
63  cls.def("getName", &Class::getName);
64  cls.def("normalize", &Class::normalize);
65  cls.def("assign", [](Class &self, Class &other) { self = other; });
66  cls.def("assign", [](Class &self, BaseCore &other) { self = other; });
67  cls.def("transform", [](Class &self, lsst::geom::LinearTransform const &t) {
68  return std::static_pointer_cast<Class>(self.transform(t).copy());
69  });
70  cls.def("transformInPlace", [](Class &self, lsst::geom::LinearTransform const &t) {
71  self.transform(t).inPlace();
72  });
73  cls.def("__str__", [](Class &self) {
75  });
76  cls.def("__repr__", [](Class &self) {
78  });
79  });
80 }
table::Key< int > transform
A 2D linear coordinate transformation.
T copy(T... args)

## ◆ Ellipse_plot()

 def lsst.afw.geom.ellipses.Ellipse_plot ( self, axes = None, scale = 1.0, show = True, rescale = True, ** kwds )
Plot the ellipse in matplotlib, adding a MatplotlibInterface
object as the 'matplotlib' attribute of the ellipse.

Aside from those below, keyword arguments for the
matplotlib.patches.Patch constructor are also accepted
('facecolor', 'linestyle', etc.)

Parameters
----------
axes : matplotlib.axes.Axes, optional
Axes to plot on.  Defaults to matplotlib.pyplot.gca().
scale : float, optional
Scale the displayed ellipse by this factor.
show : bool, optional
If True, update the figure automatically.  Set to False for batch
processing.
rescale : bool, optional
If True, rescale the axes.

Returns
-------
interface : EllipseMatplotlibInterface
An object that allows the matplotlib patch to be updated when the
ellipse modified.


Definition at line 90 of file __init__.py.

90 def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds):
91  """Plot the ellipse in matplotlib, adding a MatplotlibInterface
92  object as the 'matplotlib' attribute of the ellipse.
93
94  Aside from those below, keyword arguments for the
95  matplotlib.patches.Patch constructor are also accepted
96  ('facecolor', 'linestyle', etc.)
97
98  Parameters
99  ----------
100  axes : matplotlib.axes.Axes, optional
101  Axes to plot on. Defaults to matplotlib.pyplot.gca().
102  scale : float, optional
103  Scale the displayed ellipse by this factor.
104  show : bool, optional
105  If True, update the figure automatically. Set to False for batch
106  processing.
107  rescale : bool, optional
108  If True, rescale the axes.
109
110  Returns
111  -------
112  interface : EllipseMatplotlibInterface
113  An object that allows the matplotlib patch to be updated when the
114  ellipse modified.
115  """
116  import matplotlib.pyplot
117  interface = self.MatplotlibInterface(self, scale, **kwds)
118  if axes is None:
119  axes = matplotlib.pyplot.gca()
121  if rescale:
122  axes.autoscale_view()
123  if show:
124  axes.figure.canvas.draw()
125  return interface
126
127
128 Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
129 Ellipse.plot = Ellipse_plot
def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds)
Definition: __init__.py:90

## ◆ PYBIND11_MODULE()

 lsst::afw::geom::ellipses::PYBIND11_MODULE ( _ellipses , mod )

Definition at line 43 of file _ellipses.cc.

43  {
44  lsst::utils::python::WrapperCollection wrappers(mod, "lsst.afw.geom.ellipses");
46  wrapEllipse(wrappers);
47  wrapPixelRegion(wrappers);
48  wrapBaseCore(wrappers);
49  wrapAxes(wrappers);
51  wrapEllipticityBase(wrappers);
52  wrapDistortion(wrappers);
53  wrapConformalShear(wrappers);
55  wrapReducedShear(wrappers);
56  wrapSeparable(wrappers);
57  wrappers.finish();
58 }
void wrapSeparable(lsst::utils::python::WrapperCollection &)
Definition: _separable.cc:82
void wrapPixelRegion(lsst::utils::python::WrapperCollection &)
Definition: _pixelRegion.cc:35
void wrapConformalShear(lsst::utils::python::WrapperCollection &wrappers)
void wrapEllipse(lsst::utils::python::WrapperCollection &wrappers)
Definition: _ellipse.cc:44
void wrapDistortion(lsst::utils::python::WrapperCollection &wrappers)
Definition: _distortion.cc:38
void wrapEllipticityBase(lsst::utils::python::WrapperCollection &)
void wrapAxes(lsst::utils::python::WrapperCollection &wrappers)
Definition: _axes.cc:37
void wrapReducedShear(lsst::utils::python::WrapperCollection &)
void wrapBaseCore(lsst::utils::python::WrapperCollection &wrappers)
Definition: _baseCore.cc:40

## ◆ wrapAxes()

 void lsst::afw::geom::ellipses::wrapAxes ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 37 of file _axes.cc.

37  {
38  wrappers.wrapType(
39  py::class_<Axes, std::shared_ptr<Axes>, BaseCore>(wrappers.module, "Axes"),
40  [](auto &mod, auto &cls) {
41  /* Constructors */
42  cls.def(py::init<double, double, double, bool>(), "a"_a = 1.0, "b"_a = 1.0, "theta"_a = 0.0,
43  "normalize"_a = false);
44  cls.def(py::init<Axes const &>());
45  cls.def(py::init<BaseCore const &>());
46
47  /* Operators */
48  cls.def(
49  "__eq__", [](Axes &self, Axes &other) { return self == other; }, py::is_operator());
50  cls.def(
51  "__ne__", [](Axes &self, Axes &other) { return self != other; }, py::is_operator());
52
53  /* Members */
54  cls.def("getA", &Axes::getA);
55  cls.def("setA", &Axes::setA);
56  cls.def("getB", &Axes::getB);
57  cls.def("setB", &Axes::setB);
58  cls.def("getTheta", &Axes::getTheta);
59  cls.def("setTheta", &Axes::setTheta);
60  cls.def("clone", &Axes::clone);
61  cls.def("getName", &Axes::getName);
62  cls.def("normalize", &Axes::normalize);
64  cls.def("writeParameters", &Axes::writeParameters);
65  cls.def("assign", [](Axes &self, Axes &other) { self = other; });
66  cls.def("assign", [](Axes &self, BaseCore &other) { self = other; });
67  cls.def("transform", [](Axes &self, lsst::geom::LinearTransform const &t) {
68  return std::static_pointer_cast<Axes>(self.transform(t).copy());
69  });
70  cls.def("transformInPlace", [](Axes &self, lsst::geom::LinearTransform const &t) {
71  self.transform(t).inPlace();
72  });
73  });
74 }
std::string const & getName() const noexcept
Return a filter's name.
Definition: Filter.h:78

## ◆ wrapBaseCore()

 void lsst::afw::geom::ellipses::wrapBaseCore ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 40 of file _baseCore.cc.

40  {
41  wrappers.wrapType(py::class_<BaseCore, std::shared_ptr<BaseCore>>(wrappers.module, "BaseCore"),
42  [](auto &mod, auto &cls) {
43  cls.def("__eq__", &BaseCore::operator==, py::is_operator());
44  cls.def("__nq__", &BaseCore::operator!=, py::is_operator());
45  /* Members */
46  cls.def("getName", &BaseCore::getName);
47  cls.def("clone", &BaseCore::clone);
48  cls.def("normalize", &BaseCore::normalize);
49  cls.def("grow", &BaseCore::grow);
50  cls.def("scale", &BaseCore::scale);
51  cls.def("getArea", &BaseCore::getArea);
54  cls.def("convolve", (BaseCore::Convolution(BaseCore::*)(BaseCore const &)) &
55  BaseCore::convolve);
56  cls.def("computeDimensions", &BaseCore::computeDimensions);
57  cls.def("getParameterVector", &BaseCore::getParameterVector);
58  cls.def("setParameterVector", &BaseCore::setParameterVector);
59  });
60 }

## ◆ wrapConformalShear()

 void lsst::afw::geom::ellipses::wrapConformalShear ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 39 of file _conformalShear.cc.

39  {
40  wrappers.wrapType(py::class_<ConformalShear, detail::EllipticityBase>(wrappers.module, "ConformalShear"),
41  [](auto &mod, auto &cls) {
42  /* Constructors */
43  cls.def(py::init<std::complex<double> const &>());
44  cls.def(py::init<double, double>(), "e1"_a = 0.0, "e2"_a = 0.0);
45
46  /* Members */
47  // cls.def("dAssign", (Jacobian (ConformalShear::*)(Distortion const &))
48  // &ConformalShear::dAssign); cls.def("dAssign", (Jacobian
49  // (ConformalShear::*)(ReducedShear const &)) &ConformalShear::dAssign);
50  cls.def("getAxisRatio", &ConformalShear::getAxisRatio);
51  cls.def("normalize", &ConformalShear::normalize);
52  cls.def("getName", &ConformalShear::getName);
53  cls.def("__repr__", [](ConformalShear const &self) {
54  return py::str("{}({}, {})").format(self.getName(), self.getE1(), self.getE2());
55  });
56  });
57 }

## ◆ wrapDistortion()

 void lsst::afw::geom::ellipses::wrapDistortion ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 38 of file _distortion.cc.

38  {
39  wrappers.wrapType(py::class_<Distortion, detail::EllipticityBase>(wrappers.module, "Distortion"),
40  [](auto &mod, auto &cls) {
41  /* Constructors */
42  cls.def(py::init<std::complex<double> const &>());
43  cls.def(py::init<double, double>(), "e1"_a = 0.0, "e2"_a = 0.0);
44
45  /* Members */
46  // cls.def("dAssign", (Jacobian (Distortion::*)(Distortion const &))
47  // &Distortion::dAssign); cls.def("dAssign", (Jacobian
48  // (Distortion::*)(ReducedShear const &)) &Distortion::dAssign);
49  cls.def("getAxisRatio", &Distortion::getAxisRatio);
50  cls.def("normalize", &Distortion::normalize);
51  cls.def("getName", &Distortion::getName);
52  cls.def("__repr__", [](Distortion const &self) {
53  return py::str("{}({}, {})").format(self.getName(), self.getE1(), self.getE2());
54  });
55  });
56 }

## ◆ wrapEllipse()

 void lsst::afw::geom::ellipses::wrapEllipse ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 44 of file _ellipse.cc.

44  {
45  wrappers.wrapType(
46  py::class_<Ellipse, std::shared_ptr<Ellipse>>(wrappers.module, "Ellipse"),
47  [](auto &mod, auto &cls) {
48  /* Constructors */
49  cls.def(py::init<BaseCore const &, lsst::geom::Point2D const &>(), "core"_a,
50  "center"_a = lsst::geom::Point2D());
51  cls.def(py::init<Ellipse const &>());
52  cls.def(py::init<Ellipse::Convolution const &>());
53
54  py::implicitly_convertible<Ellipse::Convolution, Ellipse>();
55
56  /* Operators */
57
58  /* Members */
59  cls.def("getCore", [](Ellipse &ellipse) { return ellipse.getCorePtr(); });
60  cls.def("getCenter", (lsst::geom::Point2D & (Ellipse::*)()) & Ellipse::getCenter);
61  cls.def("setCenter", &Ellipse::setCenter);
62  cls.def("setCore", &Ellipse::setCore);
63  cls.def("normalize", &Ellipse::normalize);
64  cls.def("grow", &Ellipse::grow);
65  cls.def("scale", &Ellipse::scale);
66  cls.def("shift", &Ellipse::shift);
67  cls.def("getParameterVector", &Ellipse::getParameterVector);
68  cls.def("setParameterVector", &Ellipse::setParameterVector);
69  cls.def(
70  "transform",
71  [](Ellipse const &self, lsst::geom::AffineTransform const &t) -> Ellipse {
72  return self.transform(t);
73  },
74  "transform"_a);
75  cls.def("getGridTransform", [](Ellipse &self) -> lsst::geom::AffineTransform {
76  return self.getGridTransform(); // delibarate conversion to lsst::geom::AffineTransform
77  });
78  cls.def("computeBBox", &Ellipse::computeBBox);
79  });
80 }
An affine coordinate transformation consisting of a linear transformation and an offset.
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108

## ◆ wrapEllipticityBase()

 void lsst::afw::geom::ellipses::wrapEllipticityBase ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 37 of file _ellipticityBase.cc.

37  {
38  wrappers.wrapType(py::class_<detail::EllipticityBase>(wrappers.module, "EllipticityBase"),
39  [](auto &mod, auto &cls) {
40  /* Member types and enums */
41  py::enum_<detail::EllipticityBase::ParameterEnum>(cls, "ParameterEnum")
42  .value("E1", detail::EllipticityBase::ParameterEnum::E1)
43  .value("E2", detail::EllipticityBase::ParameterEnum::E2)
44  .export_values();
45
46  /* Members */
47  cls.def("getComplex", (std::complex<double> & (detail::EllipticityBase::*)()) &
48  detail::EllipticityBase::getComplex);
49  cls.def("setComplex", &detail::EllipticityBase::setComplex);
50  cls.def("getE1", &detail::EllipticityBase::getE1);
51  cls.def("setE1", &detail::EllipticityBase::setE1);
52  cls.def("getE2", &detail::EllipticityBase::getE2);
53  cls.def("setE2", &detail::EllipticityBase::setE2);
54  cls.def("getTheta", &detail::EllipticityBase::getTheta);
55  cls.def("__str__", [](detail::EllipticityBase const &self) {
56  return py::str("({}, {})").format(self.getE1(), self.getE2());
57  });
58  });
59 }

## ◆ wrapPixelRegion()

 void lsst::afw::geom::ellipses::wrapPixelRegion ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 35 of file _pixelRegion.cc.

35  {
36  wrappers.wrapType(py::class_<PixelRegion>(wrappers.module, "PixelRegion"), [](auto &mod, auto &cls) {
37  /* Constructors */
38  cls.def(py::init<Ellipse const &>());
39
40  /* Members */
41  cls.def("getBBox", &PixelRegion::getBBox, py::return_value_policy::copy);
42  cls.def("getSpanAt", &PixelRegion::getSpanAt);
43  cls.def(
44  "__iter__",
45  [](const PixelRegion &self) { return py::make_iterator(self.begin(), self.end()); },
46  py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */);
47  });
48 }

 void lsst::afw::geom::ellipses::wrapQuadrupole ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 39 of file _quadrupole.cc.

39  {
40  wrappers.wrapType(
42  [](auto &mod, auto &cls) {
43  /* Member types and enums */
44  using Matrix = Eigen::Matrix<double, 2, 2, Eigen::DontAlign>;
45
46  /* Constructors */
47  cls.def(py::init<double, double, double, bool>(), "ixx"_a = 1.0, "iyy"_a = 1.0, "ixy"_a = 0.0,
48  "normalize"_a = false);
49  cls.def(py::init<BaseCore::ParameterVector const &, bool>(), "vector"_a,
50  "normalize"_a = false);
51  cls.def(py::init<Matrix const &, bool>(), "matrix"_a, "normalize"_a = true);
53  cls.def(py::init<BaseCore const &>());
54  cls.def(py::init<BaseCore::Convolution const &>());
55
57
58  /* Operators */
59  cls.def(
60  "__eq__", [](Quadrupole &self, Quadrupole &other) { return self == other; },
61  py::is_operator());
62  cls.def(
63  "__ne__", [](Quadrupole &self, Quadrupole &other) { return self != other; },
64  py::is_operator());
65
66  /* Members */
74  cls.def("assign", [](Quadrupole &self, BaseCore &other) { self = other; });
75  cls.def("transform", [](Quadrupole &self, lsst::geom::LinearTransform const &t) {
77  });
78  cls.def("transformInPlace", [](Quadrupole &self, lsst::geom::LinearTransform const &t) {
79  self.transform(t).inPlace();
80  });
81  // TODO: pybind11 based on swig wrapper for now. Hopefully can be removed once pybind11 gets
82  // smarter handling of implicit conversions
83  cls.def("convolve", [](Quadrupole &self, BaseCore const &other) {
85  });
86  });
87 }
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.

 void lsst::afw::geom::ellipses::wrapRadii ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 37 of file _radii.cc.

37  {
38  wrappers.wrapType(
40  cls.def(py::init<double>(), "value"_a = 1.0);
43  cls.def("__str__", [](DeterminantRadius const &self) { return std::to_string(self); });
44  cls.def("__repr__", [](DeterminantRadius const &self) {
45  return self.getName() + "(" + std::to_string(self) + ")";
46  });
47  });
48
50  cls.def(py::init<double>(), "value"_a = 1.0);
53  cls.def("__str__", [](TraceRadius const &self) { return std::to_string(self); });
54  cls.def("__repr__",
55  [](TraceRadius const &self) { return self.getName() + "(" + std::to_string(self) + ")"; });
56  });
57
59  [](auto &mod, auto &cls) {
60  cls.def(py::init<double>(), "value"_a = 0.0);
63  cls.def("__str__",
64  [](LogDeterminantRadius const &self) { return std::to_string(self); });
65  cls.def("__repr__", [](LogDeterminantRadius const &self) {
66  return self.getName() + "(" + std::to_string(self) + ")";
67  });
68  });
69
71  [](auto &mod, auto &cls) {
72  cls.def(py::init<double>(), "value"_a = 0.0);
75  cls.def("__str__", [](LogTraceRadius const &self) { return std::to_string(self); });
76  cls.def("__repr__", [](LogTraceRadius const &self) {
77  return self.getName() + "(" + std::to_string(self) + ")";
78  });
79  });
80 }
T to_string(T... args)

## ◆ wrapReducedShear()

 void lsst::afw::geom::ellipses::wrapReducedShear ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 38 of file _reducedShear.cc.

38  {
39  wrappers.wrapType(py::class_<ReducedShear, detail::EllipticityBase>(wrappers.module, "ReducedShear"),
40  [](auto &mod, auto &cls) {
41  /* Constructors */
42  cls.def(py::init<std::complex<double> const &>());
43  cls.def(py::init<double, double>(), "e1"_a = 0.0, "e2"_a = 0.0);
44
45  /* Members */
46  // cls.def("dAssign", (Jacobian (ReducedShear::*)(Distortion const &))
47  // &ReducedShear::dAssign); cls.def("dAssign", (Jacobian
48  // (ReducedShear::*)(ReducedShear const &)) &ReducedShear::dAssign);
49  cls.def("getAxisRatio", &ReducedShear::getAxisRatio);
50  cls.def("normalize", &ReducedShear::normalize);
51  cls.def("getName", &ReducedShear::getName);
52  cls.def("__repr__", [](ReducedShear const &self) {
53  return py::str("{}({}, {})").format(self.getName(), self.getE1(), self.getE2());
54  });
55  });
56 }

## ◆ wrapSeparable()

 void lsst::afw::geom::ellipses::wrapSeparable ( lsst::utils::python::WrapperCollection & wrappers )

Definition at line 82 of file _separable.cc.

82  {
87
92
97 }

## ◆ Separable

 dictionary lsst.afw.geom.ellipses.Separable
Initial value:
1 = {