23 """lsst.afw.geom.ellipses
25 from ellipsesLib
import *
30 (Distortion, DeterminantRadius):SeparableDistortionDeterminantRadius,
31 (Distortion, TraceRadius):SeparableDistortionTraceRadius,
32 (Distortion, LogDeterminantRadius):SeparableDistortionLogDeterminantRadius,
33 (Distortion, LogTraceRadius):SeparableDistortionLogTraceRadius,
34 (ConformalShear, DeterminantRadius):SeparableConformalShearDeterminantRadius,
35 (ConformalShear, TraceRadius):SeparableConformalShearTraceRadius,
36 (ConformalShear, LogDeterminantRadius):SeparableConformalShearLogDeterminantRadius,
37 (ConformalShear, LogTraceRadius):SeparableConformalShearLogTraceRadius
40 BaseCore.cast =
lambda self: globals()[self.getName()].cast(self)
43 """An interface for drawing the ellipse using matplotlib.
45 This is typically initiated by calling Ellipse.plot(), which
46 adds the interface as the matplotlib attribute of the ellipse
47 object (this can be deleted later if desired).
50 def __init__(self, ellipse, scale=1.0, **kwds):
51 import matplotlib.patches
54 core =
Axes(self.__ellipse.getCore())
55 core.scale(2.0 * scale)
56 self.
patch = matplotlib.patches.Ellipse(
57 (self.__ellipse.getCenter().getX(), self.__ellipse.getCenter().getY()),
58 core.getA(), core.getB(), core.getTheta() * 180.0 / numpy.pi,
63 return getattr(self.
patch, name)
65 def update(self, show=True, rescale=True):
66 """Update the matplotlib representation to the current ellipse parameters.
68 import matplotlib.patches
69 core = _agl.Axes(self.__ellipse.getCore())
70 core.scale(2.0 * scale)
71 new_patch = matplotlib.patches.Ellipse(
72 (self.__ellipse.getCenter().getX(), self.__ellipse.getCenter().getY()),
73 core.a, core.b, core.theta * 180.0 / numpy.pi
75 new_patch.update_from(self.
patch)
76 axes = self.patch.get_axes()
79 axes.add_patch(new_patch)
80 self.
patch = new_patch
82 if rescale: axes.autoscale_view()
83 if show: axes.figure.canvas.draw()
85 def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds):
86 """Plot the ellipse in matplotlib, adding a MatplotlibInterface
87 object as the 'matplotlib' attribute of the ellipse.
89 Aside from those below, keyword arguments for the
90 matplotlib.patches.Patch constructor are also accepted
91 ('facecolor', 'linestyle', etc.)
94 axes -------- A matplotlib.axes.Axes object, or None to use
95 matplotlib.pyplot.gca().
96 scale ------- Scale the displayed ellipse by this factor.
97 show -------- If True, update the figure automatically. Set
98 to False for batch processing.
99 rescale ----- If True, rescale the axes.
101 import matplotlib.pyplot
102 self.matplotlib = self.MatplotlibInterface(self, scale, **kwds)
104 axes = matplotlib.pyplot.gca()
105 axes.add_patch(self.matplotlib.patch)
106 if rescale: axes.autoscale_view()
107 if show: axes.figure.canvas.draw()
108 return self.matplotlib.patch
111 Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
112 Ellipse.plot = Ellipse_plot
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...