lsst.afw  16.0-19-g2da375352+1
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 ..slicing import supportSlicing
30 from .exposure import ExposureI, ExposureF, ExposureD, ExposureU, ExposureL
31 
32 
33 class Exposure(metaclass=TemplateMeta):
34 
35  def _set(self, index, value, origin):
36  """Set the pixel at the given index to a triple (value, mask, variance).
37 
38  Parameters
39  ----------
40  index : `geom.Point2I`
41  Position of the pixel to assign to.
42  value : `tuple`
43  A tuple of (value, mask, variance) scalars.
44  origin : `ImageOrigin`
45  Coordinate system of ``index`` (`PARENT` or `LOCAL`).
46  """
47  self.maskedImage._set(index, value=value, origin=origin)
48 
49  def _get(self, index, origin):
50  """Return a triple (value, mask, variance) at the given index.
51 
52  Parameters
53  ----------
54  index : `geom.Point2I`
55  Position of the pixel to assign to.
56  origin : `ImageOrigin`
57  Coordinate system of ``index`` (`PARENT` or `LOCAL`).
58  """
59  return self.maskedImage._get(index, origin=origin)
60 
61  def __reduce__(self):
62  from lsst.afw.fits import reduceToFits
63  return reduceToFits(self)
64 
65  def convertF(self):
66  return ExposureF(self, deep=True)
67 
68  def convertD(self):
69  return ExposureD(self, deep=True)
70 
71  def getImage(self):
72  return self.maskedImage.image
73 
74  def setImage(self, image):
75  self.maskedImage.image = image
76 
77  image = property(getImage, setImage)
78 
79  def getMask(self):
80  return self.maskedImage.mask
81 
82  def setMask(self, mask):
83  self.maskedImage.mask = mask
84 
85  mask = property(getMask, setMask)
86 
87  def getVariance(self):
88  return self.maskedImage.variance
89 
90  def setVariance(self, variance):
91  self.maskedImage.variance = variance
92 
93  variance = property(getVariance, setVariance)
94 
95 
96 Exposure.register(np.int32, ExposureI)
97 Exposure.register(np.float32, ExposureF)
98 Exposure.register(np.float64, ExposureD)
99 Exposure.register(np.uint16, ExposureU)
100 Exposure.register(np.int64, ExposureL)
101 Exposure.alias("I", ExposureI)
102 Exposure.alias("F", ExposureF)
103 Exposure.alias("D", ExposureD)
104 Exposure.alias("U", ExposureU)
105 Exposure.alias("L", ExposureL)
106 
107 for cls in set(Exposure.values()):
108  supportSlicing(cls)
daf::base::PropertySet * set
Definition: fits.cc:818