LSSTApplications  11.0-24-g0a022a1,14.0+76,14.0-1-g4b114ac+19,14.0-1-g6829aa7+15,14.0-1-g7257b6a+17,14.0-1-g8b7e855+69,14.0-1-gfce6a49+15,14.0-10-g2094653+13,14.0-10-gaad1ee2+1,14.0-11-g7664582+5,14.0-17-g2e0c876,14.0-18-g77a82f3,14.0-2-g14e9bfd,14.0-2-g519ff97+17,14.0-2-ga5af9b6+15,14.0-20-gc5946167,14.0-21-gb9e430a+11,14.0-28-gd4c92d7+3,14.0-4-g3609236+11,14.0-4-gae1598d+1,14.0-54-gb4e84373+2,14.0-58-g91bfccb15,14.0-6-ge2c9487+58,14.0-6-gf4f1c34,14.0-7-g0d69b06+17,14.0-8-g56b2ea8+3,14.0-9-g6668b0b
LSSTDataManagementBasePackage
ds9.py
Go to the documentation of this file.
1 #
2 # LSST Data Management System
3 # Copyright 2008, 2009, 2010, 2015 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 
27 
28 from __future__ import absolute_import, division, print_function
29 
30 import lsst.afw.display
31 import lsst.afw.image as afwImage
32 from .interface import getDisplay as _getDisplay, setDefaultBackend
33 try:
34  loaded
35 except NameError:
36  try:
37  setDefaultBackend("lsst.display.ds9")
38  getDisplay = _getDisplay
39  except Exception as e:
40  # No usable version of display_ds9.
41  # Let's define a version of getDisplay() which will throw an exception.
42 
43  # Prior to DM-9433, we used a closure to implicitly capture the
44  # exception being thrown for future reference. Following changes to
45  # exception scope rules in Python 3 (see PEP 3110), it's now regarded
46  # as clearer to make the capture explicit using the following class.
48  def __init__(self, exception):
49  # The exception being caught above may have a bulky context which we
50  # don't want to capture in a closure for all time: see DM-9504 for a
51  # full discussion. We therefore define a new exception of the same
52  # type, which just encodes the error text.
53  self.exception = type(e)("%s (is display_ds9 setup?)" % e)
54 
55  def __call__(self, *args, **kwargs):
56  raise self.exception
57 
58  getDisplay = _RaiseException(e)
59 
61  __init__ = getDisplay
62 
63  loaded = False
64  else:
65  loaded = True
66 
67 #
68 # Backwards compatibility. Downstream code should be converted to use display.RED etc.
69 #
70 from lsst.afw.display import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE
71 
72 def Buffering():
73  # always use the real one
74  return _getDisplay(None, create=True).Buffering()
75 
76 #
77 # Functions provided for backwards compatibility
78 #
79 
80 
81 def setMaskPlaneColor(name, color=None, frame=None):
82  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
83 
84 
85 def getMaskPlaneColor(name, frame=None):
86  return getDisplay(frame, create=True).getMaskPlaneColor(name)
87 
88 
89 def setMaskTransparency(name, frame=None):
90  return getDisplay(frame, create=True).setMaskTransparency(name)
91 
92 
93 def getMaskTransparency(name, frame=None):
94  return getDisplay(frame, create=True).getMaskTransparency(name)
95 
96 
97 def show(frame=None):
98  return getDisplay(frame, create=True).show()
99 
100 
101 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
102  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
103 
104 
105 def erase(frame=None):
106  return getDisplay(frame, create=True).erase()
107 
108 
109 def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
110  return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs)
111 
112 
113 def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
114  return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size)
115 
116 
117 def scale(algorithm, min, max=None, frame=None):
118  return getDisplay(frame, create=True).scale(algorithm, min, max)
119 
120 
121 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
122  disp = getDisplay(frame, create=True)
123 
124  disp.pan(colc, rowc, origin)
125 
126 
127 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
128  disp = getDisplay(frame, create=True)
129 
130  disp.zoom(zoomfac)
131  disp.pan(colc, rowc, origin)
132 
133 
134 def interact(frame=None):
135  return getDisplay(frame, create=True).interact()
136 
137 
138 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
139  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
140 
141 
142 def getActiveCallbackKeys(onlyActive=True, frame=None):
143  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
def erase(frame=None)
Definition: ds9.py:105
def __init__(self, exception)
Definition: ds9.py:48
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:142
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:117
def setMaskTransparency(name, frame=None)
Definition: ds9.py:89
def __call__(self, args, kwargs)
Definition: ds9.py:55
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, args, kwargs)
Definition: ds9.py:109
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:121
def show(frame=None)
Definition: ds9.py:97
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:127
def setDefaultBackend(backend)
Definition: interface.py:691
def mtv(data, frame=None, title="", wcs=None, args, kwargs)
Definition: ds9.py:101
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:113
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:138
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:85
def getMaskTransparency(name, frame=None)
Definition: ds9.py:93
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:81
def Buffering()
Definition: ds9.py:72
def interact(frame=None)
Definition: ds9.py:134