LSSTApplications  18.1.0
LSSTDataManagementBasePackage
__init__.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008, 2009, 2010 LSST Corporation.
4 #
5 # This product includes software developed by the
6 # LSST Project (http://www.lsst.org/).
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the LSST License Statement and
19 # the GNU General Public License along with this program. If not,
20 # see <http://www.lsstcorp.org/LegalNotices/>.
21 #
22 
23 """lsst.afw.geom.ellipses
24 """
25 from .ellipsesLib import *
26 
27 Separable = {
28  (Distortion, DeterminantRadius): SeparableDistortionDeterminantRadius,
29  (Distortion, TraceRadius): SeparableDistortionTraceRadius,
30  (Distortion, LogDeterminantRadius): SeparableDistortionLogDeterminantRadius,
31  (Distortion, LogTraceRadius): SeparableDistortionLogTraceRadius,
32  (ConformalShear, DeterminantRadius): SeparableConformalShearDeterminantRadius,
33  (ConformalShear, TraceRadius): SeparableConformalShearTraceRadius,
34  (ConformalShear, LogDeterminantRadius): SeparableConformalShearLogDeterminantRadius,
35  (ConformalShear, LogTraceRadius): SeparableConformalShearLogTraceRadius
36 }
37 
38 
40  """An interface for drawing the ellipse using matplotlib.
41 
42  This is typically initiated by calling Ellipse.plot(), which
43  adds the interface as the matplotlib attribute of the ellipse
44  object (this can be deleted later if desired).
45  """
46 
47  def __init__(self, ellipse, scale=1.0, **kwds):
48  import matplotlib.patches
49  self.__ellipse = weakref.proxy(ellipse)
50  self.scale = float(scale)
51  core = Axes(self.__ellipse.getCore())
52  core.scale(2.0 * scale)
53  self.patch = matplotlib.patches.Ellipse(
54  (self.__ellipse.getCenter().getX(), self.__ellipse.getCenter().getY()),
55  core.getA(), core.getB(), core.getTheta() * 180.0 / numpy.pi,
56  **kwds
57  )
58 
59  def __getattr__(self, name):
60  return getattr(self.patch, name)
61 
62  def update(self, show=True, rescale=True):
63  """Update the matplotlib representation to the current ellipse parameters.
64  """
65  import matplotlib.patches
66  core = _agl.Axes(self.__ellipse.getCore())
67  core.scale(2.0 * scale)
68  new_patch = matplotlib.patches.Ellipse(
69  (self.__ellipse.getCenter().getX(), self.__ellipse.getCenter().getY()),
70  core.a, core.b, core.theta * 180.0 / numpy.pi
71  )
72  new_patch.update_from(self.patch)
73  axes = self.patch.get_axes()
74  if axes is not None:
75  self.patch.remove()
76  axes.add_patch(new_patch)
77  self.patch = new_patch
78  if axes is not None:
79  if rescale:
80  axes.autoscale_view()
81  if show:
82  axes.figure.canvas.draw()
83 
84 
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.
88 
89  Aside from those below, keyword arguments for the
90  matplotlib.patches.Patch constructor are also accepted
91  ('facecolor', 'linestyle', etc.)
92 
93  Arguments:
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.
100  """
101  import matplotlib.pyplot
102  self.matplotlib = self.MatplotlibInterface(self, scale, **kwds)
103  if axes is None:
104  axes = matplotlib.pyplot.gca()
105  axes.add_patch(self.matplotlib.patch)
106  if rescale:
107  axes.autoscale_view()
108  if show:
109  axes.figure.canvas.draw()
110  return self.matplotlib.patch
111 
112 
113 # Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
114 # Ellipse.plot = Ellipse_plot
def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, kwds)
Definition: __init__.py:85
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a...
Definition: Axes.h:47
def __init__(self, ellipse, scale=1.0, kwds)
Definition: __init__.py:47
def update(self, show=True, rescale=True)
Definition: __init__.py:62