LSSTApplications  19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+17,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+5,19.0.0-20-g5a5a17ab+15,19.0.0-21-g2644856+18,19.0.0-23-g84eeccb+6,19.0.0-24-g878c510+5,19.0.0-25-g6c8df7140,19.0.0-25-gb330496+5,19.0.0-3-g2b32d65+5,19.0.0-3-g8227491+16,19.0.0-3-g9c54d0d+16,19.0.0-3-gca68e65+12,19.0.0-3-gcfc5f51+5,19.0.0-3-ge110943+15,19.0.0-3-ge74d124,19.0.0-3-gfe04aa6+16,19.0.0-30-g9c3fd16+6,19.0.0-4-g06f5963+5,19.0.0-4-g3d16501+18,19.0.0-4-g4a9c019+5,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8278b9b+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+17,19.0.0-4-ge404a01+16,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gfb03ce7+17,19.0.0-6-gbaebbfb+16,19.0.0-61-gec4c6e08+6,19.0.0-7-g039c0b5+16,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+17,19.0.0-70-g334bf3e+1,19.0.0-9-g463f923+16,b.20.0.x-g5487ab2134,v20.0.0.rc1
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  returns an instance of this class.
44  """
45 
46  def __init__(self, ellipse, scale=1.0, **kwds):
47  import matplotlib.patches
48  import weakref
49  import numpy as np
50  self.__ellipse = weakref.proxy(ellipse)
51  self.scale = float(scale)
52  core = Axes(self.__ellipse.getCore())
53  core.scale(2.0 * scale)
54  self.patch = matplotlib.patches.Ellipse(
55  (self.__ellipse.getCenter().getX(), self.__ellipse.getCenter().getY()),
56  core.getA(), core.getB(), core.getTheta() * 180.0 / np.pi,
57  **kwds
58  )
59 
60  def __getattr__(self, name):
61  return getattr(self.patch, name)
62 
63  def update(self, show=True, rescale=True):
64  """Update the matplotlib representation to the current ellipse parameters.
65  """
66  import matplotlib.patches
67  import numpy as np
68  core = _agl.Axes(self.__ellipse.getCore())
69  core.scale(2.0 * scale)
70  new_patch = matplotlib.patches.Ellipse(
71  (self.__ellipse.getCenter().getX(), self.__ellipse.getCenter().getY()),
72  core.a, core.b, core.theta * 180.0 / np.pi
73  )
74  new_patch.update_from(self.patch)
75  axes = self.patch.get_axes()
76  if axes is not None:
77  self.patch.remove()
78  axes.add_patch(new_patch)
79  self.patch = new_patch
80  if axes is not None:
81  if rescale:
82  axes.autoscale_view()
83  if show:
84  axes.figure.canvas.draw()
85 
86 
87 def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds):
88  """Plot the ellipse in matplotlib, adding a MatplotlibInterface
89  object as the 'matplotlib' attribute of the ellipse.
90 
91  Aside from those below, keyword arguments for the
92  matplotlib.patches.Patch constructor are also accepted
93  ('facecolor', 'linestyle', etc.)
94 
95  Parameters
96  ----------
97  axes : `matplotlib.axes.Axes`, optional
98  Axes to plot on. Defaults to matplotlib.pyplot.gca().
99  scale : `float`, optional
100  Scale the displayed ellipse by this factor.
101  show : `bool`, optional
102  If True, update the figure automatically. Set to False for batch
103  processing.
104  rescale : `bool`, optional
105  If True, rescale the axes.
106 
107  Returns
108  -------
109  interface : `EllipseMatplotlibInterface`
110  An object that allows the matplotlib patch to be updated when the
111  ellipse modified.
112  """
113  import matplotlib.pyplot
114  interface = self.MatplotlibInterface(self, scale, **kwds)
115  if axes is None:
116  axes = matplotlib.pyplot.gca()
117  axes.add_patch(interface.patch)
118  if rescale:
119  axes.autoscale_view()
120  if show:
121  axes.figure.canvas.draw()
122  return interface
123 
124 
125 Ellipse.MatplotlibInterface = EllipseMatplotlibInterface
126 Ellipse.plot = Ellipse_plot
lsst::afw::geom::ellipses.EllipseMatplotlibInterface.scale
scale
Definition: __init__.py:51
lsst::afw::geom::ellipses.EllipseMatplotlibInterface.__init__
def __init__(self, ellipse, scale=1.0, **kwds)
Definition: __init__.py:46
lsst::afw::geom::ellipses.EllipseMatplotlibInterface.__getattr__
def __getattr__(self, name)
Definition: __init__.py:60
lsst::afw::geom::ellipses::Axes
An ellipse core for the semimajor/semiminor axis and position angle parametrization (a,...
Definition: Axes.h:47
lsst::afw::geom::ellipses.EllipseMatplotlibInterface.__ellipse
__ellipse
Definition: __init__.py:50
lsst::afw::geom::ellipses.EllipseMatplotlibInterface.patch
patch
Definition: __init__.py:54
lsst::afw::geom::ellipses.Ellipse_plot
def Ellipse_plot(self, axes=None, scale=1.0, show=True, rescale=True, **kwds)
Definition: __init__.py:87
lsst::afw::geom::ellipses.EllipseMatplotlibInterface.update
def update(self, show=True, rescale=True)
Definition: __init__.py:63
lsst::afw::geom::ellipses.EllipseMatplotlibInterface
Definition: __init__.py:39