lsst.afw  18.1.0-14-gac42dcd43
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 deprecated.sphinx import deprecated
28 
29 from lsst.utils import TemplateMeta
30 
31 from ..slicing import supportSlicing
32 from ..disableArithmetic import disableImageArithmetic
33 from ..image.fitsIoWithOptions import imageReadFitsWithOptions, exposureWriteFitsWithOptions
34 from .exposure import ExposureI, ExposureF, ExposureD, ExposureU, ExposureL
35 
36 
37 class Exposure(metaclass=TemplateMeta):
38 
39  def _set(self, index, value, origin):
40  """Set the pixel at the given index to a triple (value, mask, variance).
41 
42  Parameters
43  ----------
44  index : `geom.Point2I`
45  Position of the pixel to assign to.
46  value : `tuple`
47  A tuple of (value, mask, variance) scalars.
48  origin : `ImageOrigin`
49  Coordinate system of ``index`` (`PARENT` or `LOCAL`).
50  """
51  self.maskedImage._set(index, value=value, origin=origin)
52 
53  def _get(self, index, origin):
54  """Return a triple (value, mask, variance) at the given index.
55 
56  Parameters
57  ----------
58  index : `geom.Point2I`
59  Position of the pixel to assign to.
60  origin : `ImageOrigin`
61  Coordinate system of ``index`` (`PARENT` or `LOCAL`).
62  """
63  return self.maskedImage._get(index, origin=origin)
64 
65  def __reduce__(self):
66  from lsst.afw.fits import reduceToFits
67  return reduceToFits(self)
68 
69  def convertF(self):
70  return ExposureF(self, deep=True)
71 
72  def convertD(self):
73  return ExposureD(self, deep=True)
74 
75  def getImage(self):
76  return self.maskedImage.image
77 
78  def setImage(self, image):
79  self.maskedImage.image = image
80 
81  image = property(getImage, setImage)
82 
83  def getMask(self):
84  return self.maskedImage.mask
85 
86  def setMask(self, mask):
87  self.maskedImage.mask = mask
88 
89  mask = property(getMask, setMask)
90 
91  def getVariance(self):
92  return self.maskedImage.variance
93 
94  def setVariance(self, variance):
95  self.maskedImage.variance = variance
96 
97  variance = property(getVariance, setVariance)
98 
99  readFitsWithOptions = classmethod(imageReadFitsWithOptions)
100 
101  writeFitsWithOptions = exposureWriteFitsWithOptions
102 
103  @deprecated(reason="Replaced with getPhotoCalib (will be removed after v18)", category=FutureWarning)
104  def getCalib(self, *args, **kwargs):
105  return self._getCalib(*args, **kwargs)
106 
107  @deprecated(reason="Replaced with setPhotoCalib (will be removed after v18)", category=FutureWarning)
108  def setCalib(self, *args, **kwargs):
109  self._setCalib(*args, **kwargs)
110 
111 
112 Exposure.register(np.int32, ExposureI)
113 Exposure.register(np.float32, ExposureF)
114 Exposure.register(np.float64, ExposureD)
115 Exposure.register(np.uint16, ExposureU)
116 Exposure.register(np.uint64, ExposureL)
117 Exposure.alias("I", ExposureI)
118 Exposure.alias("F", ExposureF)
119 Exposure.alias("D", ExposureD)
120 Exposure.alias("U", ExposureU)
121 Exposure.alias("L", ExposureL)
122 
123 for cls in set(Exposure.values()):
124  supportSlicing(cls)
daf::base::PropertySet * set
Definition: fits.cc:884