22 __all__ = [
"MultibandExposure"]
27 from .
import Exposure, ExposureF
28 from ..image._multiband
import MultibandImage, MultibandTripleBase
29 from ..image._multiband
import tripleFromSingles, tripleFromArrays, makeTripleFromKwargs
30 from ..maskedImage
import MaskedImage
34 """MultibandExposure class
36 This class acts as a container for multiple `afw.Exposure` objects.
37 All exposures must have the same bounding box, and the associated
38 images must all have the same data type.
40 See `MultibandTripleBase` for parameter definitions.
42 def __init__(self, filters, image, mask, variance, psfs=None):
43 super().
__init__(filters, image, mask, variance)
45 for psf, exposure
in zip(psfs, self.
singlessingles):
50 """Construct a MultibandImage from a collection of single band images
52 see `tripleFromExposures` for a description of parameters
54 psfs = [s.getPsf()
for s
in singles]
58 def fromArrays(filters, image, mask, variance, bbox=None):
59 """Construct a MultibandExposure from a collection of arrays
61 see `tripleFromArrays` for a description of parameters
63 return tripleFromArrays(MultibandExposure, filters, image, mask, variance, bbox)
66 def fromKwargs(filters, filterKwargs, singleType=ExposureF, **kwargs):
67 """Build a MultibandImage from a set of keyword arguments
69 see `makeTripleFromKwargs` for a description of parameters
73 def _buildSingles(self, image=None, mask=None, variance=None):
74 """Make a new list of single band objects
79 List of `Image` objects that represent the image in each band.
81 List of `Mask` objects that represent the mask in each band.
83 List of `Image` objects that represent the variance in each band.
88 Tuple of `MaskedImage` objects for each band,
89 where the `image`, `mask`, and `variance` of each `single`
90 point to the multiband objects.
94 image = self.
imageimage
100 dtype = image.array.dtype
102 maskedImage =
MaskedImage(image=image[f], mask=mask[f], variance=variance[f], dtype=dtype)
103 single = Exposure(maskedImage, dtype=dtype)
104 singles.append(single)
105 return tuple(singles)
108 def fromButler(butler, filters, filterKwargs, *args, **kwargs):
109 """Load a multiband exposure from a butler
111 Because each band is stored in a separate exposure file,
112 this method can be used to load all of the exposures for
118 Butler connection to use to load the single band
120 filters: `list` or `str`
121 List of filter names for each band
123 Keyword arguments to pass to the Butler
124 that are different for each filter.
125 The keys are the names of the arguments and the values
126 should also be dictionaries, with filter names as keys
127 and the value of the argument for the given filter as values.
129 Arguments to the Butler.
131 Keyword arguments to pass to the Butler
132 that are the same in all bands.
136 result: `MultibandExposure`
137 The new `MultibandExposure` created by combining all of the
138 single band exposures.
143 if filterKwargs
is not None:
144 for key, value
in filterKwargs:
145 kwargs[key] = value[f]
146 exposures.append(butler.get(*args, filter=f, **kwargs))
147 return MultibandExposure.fromExposures(filters, exposures)
150 """Get a multiband PSF image
152 The PSF Kernel Image is computed for each band
153 and combined into a (filter, y, x) array and stored
155 The result is not cached, so if the same PSF is expected
156 to be used multiple times it is a good idea to store the
157 result in another variable.
161 position: `Point2D` or `tuple`
162 Coordinates to evaluate the PSF. If `position` is `None`
163 then `Psf.getAveragePosition()` is used.
167 self._psfImage: array
168 The multiband PSF image.
172 if not isinstance(position, Point2D)
and position
is not None:
173 position =
Point2D(position[0], position[1])
174 for single
in self.
singlessingles:
176 psfs.append(single.getPsf().computeKernelImage().array)
178 psfs.append(single.getPsf().computeKernelImage(position).array)
179 psfs = np.array(psfs)
184 """Get a multiband PSF image
186 The PSF Kernel Image is computed for each band
187 and combined into a (filter, y, x) array and stored
189 The result is not cached, so if the same PSF is expected
190 to be used multiple times it is a good idea to store the
191 result in another variable.
195 position: `Point2D` or `tuple`
196 Coordinates to evaluate the PSF. If `position` is `None`
197 then `Psf.getAveragePosition()` is used.
201 self._psfImage: array
202 The multiband PSF image.
206 if not isinstance(position, Point2D)
and position
is not None:
207 position =
Point2D(position[0], position[1])
208 for single
in self.
singlessingles:
210 psfs.append(single.getPsf().computeImage().array)
212 psfs.append(single.getPsf().computeImage(position).array)
213 psfs = np.array(psfs)
def fromButler(butler, filters, filterKwargs, *args, **kwargs)
def fromExposures(filters, singles)
def __init__(self, filters, image, mask, variance, psfs=None)
def computePsfKernelImage(self, position=None)
def fromArrays(filters, image, mask, variance, bbox=None)
def fromKwargs(filters, filterKwargs, singleType=ExposureF, **kwargs)
def computePsfImage(self, position=None)
def makeTripleFromKwargs(cls, filters, filterKwargs, singleType, **kwargs)
def tripleFromSingles(cls, filters, singles, **kwargs)
def tripleFromArrays(cls, filters, image, mask, variance, bbox=None)
Point< double, 2 > Point2D