LSSTApplications  21.0.0+1b62c9342b,21.0.0+45a059f35e,21.0.0-1-ga51b5d4+ceb9cf20a3,21.0.0-18-gaffd721+9e5b25d042,21.0.0-2-g103fe59+513edb8842,21.0.0-2-g1367e85+d9bb5204cb,21.0.0-2-g2909d54+45a059f35e,21.0.0-2-g45278ab+1b62c9342b,21.0.0-2-g4bc9b9f+71b33656bf,21.0.0-2-g5242d73+d9bb5204cb,21.0.0-2-g54e2caa+2eef0310e6,21.0.0-2-g66bcc37+d6fe391fa3,21.0.0-2-g7f82c8f+8938dec807,21.0.0-2-g8dde007+7bfb5851c8,21.0.0-2-g8f08a60+73884b2cf5,21.0.0-2-g973f35b+03b9a35142,21.0.0-2-ga326454+8938dec807,21.0.0-2-ga63a54e+935c8992c7,21.0.0-2-ga885a99+9a92674037,21.0.0-2-gc738bc1+ebe6cc8da6,21.0.0-2-gde069b7+5a8f2956b8,21.0.0-2-ge17e5af+d9bb5204cb,21.0.0-2-ge712728+0698132099,21.0.0-2-gecfae73+85cfcaf62c,21.0.0-2-gfc62afb+d9bb5204cb,21.0.0-21-g006371a9+aa7b4785b3,21.0.0-3-g4c5b185+4e2de95c30,21.0.0-3-g6d51c4a+d6fe391fa3,21.0.0-3-gaa929c8+fca53d2b73,21.0.0-3-gd222c45+afc8332dbe,21.0.0-3-gd5de2f2+d6fe391fa3,21.0.0-4-g3300ddd+1b62c9342b,21.0.0-4-g8a80011+06a34d01f4,21.0.0-5-gb7080ec+16cb3ec261,21.0.0-5-gcff38f6+f4fb272da2,21.0.0-6-gd3283ba+fca53d2b73,21.0.0-8-g19111d86+6561528872,21.0.0-8-gd9c33f4a0+b58bb1f4d6,w.2021.03
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 import lsst.afw.display
24 import lsst.afw.image as afwImage
25 from .interface import getDisplay as _getDisplay, getDefaultBackend, setDefaultBackend
26 # Backwards compatibility. Downstream code should be converted to use display.RED etc.
27 from .interface import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE # noqa: F401
28 try:
29  loaded
30 except NameError:
31  try:
32  if getDefaultBackend() is None:
33  setDefaultBackend("lsst.display.ds9")
34  getDisplay = _getDisplay
35  except Exception as e:
36  # No usable version of display_ds9.
37  # Let's define a version of getDisplay() which will throw an exception.
38 
39  # Prior to DM-9433, we used a closure to implicitly capture the
40  # exception being thrown for future reference. Following changes to
41  # exception scope rules in Python 3 (see PEP 3110), it's now regarded
42  # as clearer to make the capture explicit using the following class.
44  def __init__(self, exception):
45  # The exception being caught above may have a bulky context which we
46  # don't want to capture in a closure for all time: see DM-9504 for a
47  # full discussion. We therefore define a new exception of the same
48  # type, which just encodes the error text.
49  self.exception = type(exception)(f"{exception} (is display_ds9 setup?)")
50 
51  def __call__(self, *args, **kwargs):
52  raise self.exception
53 
54  getDisplay = _RaiseException(e)
55 
56  class DisplayImpl:
57  __init__ = getDisplay
58 
59  loaded = False
60  else:
61  loaded = True
62 
63 
64 def Buffering():
65  # always use the real one
66  return _getDisplay(None, create=True).Buffering()
67 
68 #
69 # Functions provided for backwards compatibility
70 #
71 
72 
73 def setMaskPlaneColor(name, color=None, frame=None):
74  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
75 
76 
77 def getMaskPlaneColor(name, frame=None):
78  return getDisplay(frame, create=True).getMaskPlaneColor(name)
79 
80 
81 def setMaskTransparency(name, frame=None):
82  return getDisplay(frame, create=True).setMaskTransparency(name)
83 
84 
85 def getMaskTransparency(name, frame=None):
86  return getDisplay(frame, create=True).getMaskTransparency(name)
87 
88 
89 def show(frame=None):
90  return getDisplay(frame, create=True).show()
91 
92 
93 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
94  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
95 
96 
97 def erase(frame=None):
98  return getDisplay(frame, create=True).erase()
99 
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 
105 def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5):
106  return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size)
107 
108 
109 def scale(algorithm, min, max=None, frame=None):
110  return getDisplay(frame, create=True).scale(algorithm, min, max)
111 
112 
113 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
114  disp = getDisplay(frame, create=True)
115 
116  disp.pan(colc, rowc, origin)
117 
118 
119 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
120  disp = getDisplay(frame, create=True)
121 
122  disp.zoom(zoomfac)
123  disp.pan(colc, rowc, origin)
124 
125 
126 def interact(frame=None):
127  return getDisplay(frame, create=True).interact()
128 
129 
130 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
131  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
132 
133 
134 def getActiveCallbackKeys(onlyActive=True, frame=None):
135  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw.display.ds9._RaiseException.exception
exception
Definition: ds9.py:49
lsst::afw.display.ds9.getDisplay
getDisplay
Definition: ds9.py:34
lsst::afw.display.ds9.getActiveCallbackKeys
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:134
lsst::afw.display.ds9.setMaskPlaneColor
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:73
lsst::afw.display
Definition: __init__.py:1
lsst::afw.display.ds9._RaiseException
Definition: ds9.py:43
lsst::afw.display.ds9.mtv
def mtv(data, frame=None, title="", wcs=None, *args, **kwargs)
Definition: ds9.py:93
lsst::afw.display.ds9.interact
def interact(frame=None)
Definition: ds9.py:126
lsst::afw.display.ds9.dot
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs)
Definition: ds9.py:101
lsst::afw.display.ds9.setCallback
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:130
lsst::afw.display.ds9.DisplayImpl
Definition: ds9.py:56
lsst::afw.display.ds9.getMaskPlaneColor
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:77
lsst::afw.display.interface.setDefaultBackend
def setDefaultBackend(backend)
Definition: interface.py:870
lsst::afw.display.ds9.Buffering
def Buffering()
Definition: ds9.py:64
lsst::afw.display.ds9.line
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:105
lsst::afw.display.ds9._RaiseException.__init__
def __init__(self, exception)
Definition: ds9.py:44
lsst::afw.display.ds9.setMaskTransparency
def setMaskTransparency(name, frame=None)
Definition: ds9.py:81
lsst::afw.display.ds9.pan
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:113
lsst::afw.display.ds9._RaiseException.__call__
def __call__(self, *args, **kwargs)
Definition: ds9.py:51
type
table::Key< int > type
Definition: Detector.cc:163
lsst::afw.display.ds9.scale
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109
lsst::afw.display.ds9.show
def show(frame=None)
Definition: ds9.py:89
lsst::afw.display.ds9.getMaskTransparency
def getMaskTransparency(name, frame=None)
Definition: ds9.py:85
lsst::afw.display.interface.getDefaultBackend
def getDefaultBackend()
Definition: interface.py:874
lsst::afw.display.ds9.erase
def erase(frame=None)
Definition: ds9.py:97
lsst::afw.display.ds9.zoom
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:119