23 """lsst.afw.geom.ellipses 25 from __future__
import absolute_import
26 from .ellipsesLib
import *
29 (Distortion, DeterminantRadius): SeparableDistortionDeterminantRadius,
30 (Distortion, TraceRadius): SeparableDistortionTraceRadius,
31 (Distortion, LogDeterminantRadius): SeparableDistortionLogDeterminantRadius,
32 (Distortion, LogTraceRadius): SeparableDistortionLogTraceRadius,
33 (ConformalShear, DeterminantRadius): SeparableConformalShearDeterminantRadius,
34 (ConformalShear, TraceRadius): SeparableConformalShearTraceRadius,
35 (ConformalShear, LogDeterminantRadius): SeparableConformalShearLogDeterminantRadius,
36 (ConformalShear, LogTraceRadius): SeparableConformalShearLogTraceRadius
41 """An interface for drawing the ellipse using matplotlib. 43 This is typically initiated by calling Ellipse.plot(), which 44 adds the interface as the matplotlib attribute of the ellipse 45 object (this can be deleted later if desired). 48 def __init__(self, ellipse, scale=1.0, **kwds):
49 import matplotlib.patches
53 core.scale(2.0 * scale)
54 self.
patch = matplotlib.patches.Ellipse(
56 core.getA(), core.getB(), core.getTheta() * 180.0 / numpy.pi,
61 return getattr(self.
patch, name)
63 def update(self, show=True, rescale=True):
64 """Update the matplotlib representation to the current ellipse parameters. 66 import matplotlib.patches
67 core = _agl.Axes(self.
__ellipse.getCore())
68 core.scale(2.0 * scale)
69 new_patch = matplotlib.patches.Ellipse(
71 core.a, core.b, core.theta * 180.0 / numpy.pi
73 new_patch.update_from(self.
patch)
74 axes = self.
patch.get_axes()
77 axes.add_patch(new_patch)
78 self.
patch = new_patch
83 axes.figure.canvas.draw()
86 def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds):
87 """Plot the ellipse in matplotlib, adding a MatplotlibInterface 88 object as the 'matplotlib' attribute of the ellipse. 90 Aside from those below, keyword arguments for the 91 matplotlib.patches.Patch constructor are also accepted 92 ('facecolor', 'linestyle', etc.) 95 axes -------- A matplotlib.axes.Axes object, or None to use 96 matplotlib.pyplot.gca(). 97 scale ------- Scale the displayed ellipse by this factor. 98 show -------- If True, update the figure automatically. Set 99 to False for batch processing. 100 rescale ----- If True, rescale the axes. 102 import matplotlib.pyplot
103 self.matplotlib = self.MatplotlibInterface(self, scale, **kwds)
105 axes = matplotlib.pyplot.gca()
106 axes.add_patch(self.matplotlib.patch)
108 axes.autoscale_view()
110 axes.figure.canvas.draw()
111 return self.matplotlib.patch
def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, kwds)
def __getattr__(self, name)
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...
def __init__(self, ellipse, scale=1.0, kwds)
def update(self, show=True, rescale=True)