LSSTApplications  11.0-24-g0a022a1,15.0+13,15.0+9,15.0-1-g19261fa+5,15.0-1-g1eca518+15,15.0-1-g60afb23+12,15.0-1-g615e0bb+4,15.0-1-g6668b0b+5,15.0-1-g788a293+12,15.0-1-ga91101e+12,15.0-1-gae1598d+8,15.0-1-gc45031d+15,15.0-1-gd076f1f+12,15.0-1-gdf18595+2,15.0-1-gf4f1c34+8,15.0-2-g100d730+5,15.0-2-g18f3f21+5,15.0-2-g35685a8+6,15.0-2-gf38729e+5,15.0-21-g91b8abf62,15.0-3-g150fc43+14,15.0-3-g6f085af+5,15.0-3-g707930d,15.0-3-g9103c06+8,15.0-3-ga03b4ca+16,15.0-3-gaec6799+5,15.0-3-gb7a597c+12,15.0-3-ge6a6747+5,15.0-4-g45f767a+8,15.0-4-g654b129+10,15.0-4-gf5d1e39,15.0-4-gff20472+15,15.0-5-ga70c291+5,15.0-6-g9a9df217+5,15.0-7-gab4c137+6,15.0-7-gab79a70c+4
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 # Backwards compatibility. Downstream code should be converted to use display.RED etc.
34 from .interface import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE # noqa F401
35 try:
36  loaded
37 except NameError:
38  try:
39  setDefaultBackend("lsst.display.ds9")
40  getDisplay = _getDisplay
41  except Exception as e:
42  # No usable version of display_ds9.
43  # Let's define a version of getDisplay() which will throw an exception.
44 
45  # Prior to DM-9433, we used a closure to implicitly capture the
46  # exception being thrown for future reference. Following changes to
47  # exception scope rules in Python 3 (see PEP 3110), it's now regarded
48  # as clearer to make the capture explicit using the following class.
50  def __init__(self, exception):
51  # The exception being caught above may have a bulky context which we
52  # don't want to capture in a closure for all time: see DM-9504 for a
53  # full discussion. We therefore define a new exception of the same
54  # type, which just encodes the error text.
55  self.exception = type(exception)("%s (is display_ds9 setup?)" % exception)
56 
57  def __call__(self, *args, **kwargs):
58  raise self.exception
59 
60  getDisplay = _RaiseException(e)
61 
63  __init__ = getDisplay
64 
65  loaded = False
66  else:
67  loaded = True
68 
69 
70 def Buffering():
71  # always use the real one
72  return _getDisplay(None, create=True).Buffering()
73 
74 #
75 # Functions provided for backwards compatibility
76 #
77 
78 
79 def setMaskPlaneColor(name, color=None, frame=None):
80  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
81 
82 
83 def getMaskPlaneColor(name, frame=None):
84  return getDisplay(frame, create=True).getMaskPlaneColor(name)
85 
86 
87 def setMaskTransparency(name, frame=None):
88  return getDisplay(frame, create=True).setMaskTransparency(name)
89 
90 
91 def getMaskTransparency(name, frame=None):
92  return getDisplay(frame, create=True).getMaskTransparency(name)
93 
94 
95 def show(frame=None):
96  return getDisplay(frame, create=True).show()
97 
98 
99 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
100  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
101 
102 
103 def erase(frame=None):
104  return getDisplay(frame, create=True).erase()
105 
106 
107 def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
108  return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs)
109 
110 
111 def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
112  return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size)
113 
114 
115 def scale(algorithm, min, max=None, frame=None):
116  return getDisplay(frame, create=True).scale(algorithm, min, max)
117 
118 
119 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
120  disp = getDisplay(frame, create=True)
121 
122  disp.pan(colc, rowc, origin)
123 
124 
125 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
126  disp = getDisplay(frame, create=True)
127 
128  disp.zoom(zoomfac)
129  disp.pan(colc, rowc, origin)
130 
131 
132 def interact(frame=None):
133  return getDisplay(frame, create=True).interact()
134 
135 
136 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
137  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
138 
139 
140 def getActiveCallbackKeys(onlyActive=True, frame=None):
141  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
def erase(frame=None)
Definition: ds9.py:103
def __init__(self, exception)
Definition: ds9.py:50
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:140
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:115
def setMaskTransparency(name, frame=None)
Definition: ds9.py:87
def __call__(self, args, kwargs)
Definition: ds9.py:57
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, args, kwargs)
Definition: ds9.py:107
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:119
def show(frame=None)
Definition: ds9.py:95
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:125
def setDefaultBackend(backend)
Definition: interface.py:691
def mtv(data, frame=None, title="", wcs=None, args, kwargs)
Definition: ds9.py:99
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:111
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:136
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:83
def getMaskTransparency(name, frame=None)
Definition: ds9.py:91
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:79
def Buffering()
Definition: ds9.py:70
def interact(frame=None)
Definition: ds9.py:132