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# LSST Data Management System 

3# Copyright 2008-2017 LSST/AURA. 

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__all__ = ["Image", "DecoratedImage"] 

24 

25import numpy as np 

26from lsst.utils import TemplateMeta 

27 

28from ..slicing import supportSlicing 

29from ..disableArithmetic import disableImageArithmetic 

30from .fitsIoWithOptions import imageReadFitsWithOptions, imageWriteFitsWithOptions 

31from .image import ImageI, ImageF, ImageD, ImageU, ImageL 

32from .image import DecoratedImageI, DecoratedImageF, DecoratedImageD, DecoratedImageU, DecoratedImageL 

33 

34 

35class Image(metaclass=TemplateMeta): 

36 

37 def __reduce__(self): 

38 from lsst.afw.fits import reduceToFits 

39 return reduceToFits(self) 

40 

41 def __str__(self): 

42 return "{}, bbox={}".format(self.array, self.getBBox()) 

43 

44 def __repr__(self): 

45 return "{}.{}={}".format(self.__module__, self.__class__.__name__, str(self)) 

46 

47 readFitsWithOptions = classmethod(imageReadFitsWithOptions) 

48 

49 writeFitsWithOptions = imageWriteFitsWithOptions 

50 

51 

52Image.register(np.int32, ImageI) 

53Image.register(np.float32, ImageF) 

54Image.register(np.float64, ImageD) 

55Image.register(np.uint16, ImageU) 

56Image.register(np.uint64, ImageL) 

57Image.alias("I", ImageI) 

58Image.alias("F", ImageF) 

59Image.alias("D", ImageD) 

60Image.alias("U", ImageU) 

61Image.alias("L", ImageL) 

62 

63 

64class DecoratedImage(metaclass=TemplateMeta): 

65 

66 def convertF(self): 

67 return ImageF(self, deep=True) 

68 

69 def convertD(self): 

70 return ImageD(self, deep=True) 

71 

72 readFitsWithOptions = classmethod(imageReadFitsWithOptions) 

73 

74 writeFitsWithOptions = imageWriteFitsWithOptions 

75 

76 

77DecoratedImage.register(np.int32, DecoratedImageI) 

78DecoratedImage.register(np.float32, DecoratedImageF) 

79DecoratedImage.register(np.float64, DecoratedImageD) 

80DecoratedImage.register(np.uint16, DecoratedImageU) 

81DecoratedImage.register(np.uint64, DecoratedImageL) 

82DecoratedImage.alias("I", DecoratedImageI) 

83DecoratedImage.alias("F", DecoratedImageF) 

84DecoratedImage.alias("D", DecoratedImageD) 

85DecoratedImage.alias("U", DecoratedImageU) 

86DecoratedImage.alias("L", DecoratedImageL) 

87 

88 

89for cls in set(Image.values()): 

90 supportSlicing(cls) 

91 disableImageArithmetic(cls) 

92 

93for cls in set(DecoratedImage.values()): 

94 supportSlicing(cls) 

95 disableImageArithmetic(cls)