lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
imageContinued.py
Go to the documentation of this file.
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 from __future__ import absolute_import, division, print_function
24 
25 __all__ = ["Image", "DecoratedImage"]
26 
27 from future.utils import with_metaclass
28 
29 import numpy as np
30 from lsst.utils import TemplateMeta
31 
32 from ..slicing import supportSlicing
33 from .image import ImageI, ImageF, ImageD, ImageU, ImageL
34 from .image import DecoratedImageI, DecoratedImageF, DecoratedImageD, DecoratedImageU, DecoratedImageL
35 
36 
37 class Image(with_metaclass(TemplateMeta, object)):
38 
39  def __reduce__(self):
40  from lsst.afw.fits import reduceToFits
41  return reduceToFits(self)
42 
43 
44 Image.register(np.int32, ImageI)
45 Image.register(np.float32, ImageF)
46 Image.register(np.float64, ImageD)
47 Image.register(np.uint16, ImageU)
48 Image.register(np.int64, ImageL)
49 Image.alias("I", ImageI)
50 Image.alias("F", ImageF)
51 Image.alias("D", ImageD)
52 Image.alias("U", ImageU)
53 Image.alias("L", ImageL)
54 
55 
56 class DecoratedImage(with_metaclass(TemplateMeta, object)):
57 
58  def convertF(self):
59  return ImageF(self, deep=True)
60 
61  def convertD(self):
62  return ImageD(self, deep=True)
63 
64 
65 DecoratedImage.register(np.int32, DecoratedImageI)
66 DecoratedImage.register(np.float32, DecoratedImageF)
67 DecoratedImage.register(np.float64, DecoratedImageD)
68 DecoratedImage.register(np.uint16, DecoratedImageU)
69 DecoratedImage.register(np.int64, DecoratedImageL)
70 DecoratedImage.alias("I", DecoratedImageI)
71 DecoratedImage.alias("F", DecoratedImageF)
72 DecoratedImage.alias("D", DecoratedImageD)
73 DecoratedImage.alias("U", DecoratedImageU)
74 DecoratedImage.alias("L", DecoratedImageL)
75 
76 
77 for cls in set(Image.values()):
78  supportSlicing(cls)
79 
80 for cls in set(DecoratedImage.values()):
81  supportSlicing(cls)