lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exposureContinued.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__ = ["Exposure"]
26 
27 from future.utils import with_metaclass
28 import numpy as np
29 
30 from lsst.utils import TemplateMeta
31 
32 from .exposure import ExposureI, ExposureF, ExposureD, ExposureU, ExposureL
33 
34 
35 class Exposure(with_metaclass(TemplateMeta, object)):
36 
37  def __reduce__(self):
38  from lsst.afw.fits import reduceToFits
39  return reduceToFits(self)
40 
41  def convertF(self):
42  return ExposureF(self, deep=True)
43 
44  def convertD(self):
45  return ExposureD(self, deep=True)
46 
47  @classmethod
48  def Factory(cls, *args, **kwargs):
49  """Construct a new Exposure of the same dtype.
50  """
51  return cls(*args, **kwargs)
52 
53  def clone(self):
54  """Return a deep copy of self"""
55  return self.Factory(self, deep=True)
56 
57  def __getitem__(self, imageSlice):
58  return self.Factory(self.getMaskedImage()[imageSlice])
59 
60  def __setitem__(self, imageSlice, rhs):
61  self.getMaskedImage[imageSlice] = rhs.getMaskedImage()
62 
63  def getImage(self):
64  return self.maskedImage.image
65 
66  def setImage(self, image):
67  self.maskedImage.image = image
68 
69  image = property(getImage, setImage)
70 
71  def getMask(self):
72  return self.maskedImage.mask
73 
74  def setMask(self, mask):
75  self.maskedImage.mask = mask
76 
77  mask = property(getMask, setMask)
78 
79  def getVariance(self):
80  return self.maskedImage.variance
81 
82  def setVariance(self, variance):
83  self.maskedImage.variance = variance
84 
85  variance = property(getVariance, setVariance)
86 
87 
88 Exposure.register(np.int32, ExposureI)
89 Exposure.register(np.float32, ExposureF)
90 Exposure.register(np.float64, ExposureD)
91 Exposure.register(np.uint16, ExposureU)
92 Exposure.register(np.int64, ExposureL)
93 Exposure.alias("I", ExposureI)
94 Exposure.alias("F", ExposureF)
95 Exposure.alias("D", ExposureD)
96 Exposure.alias("U", ExposureU)
97 Exposure.alias("L", ExposureL)