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