LSSTApplications  16.0-1-gce273f5+20,16.0-10-g1758552,16.0-10-gc1446dd+21,16.0-12-g569485f+3,16.0-13-g5f20d24+1,16.0-13-g80874fd+2,16.0-13-gb122224+12,16.0-14-g08f9460+4,16.0-14-g8a3b804,16.0-14-ga5060d2,16.0-15-g77ef378+7,16.0-18-gdf247dd+2,16.0-18-ge18fa5b,16.0-18-ge4151178,16.0-2-g0febb12+16,16.0-2-g9d5294e+46,16.0-2-gc6e0ed0+5,16.0-23-ge8a9b866+3,16.0-3-g404ea43+13,16.0-3-gbc759ec+19,16.0-3-gcfd6c53+44,16.0-3-ge00e371,16.0-4-g03cf288+35,16.0-4-g13a27c5+21,16.0-4-g5f3a788+15,16.0-4-ga3eb747+5,16.0-5-g1991253+21,16.0-5-g1e9226d+3,16.0-5-g6a53317,16.0-5-g865efd9+23,16.0-5-gb3f8a4b+53,16.0-5-gd0f1235+10,16.0-52-gad2f36c79,16.0-7-g6043bfc+9,16.0-7-gd2eeba5+3,16.0-7-gde5bd64+3,16.0-8-g0e813a6+1,16.0-9-g52c50f7,16.0-9-g73415e6,master-g5768c874b9+5,w.2018.41
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 import lsst.afw.display
29 import lsst.afw.image as afwImage
30 from .interface import getDisplay as _getDisplay, getDefaultBackend, setDefaultBackend
31 # Backwards compatibility. Downstream code should be converted to use display.RED etc.
32 from .interface import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE # noqa F401
33 try:
34  loaded
35 except NameError:
36  try:
37  if getDefaultBackend() is None:
38  setDefaultBackend("lsst.display.ds9")
39  getDisplay = _getDisplay
40  except Exception as e:
41  # No usable version of display_ds9.
42  # Let's define a version of getDisplay() which will throw an exception.
43 
44  # Prior to DM-9433, we used a closure to implicitly capture the
45  # exception being thrown for future reference. Following changes to
46  # exception scope rules in Python 3 (see PEP 3110), it's now regarded
47  # as clearer to make the capture explicit using the following class.
49  def __init__(self, exception):
50  # The exception being caught above may have a bulky context which we
51  # don't want to capture in a closure for all time: see DM-9504 for a
52  # full discussion. We therefore define a new exception of the same
53  # type, which just encodes the error text.
54  self.exception = type(exception)("%s (is display_ds9 setup?)" % exception)
55 
56  def __call__(self, *args, **kwargs):
57  raise self.exception
58 
59  getDisplay = _RaiseException(e)
60 
61  class DisplayImpl:
62  __init__ = getDisplay
63 
64  loaded = False
65  else:
66  loaded = True
67 
68 
69 def Buffering():
70  # always use the real one
71  return _getDisplay(None, create=True).Buffering()
72 
73 #
74 # Functions provided for backwards compatibility
75 #
76 
77 
78 def setMaskPlaneColor(name, color=None, frame=None):
79  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
80 
81 
82 def getMaskPlaneColor(name, frame=None):
83  return getDisplay(frame, create=True).getMaskPlaneColor(name)
84 
85 
86 def setMaskTransparency(name, frame=None):
87  return getDisplay(frame, create=True).setMaskTransparency(name)
88 
89 
90 def getMaskTransparency(name, frame=None):
91  return getDisplay(frame, create=True).getMaskTransparency(name)
92 
93 
94 def show(frame=None):
95  return getDisplay(frame, create=True).show()
96 
97 
98 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
99  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
100 
101 
102 def erase(frame=None):
103  return getDisplay(frame, create=True).erase()
104 
105 
106 def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
107  return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs)
108 
109 
110 def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
111  return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size)
112 
113 
114 def scale(algorithm, min, max=None, frame=None):
115  return getDisplay(frame, create=True).scale(algorithm, min, max)
116 
117 
118 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
119  disp = getDisplay(frame, create=True)
120 
121  disp.pan(colc, rowc, origin)
122 
123 
124 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
125  disp = getDisplay(frame, create=True)
126 
127  disp.zoom(zoomfac)
128  disp.pan(colc, rowc, origin)
129 
130 
131 def interact(frame=None):
132  return getDisplay(frame, create=True).interact()
133 
134 
135 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
136  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
137 
138 
139 def getActiveCallbackKeys(onlyActive=True, frame=None):
140  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
def erase(frame=None)
Definition: ds9.py:102
def __init__(self, exception)
Definition: ds9.py:49
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:139
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:114
def setMaskTransparency(name, frame=None)
Definition: ds9.py:86
def __call__(self, args, kwargs)
Definition: ds9.py:56
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, args, kwargs)
Definition: ds9.py:106
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:118
def show(frame=None)
Definition: ds9.py:94
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:124
def setDefaultBackend(backend)
Definition: interface.py:716
def mtv(data, frame=None, title="", wcs=None, args, kwargs)
Definition: ds9.py:98
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:110
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:135
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:82
def getMaskTransparency(name, frame=None)
Definition: ds9.py:90
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:78
def Buffering()
Definition: ds9.py:69
def interact(frame=None)
Definition: ds9.py:131