LSSTApplications  16.0-10-g4f78f78+16,16.0-10-gc1446dd+42,16.0-11-g09ed895+1,16.0-13-g7649090,16.0-14-g0a28612+1,16.0-14-g6c7ed55+16,16.0-15-ga29f190+1,16.0-16-g89065d4+14,16.0-16-gd8e3590+16,16.0-16-ge6a35c8+6,16.0-17-g7e0e4ff+10,16.0-17-ga3d2e9f,16.0-19-gb830ed4e+16,16.0-2-g0febb12+21,16.0-2-g9d5294e+61,16.0-2-ga8830df+5,16.0-24-gc1c7f52+9,16.0-25-g07af9f2+1,16.0-3-ge00e371+21,16.0-36-g07840cb1,16.0-4-g18f3627+5,16.0-4-g5f3a788+20,16.0-4-ga3eb747+10,16.0-4-gabf74b7+16,16.0-4-gade8416+9,16.0-4-gb13d127+5,16.0-5-g6a53317+21,16.0-5-gb3f8a4b+74,16.0-5-gef99c9f+12,16.0-6-g9321be7+4,16.0-6-gcbc7b31+22,16.0-6-gf49912c+16,16.0-63-gae20905ba,16.0-7-gd2eeba5+31,16.0-8-g21fd5fe+16,16.0-8-g3a9f023+12,16.0-8-g4734f7a,16.0-9-g85d1a16+16,16.0-9-gf5c1f43,master-g07ce7b41a7,w.2018.48
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
table::Key< int > type
Definition: Detector.cc:164
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