23"""lsst.afw.geom.ellipses
25from ._ellipses
import *
26from ._ellipse
import *
28from ._quadrupole
import *
31 (Distortion, DeterminantRadius): SeparableDistortionDeterminantRadius,
32 (Distortion, TraceRadius): SeparableDistortionTraceRadius,
33 (Distortion, LogDeterminantRadius): SeparableDistortionLogDeterminantRadius,
34 (Distortion, LogTraceRadius): SeparableDistortionLogTraceRadius,
35 (ConformalShear, DeterminantRadius): SeparableConformalShearDeterminantRadius,
36 (ConformalShear, TraceRadius): SeparableConformalShearTraceRadius,
37 (ConformalShear, LogDeterminantRadius): SeparableConformalShearLogDeterminantRadius,
38 (ConformalShear, LogTraceRadius): SeparableConformalShearLogTraceRadius
43 """An interface for drawing the ellipse using matplotlib.
45 This is typically initiated by calling Ellipse.plot(), which
46 returns an instance of this
class.
49 def __init__(self, ellipse, scale=1.0, **kwds):
50 import matplotlib.patches
53 self.
__ellipse__ellipse = weakref.proxy(ellipse)
56 core.scale(2.0 * scale)
57 self.
patchpatch = matplotlib.patches.Ellipse(
58 (self.
__ellipse__ellipse.getCenter().getX(), self.
__ellipse__ellipse.getCenter().getY()),
59 core.getA(), core.getB(), core.getTheta() * 180.0 / np.pi,
64 return getattr(self.
patchpatch, name)
66 def update(self, show=True, rescale=True):
67 """Update the matplotlib representation to the current ellipse parameters.
69 import matplotlib.patches
71 core = _agl.Axes(self.
__ellipse__ellipse.getCore())
72 core.scale(2.0 * scale)
73 new_patch = matplotlib.patches.Ellipse(
74 (self.
__ellipse__ellipse.getCenter().getX(), self.
__ellipse__ellipse.getCenter().getY()),
75 core.a, core.b, core.theta * 180.0 / np.pi
77 new_patch.update_from(self.
patchpatch)
78 axes = self.
patchpatch.get_axes()
80 self.
patchpatch.remove()
81 axes.add_patch(new_patch)
82 self.
patchpatch = new_patch
87 axes.figure.canvas.draw()
90def 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.
94 Aside
from those below, keyword arguments
for the
95 matplotlib.patches.Patch constructor are also accepted
96 (
'facecolor',
'linestyle', etc.)
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
107 rescale : `bool`, optional
108 If
True, rescale the axes.
112 interface : `EllipseMatplotlibInterface`
113 An object that allows the matplotlib patch to be updated when the
116 import matplotlib.pyplot
117 interface = self.MatplotlibInterface(self, scale, **kwds)
119 axes = matplotlib.pyplot.gca()
120 axes.add_patch(interface.patch)
122 axes.autoscale_view()
124 axes.figure.canvas.draw()
128Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
129Ellipse.plot = Ellipse_plot
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
def __getattr__(self, name)
def __init__(self, ellipse, scale=1.0, **kwds)
def update(self, show=True, rescale=True)
def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds)