LSST Applications g1653933729+34a971ddd9,g1a997c3884+34a971ddd9,g2160c40384+da0d0eec6b,g28da252d5a+cb6ff358b6,g2bbee38e9b+e5a1bc5b38,g2bc492864f+e5a1bc5b38,g2ca4be77d2+2af33ed832,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+e5a1bc5b38,g35bb328faa+34a971ddd9,g3a166c0a6a+e5a1bc5b38,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9f5be647b3,g41af890bb2+f34483f65b,g5065538af8+53fd6e9482,g5a0bb5165c+1b31a0decc,g717e5f8c0f+19a1ad098c,g80478fca09+1acdc24a0d,g8204df1d8d+19a1ad098c,g82479be7b0+44a04e1d61,g858d7b2824+19a1ad098c,g9125e01d80+34a971ddd9,ga5288a1d22+ad6d5da1a4,gae0086650b+34a971ddd9,gb58c049af0+ace264a4f2,gbd397ab92a+d5fd0218dc,gc28159a63d+e5a1bc5b38,gcf0d15dbbd+618cb38075,gd6b7c0dfd1+3388d854ad,gda6a2b7d83+618cb38075,gdaeeff99f8+7774323b41,ge2409df99d+8082276ac0,ge33fd446bb+19a1ad098c,ge79ae78c31+e5a1bc5b38,gf0baf85859+890af219f9,gf5289d68f6+701f7b396a,w.2024.37
LSST Data Management Base Package
Loading...
Searching...
No Matches
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
23import lsst.afw.image as afwImage
24from .interface import getDisplay as _getDisplay, getDefaultBackend, setDefaultBackend
25# Backwards compatibility. Downstream code should be converted to use display.RED etc.
26from .interface import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE # noqa: F401
27try:
28 loaded
29except 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.exception = type(exception)(f"{exception} (is display_ds9 setup?)")
49
50 def __call__(self, *args, **kwargs):
51 raise self.exception
52
53 getDisplay = _RaiseException(e)
54
56 __init__ = getDisplay
57
58 loaded = False
59 else:
60 loaded = True
61
62
64 # always use the real one
65 return _getDisplay(None, create=True).Buffering()
66
67#
68# Functions provided for backwards compatibility
69#
70
71
72def setMaskPlaneColor(name, color=None, frame=None):
73 return getDisplay(frame, create=True).setMaskPlaneColor(name, color)
74
75
76def getMaskPlaneColor(name, frame=None):
77 return getDisplay(frame, create=True).getMaskPlaneColor(name)
78
79
80def setMaskTransparency(name, frame=None):
81 return getDisplay(frame, create=True).setMaskTransparency(name)
82
83
84def getMaskTransparency(name, frame=None):
85 return getDisplay(frame, create=True).getMaskTransparency(name)
86
87
88def show(frame=None):
89 return getDisplay(frame, create=True).show()
90
91
92def mtv(data, frame=None, title="", wcs=None, *args, **kwargs):
93 return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs)
94
95
96def erase(frame=None):
97 return getDisplay(frame, create=True).erase()
98
99
100def 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
104def 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
108def scale(algorithm, min, max=None, frame=None):
109 return getDisplay(frame, create=True).scale(algorithm, min, max)
110
111
112def 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
118def 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
125def interact(frame=None):
126 return getDisplay(frame, create=True).interact()
127
128
129def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None):
130 return getDisplay(frame, create=True).setCallback(k, noRaise=False)
131
132
133def getActiveCallbackKeys(onlyActive=True, frame=None):
134 return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)
__call__(self, *args, **kwargs)
Definition ds9.py:50
dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs)
Definition ds9.py:100
interact(frame=None)
Definition ds9.py:125
setMaskTransparency(name, frame=None)
Definition ds9.py:80
setMaskPlaneColor(name, color=None, frame=None)
Definition ds9.py:72
getActiveCallbackKeys(onlyActive=True, frame=None)
Definition ds9.py:133
getMaskPlaneColor(name, frame=None)
Definition ds9.py:76
pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition ds9.py:112
mtv(data, frame=None, title="", wcs=None, *args, **kwargs)
Definition ds9.py:92
scale(algorithm, min, max=None, frame=None)
Definition ds9.py:108
getMaskTransparency(name, frame=None)
Definition ds9.py:84
line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
Definition ds9.py:104
zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT)
Definition ds9.py:118
setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None)
Definition ds9.py:129
show(frame=None)
Definition ds9.py:88
erase(frame=None)
Definition ds9.py:96