LSSTApplications  15.0+21,16.0+1,16.0+3,16.0+4,16.0+8,16.0-1-g2115a9e+2,16.0-1-g4515a79+6,16.0-1-g5c6f5ee+4,16.0-1-g7bb14cc,16.0-1-g80120d7+4,16.0-1-g98efed3+4,16.0-1-gb7f560d+1,16.0-14-gb4f0cd2fa,16.0-2-g1ad129e+1,16.0-2-g2ed7261+1,16.0-2-g311bfd2,16.0-2-g568a347+3,16.0-2-g852da13+6,16.0-2-gd4c87cb+3,16.0-3-g099ede0,16.0-3-g150e024+3,16.0-3-g1f513a6,16.0-3-g958ce35,16.0-4-g08dccf71+4,16.0-4-g128aaef,16.0-4-g84f75fb+5,16.0-4-gcfd1396+4,16.0-4-gde8cee2,16.0-4-gdfb0d14+1,16.0-5-g7bc0afb+3,16.0-5-g86fb31a+3,16.0-6-g2dd73041+4,16.0-7-g95fb7bf,16.0-7-gc37dbc2+4,w.2018.28
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, 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  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(exception)("%s (is display_ds9 setup?)" % exception)
54 
55  def __call__(self, *args, **kwargs):
56  raise self.exception
57 
58  getDisplay = _RaiseException(e)
59 
60  class DisplayImpl:
61  __init__ = getDisplay
62 
63  loaded = False
64  else:
65  loaded = True
66 
67 
68 def Buffering():
69  # always use the real one
70  return _getDisplay(None, create=True).Buffering()
71 
72 #
73 # Functions provided for backwards compatibility
74 #
75 
76 
77 def setMaskPlaneColor(name, color=None, frame=None):
78  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
79 
80 
81 def getMaskPlaneColor(name, frame=None):
82  return getDisplay(frame, create=True).getMaskPlaneColor(name)
83 
84 
85 def setMaskTransparency(name, frame=None):
86  return getDisplay(frame, create=True).setMaskTransparency(name)
87 
88 
89 def getMaskTransparency(name, frame=None):
90  return getDisplay(frame, create=True).getMaskTransparency(name)
91 
92 
93 def show(frame=None):
94  return getDisplay(frame, create=True).show()
95 
96 
97 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
98  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
99 
100 
101 def erase(frame=None):
102  return getDisplay(frame, create=True).erase()
103 
104 
105 def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
106  return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs)
107 
108 
109 def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
110  return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size)
111 
112 
113 def scale(algorithm, min, max=None, frame=None):
114  return getDisplay(frame, create=True).scale(algorithm, min, max)
115 
116 
117 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
118  disp = getDisplay(frame, create=True)
119 
120  disp.pan(colc, rowc, origin)
121 
122 
123 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
124  disp = getDisplay(frame, create=True)
125 
126  disp.zoom(zoomfac)
127  disp.pan(colc, rowc, origin)
128 
129 
130 def interact(frame=None):
131  return getDisplay(frame, create=True).interact()
132 
133 
134 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
135  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
136 
137 
138 def getActiveCallbackKeys(onlyActive=True, frame=None):
139  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
def erase(frame=None)
Definition: ds9.py:101
def __init__(self, exception)
Definition: ds9.py:48
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:138
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:113
def setMaskTransparency(name, frame=None)
Definition: ds9.py:85
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:105
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:117
def show(frame=None)
Definition: ds9.py:93
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:123
def setDefaultBackend(backend)
Definition: interface.py:688
def mtv(data, frame=None, title="", wcs=None, args, kwargs)
Definition: ds9.py:97
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:109
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:134
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:81
def getMaskTransparency(name, frame=None)
Definition: ds9.py:89
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:77
def Buffering()
Definition: ds9.py:68
def interact(frame=None)
Definition: ds9.py:130