lsst.afw  13.0-39-g3deb52d
 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 
64 Exposure.register(np.int32, ExposureI)
65 Exposure.register(np.float32, ExposureF)
66 Exposure.register(np.float64, ExposureD)
67 Exposure.register(np.uint16, ExposureU)
68 Exposure.register(np.int64, ExposureL)
69 Exposure.alias("I", ExposureI)
70 Exposure.alias("F", ExposureF)
71 Exposure.alias("D", ExposureD)
72 Exposure.alias("U", ExposureU)
73 Exposure.alias("L", ExposureL)