Coverage for python / lsst / obs / subaru / dither.py: 0%

44 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-22 08:59 +0000

1import lsst.geom as geom 

2 

3try: 

4 pyplot 

5except NameError: 

6 import matplotlib.pyplot as pyplot 

7 pyplot.interactive(1) 

8 

9 

10def ditherDES(camera, scale=4.5, names=False): 

11 positions = [ 

12 (0.0, 0.0), 

13 (65.0, 100.0), 

14 (57.0, -99.0), 

15 (-230.0, -193.0), 

16 (-136.0, 267.0), 

17 (-430.0, 417.0), 

18 (553.0, 233.0), 

19 (628.0, 940.0), 

20 (621.0, -946.0), 

21 (-857.0, 1425.0), 

22 (10.0, 5.0), 

23 (1647.0, 231.0), 

24 (1305.0, -1764.0), 

25 (-2134.0, -511.0), 

26 (2700.0, 370.0), 

27 (-714.0, -2630.0), 

28 (2339.0, -2267.0), 

29 (-3001.0, -1267.0), 

30 (-152.0, -3785.0), 

31 (-3425.0, 1619.0), 

32 (1862.0, 3038.0), 

33 (5.0, 10.0), 

34 ] 

35 

36 xdither, ydither = [x*scale for x, y in positions], [y*scale for x, y in positions] 

37 x0, y0 = xdither[0], ydither[0] 

38 for x, y in zip(xdither, ydither): 

39 print("%8.1f %8.1f %8.1f %8.1f" % (x, y, x - x0, y - y0)) 

40 x0, y0 = x, y 

41 

42 pyplot.clf() 

43 pyplot.plot(xdither, ydither, "o") 

44 pyplot.axes().set_aspect('equal') 

45 

46 for raft in camera: 

47 for ccd in raft: 

48 ccd.setTrimmed(True) 

49 

50 width, height = ccd.getAllPixels(True).getDimensions() 

51 

52 corners = ((0.0, 0.0), (0.0, height), (width, height), (width, 0.0), (0.0, 0.0)) 

53 for (x0, y0), (x1, y1) in zip(corners[0:4], corners[1:5]): 

54 if x0 == x1 and y0 != y1: 

55 yList = [y0, y1] 

56 xList = [x0]*len(yList) 

57 elif y0 == y1 and x0 != x1: 

58 xList = [x0, x1] 

59 yList = [y0]*len(xList) 

60 else: 

61 raise RuntimeError("Should never get here") 

62 

63 xOriginal = [] 

64 yOriginal = [] 

65 for x, y in zip(xList, yList): 

66 position = ccd.getPositionFromPixel(geom.Point2D(x, y)) # focal plane position 

67 

68 xOriginal.append(position.getMm().getX()) 

69 yOriginal.append(position.getMm().getY()) 

70 

71 pyplot.plot(xOriginal, yOriginal, 'k-') 

72 

73 x, y = ccd.getPositionFromPixel(geom.Point2D(width/2, height/2)).getMm() 

74 cid = ccd.getId() 

75 if names: 

76 pyplot.text(x, y, cid.getName(), ha='center', rotation=90 if height > width else 0, 

77 fontsize="smaller") 

78 else: 

79 pyplot.text(x, y, cid.getSerial(), ha='center', va='center') 

80 

81 

82if __name__ == "__main__": 

83 ditherDES() 

84 input("Exit? ")