LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 ##
24 ## \file
25 ## \brief Support for talking to ds9 from python
26 ## \deprecated New code should use lsst.afw.display and set the backend to ds9
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, getDefaultBackend, setDefaultBackend, \
33  setDefaultFrame, getDefaultFrame, incrDefaultFrame
34 try:
35  loaded
36 except NameError:
37  try:
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.
48  class _RaiseException(object):
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(e)("%s (is display_d9 setup?)" % e)
55 
56  def __call__(self, *args, **kwargs):
57  raise self.exception
58 
59  getDisplay = _RaiseException(e)
60 
61  class DisplayImpl(object):
62  __init__ = getDisplay
63 
64  loaded = False
65  else:
66  loaded = True
67 
68 #
69 # Backwards compatibility. Downstream code should be converted to use display.RED etc.
70 #
71 from lsst.afw.display import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE
72 
73 def Buffering():
74  return _getDisplay(None, create=True).Buffering() # always use the real one
75 
76 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
77 #
78 # Functions provided for backwards compatibility
79 #
80 def setMaskPlaneColor(name, color=None, frame=None):
81  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
82 
83 def getMaskPlaneColor(name, frame=None):
84  return getDisplay(frame, create=True).getMaskPlaneColor(name)
85 
86 def setMaskTransparency(name, frame=None):
87  return getDisplay(frame, create=True).setMaskTransparency(name)
88 
89 def getMaskTransparency(name, frame=None):
90  return getDisplay(frame, create=True).getMaskTransparency(name)
91 
92 def show(frame=None):
93  return getDisplay(frame, create=True).show()
94 
95 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
96  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
97 
98 def erase(frame=None):
99  return getDisplay(frame, create=True).erase()
100 
101 def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
102  return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs)
103 
104 def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
105  return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size)
106 
107 def scale(algorithm, min, max=None, frame=None):
108  return getDisplay(frame, create=True).scale(algorithm, min, max)
109 
110 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
111  disp = getDisplay(frame, create=True)
112 
113  disp.pan(colc, rowc, origin)
114 
115 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
116  disp = getDisplay(frame, create=True)
117 
118  disp.zoom(zoomfac)
119  disp.pan(colc, rowc, origin)
120 
121 def interact(frame=None):
122  return getDisplay(frame, create=True).interact()
123 
124 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
125  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
126 
127 def getActiveCallbackKeys(onlyActive=True, frame=None):
128  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
def getActiveCallbackKeys
Definition: ds9.py:127
def setMaskPlaneColor
Definition: ds9.py:80
def getMaskPlaneColor
Definition: ds9.py:83
def getMaskTransparency
Definition: ds9.py:89
def setMaskTransparency
Definition: ds9.py:86