Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

# 

# LSST Data Management System 

# Copyright 2008, 2009, 2010, 2015 LSST Corporation. 

# 

# This product includes software developed by the 

# LSST Project (http://www.lsst.org/). 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the LSST License Statement and 

# the GNU General Public License along with this program. If not, 

# see <http://www.lsstcorp.org/LegalNotices/>. 

# 

 

import lsst.afw.display 

import lsst.afw.image as afwImage 

from .interface import getDisplay as _getDisplay, getDefaultBackend, setDefaultBackend 

# Backwards compatibility. Downstream code should be converted to use display.RED etc. 

from .interface import BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE # noqa: F401 

try: 

loaded 

except NameError: 

try: 

32 ↛ 34line 32 didn't jump to line 34, because the condition on line 32 was never false if getDefaultBackend() is None: 

setDefaultBackend("lsst.display.ds9") 

getDisplay = _getDisplay 

except Exception as e: 

# No usable version of display_ds9. 

# Let's define a version of getDisplay() which will throw an exception. 

 

# Prior to DM-9433, we used a closure to implicitly capture the 

# exception being thrown for future reference. Following changes to 

# exception scope rules in Python 3 (see PEP 3110), it's now regarded 

# as clearer to make the capture explicit using the following class. 

class _RaiseException: 

def __init__(self, exception): 

# The exception being caught above may have a bulky context which we 

# don't want to capture in a closure for all time: see DM-9504 for a 

# full discussion. We therefore define a new exception of the same 

# type, which just encodes the error text. 

self.exception = type(exception)(f"{exception} (is display_ds9 setup?)") 

 

def __call__(self, *args, **kwargs): 

raise self.exception 

 

getDisplay = _RaiseException(e) 

 

class DisplayImpl: 

__init__ = getDisplay 

 

loaded = False 

else: 

loaded = True 

 

 

def Buffering(): 

# always use the real one 

return _getDisplay(None, create=True).Buffering() 

 

# 

# Functions provided for backwards compatibility 

# 

 

 

def setMaskPlaneColor(name, color=None, frame=None): 

return getDisplay(frame, create=True).setMaskPlaneColor(name, color) 

 

 

def getMaskPlaneColor(name, frame=None): 

return getDisplay(frame, create=True).getMaskPlaneColor(name) 

 

 

def setMaskTransparency(name, frame=None): 

return getDisplay(frame, create=True).setMaskTransparency(name) 

 

 

def getMaskTransparency(name, frame=None): 

return getDisplay(frame, create=True).getMaskTransparency(name) 

 

 

def show(frame=None): 

return getDisplay(frame, create=True).show() 

 

 

def mtv(data, frame=None, title="", wcs=None, *args, **kwargs): 

return getDisplay(frame, create=True).mtv(data, title, wcs, *args, **kwargs) 

 

 

def erase(frame=None): 

return getDisplay(frame, create=True).erase() 

 

 

def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, *args, **kwargs): 

return getDisplay(frame, create=True).dot(symb, c, r, size, ctype, origin, *args, **kwargs) 

 

 

def line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5): 

return getDisplay(frame, create=True).line(points, origin, symbs, ctype, size) 

 

 

def scale(algorithm, min, max=None, frame=None): 

return getDisplay(frame, create=True).scale(algorithm, min, max) 

 

 

def pan(colc=None, rowc=None, frame=None, origin=afwImage.PARENT): 

disp = getDisplay(frame, create=True) 

 

disp.pan(colc, rowc, origin) 

 

 

def zoom(zoomfac=None, colc=None, rowc=None, frame=None, origin=afwImage.PARENT): 

disp = getDisplay(frame, create=True) 

 

disp.zoom(zoomfac) 

disp.pan(colc, rowc, origin) 

 

 

def interact(frame=None): 

return getDisplay(frame, create=True).interact() 

 

 

def setCallback(k, func=lsst.afw.display.noop_callback, noRaise=False, frame=None): 

return getDisplay(frame, create=True).setCallback(k, noRaise=False) 

 

 

def getActiveCallbackKeys(onlyActive=True, frame=None): 

return getDisplay(frame, create=True).getActiveCallbackKeys(onlyActive)