LSST Applications  21.0.0-1-g8760c09+3ec9fa6d59,21.0.0-1-ga51b5d4+1a3c9f8315,21.0.0-13-g5daad6e+2e8edea047,21.0.0-15-g543e7c3+e4ac1ef71f,21.0.0-15-g5a7caf0+08c1890463,21.0.0-15-ge3888ae+d5f2eb71b7,21.0.0-15-gfb99f82+9e2f6ff707,21.0.0-18-g546cdbd+4e75b35dac,21.0.0-2-g103fe59+b77ac56db3,21.0.0-2-g45278ab+3ec9fa6d59,21.0.0-2-g5242d73+8a658b4ab3,21.0.0-2-g7f82c8f+e76196b80b,21.0.0-2-g8faa9b5+a13d88a6a5,21.0.0-2-ga326454+e76196b80b,21.0.0-2-gde069b7+135055f2fa,21.0.0-2-gecfae73+345e77691a,21.0.0-2-gfc62afb+8a658b4ab3,21.0.0-20-g35aa1e9+3afe4fe733,21.0.0-20-g8cd22d88+eb66f50d9f,21.0.0-3-g357aad2+16e3f8303a,21.0.0-3-g4a4ce7f+8a658b4ab3,21.0.0-3-g4be5c26+8a658b4ab3,21.0.0-3-g65f322c+7c7224af56,21.0.0-3-ge02ed75+9e2f6ff707,21.0.0-30-gf21da11f8+33ac405c47,21.0.0-4-g591bb35+9e2f6ff707,21.0.0-4-g65b4814+4e75b35dac,21.0.0-4-ge8a399c+22b5d34500,21.0.0-5-g8c1d971+75b22be884,21.0.0-5-gcb07a25+7075ac2890,21.0.0-5-gcc89fd6+a13d88a6a5,21.0.0-5-gd00fb1e+5ce235a660,21.0.0-6-gc675373+8a658b4ab3,21.0.0-7-gdf92d54+3ec9fa6d59,21.0.0-72-gffa78901+7685cf5dd5,21.0.0-8-g5674e7b+3979a46207,21.0.0-8-g72414d6+11243696b5,master-gac4afde19b+9e2f6ff707,w.2021.17
LSST Data Management Base Package
ds9.py
Go to the documentation of this file.
1 # This file is part of afw.
2 #
3 # Developed for the LSST Data Management System.
4 # This product includes software developed by the LSST Project
5 # (https://www.lsst.org).
6 # See the COPYRIGHT file at the top-level directory of this distribution
7 # for details of code ownership.
8 #
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <https://www.gnu.org/licenses/>.
21 
22 import lsst.afw.display
23 import lsst.afw.image as afwImage
24 from .interface import getDisplay as _getDisplay, getDefaultBackend, setDefaultBackend
25 # Backwards compatibility. Downstream code should be converted to use display.RED etc.
26 from .interface import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE # noqa: F401
27 try:
28  loaded
29 except NameError:
30  try:
31  if getDefaultBackend() is None:
32  setDefaultBackend("lsst.display.ds9")
33  getDisplay = _getDisplay
34  except Exception as e:
35  # No usable version of display_ds9.
36  # Let's define a version of getDisplay() which will throw an exception.
37 
38  # Prior to DM-9433, we used a closure to implicitly capture the
39  # exception being thrown for future reference. Following changes to
40  # exception scope rules in Python 3 (see PEP 3110), it's now regarded
41  # as clearer to make the capture explicit using the following class.
43  def __init__(self, exception):
44  # The exception being caught above may have a bulky context which we
45  # don't want to capture in a closure for all time: see DM-9504 for a
46  # full discussion. We therefore define a new exception of the same
47  # type, which just encodes the error text.
48  self.exceptionexception = type(exception)(f"{exception} (is display_ds9 setup?)")
49 
50  def __call__(self, *args, **kwargs):
51  raise self.exceptionexception
52 
53  getDisplay = _RaiseException(e)
54 
55  class DisplayImpl:
56  __init__ = getDisplay
57 
58  loaded = False
59  else:
60  loaded = True
61 
62 
63 def Buffering():
64  # always use the real one
65  return _getDisplay(None, create=True).Buffering()
66 
67 #
68 # Functions provided for backwards compatibility
69 #
70 
71 
72 def setMaskPlaneColor(name, color=None, frame=None):
73  return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
74 
75 
76 def getMaskPlaneColor(name, frame=None):
77  return getDisplay(frame, create=True).getMaskPlaneColor(name)
78 
79 
80 def setMaskTransparency(name, frame=None):
81  return getDisplay(frame, create=True).setMaskTransparency(name)
82 
83 
84 def getMaskTransparency(name, frame=None):
85  return getDisplay(frame, create=True).getMaskTransparency(name)
86 
87 
88 def show(frame=None):
89  return getDisplay(frame, create=True).show()
90 
91 
92 def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
93  return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
94 
95 
96 def erase(frame=None):
97  return getDisplay(frame, create=True).erase()
98 
99 
100 def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs):
101  return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs)
102 
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 
108 def scale(algorithm, min, max=None, frame=None):
109  return getDisplay(frame, create=True).scale(algorithm, min, max)
110 
111 
112 def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
113  disp = getDisplay(frame, create=True)
114 
115  disp.pan(colc, rowc, origin)
116 
117 
118 def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT):
119  disp = getDisplay(frame, create=True)
120 
121  disp.zoom(zoomfac)
122  disp.pan(colc, rowc, origin)
123 
124 
125 def interact(frame=None):
126  return getDisplay(frame, create=True).interact()
127 
128 
129 def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
130  return getDisplay(frame, create=True).setCallback(k, noRaise=False)
131 
132 
133 def getActiveCallbackKeys(onlyActive=True, frame=None):
134  return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
table::Key< int > type
Definition: Detector.cc:163
def __call__(self, *args, **kwargs)
Definition: ds9.py:50
def __init__(self, exception)
Definition: ds9.py:43
def setMaskPlaneColor(name, color=None, frame=None)
Definition: ds9.py:72
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs)
Definition: ds9.py:100
def show(frame=None)
Definition: ds9.py:88
def setMaskTransparency(name, frame=None)
Definition: ds9.py:80
def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition: ds9.py:104
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:108
def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:118
def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition: ds9.py:129
def erase(frame=None)
Definition: ds9.py:96
def getActiveCallbackKeys(onlyActive=True, frame=None)
Definition: ds9.py:133
def getMaskPlaneColor(name, frame=None)
Definition: ds9.py:76
def getMaskTransparency(name, frame=None)
Definition: ds9.py:84
def mtv(data, frame=None, title="", wcs=None, *args, **kwargs)
Definition: ds9.py:92
def interact(frame=None)
Definition: ds9.py:125
def Buffering()
Definition: ds9.py:63
def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition: ds9.py:112
def setDefaultBackend(backend)
Definition: interface.py:870
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.